mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: add support for search inside notebook
This commit is contained in:
committed by
Abdullah Atta
parent
af9b9b7083
commit
bcd27e10c1
@@ -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={{
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user