Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add support for search inside notebook

Abdullah Attabcd27e10c1e2
diff --git a/apps/web/src/components/search/index.js b/apps/web/src/components/search/index.js
index c43360bc7..3a7646e3c 100644
--- a/apps/web/src/components/search/index.js
+++ b/apps/web/src/components/search/index.js
@@ -29,7 +29,7 @@ function SearchBox({ onSearch }) {
id="search"
name="search"
type="text"
- sx={{ m: 0, mx: 1, mt: 1 }}
+ sx={{ m: 0, mx: 2, mt: 1 }}
placeholder="Type your query here"
onChange={debounce((e) => onSearch(e.target.value), 250)}
action={{
diff --git a/apps/web/src/views/search.js b/apps/web/src/views/search.js
index 94e606b93..30976d6ba 100644
--- a/apps/web/src/views/search.js
+++ b/apps/web/src/views/search.js
@@ -31,6 +31,12 @@ import Placeholder from "../components/placeholders";
async function typeToItems(type, context) {
switch (type) {
+ case "notebook": {
+ const selectedNotebook = notebookstore.get().selectedNotebook;
+ if (!selectedNotebook) return ["notes", []];
+ const notes = db.relations.to(selectedNotebook, "note");
+ return ["notes", notes];
+ }
case "notes": {
await db.notes.init();
if (!context) return ["notes", db.notes.all];
@@ -113,11 +119,14 @@ function Search({ type }) {
}
case "notebooks":
return "all notebooks";
+ case "notebook":
case "topics": {
const selectedNotebook = notebookstore.get().selectedNotebook;
if (!selectedNotebook) return "";
const notebook = db.notebooks.notebook(selectedNotebook.id);
- return `topics in ${notebook.title} notebook`;
+ return `${type === "topics" ? "topics" : "notes"} in ${
+ notebook.title
+ } notebook`;
}
case "tags":
return "all tags";