mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 10:32:27 +08:00
refactor(note_autocomplete): icon as separate field
This commit is contained in:
parent
482243b419
commit
069e307ec4
@ -21,6 +21,7 @@ function getSearchDelay(notesCount: number): number {
|
|||||||
}
|
}
|
||||||
let searchDelay = getSearchDelay(notesCount);
|
let searchDelay = getSearchDelay(notesCount);
|
||||||
|
|
||||||
|
// TODO: Deduplicate with server.
|
||||||
export interface Suggestion {
|
export interface Suggestion {
|
||||||
noteTitle?: string;
|
noteTitle?: string;
|
||||||
externalLink?: string;
|
externalLink?: string;
|
||||||
@ -29,6 +30,7 @@ export interface Suggestion {
|
|||||||
highlightedNotePathTitle?: string;
|
highlightedNotePathTitle?: string;
|
||||||
action?: string | "create-note" | "search-notes" | "external-link";
|
action?: string | "create-note" | "search-notes" | "external-link";
|
||||||
parentNoteId?: string;
|
parentNoteId?: string;
|
||||||
|
icon?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
@ -262,7 +264,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
|
|||||||
},
|
},
|
||||||
displayKey: "notePathTitle",
|
displayKey: "notePathTitle",
|
||||||
templates: {
|
templates: {
|
||||||
suggestion: (suggestion) => suggestion.highlightedNotePathTitle
|
suggestion: (suggestion) => `<span class="${suggestion.icon ?? "bx bx-note"}"></span> ${suggestion.highlightedNotePathTitle}`
|
||||||
},
|
},
|
||||||
// we can't cache identical searches because notes can be created / renamed, new recent notes can be added
|
// we can't cache identical searches because notes can be created / renamed, new recent notes can be added
|
||||||
cache: false
|
cache: false
|
||||||
|
@ -75,7 +75,8 @@ function getRecentNotes(activeNoteId: string) {
|
|||||||
notePath: rn.notePath,
|
notePath: rn.notePath,
|
||||||
noteTitle: title,
|
noteTitle: title,
|
||||||
notePathTitle,
|
notePathTitle,
|
||||||
highlightedNotePathTitle: `<span class="${icon ?? "bx bx-note"}"></span> ${notePathTitle}`
|
highlightedNotePathTitle: utils.escapeHtml(notePathTitle),
|
||||||
|
icon: icon ?? "bx bx-note"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,8 @@ function searchNotesForAutocomplete(query: string, fastSearch: boolean = true) {
|
|||||||
notePath: result.notePath,
|
notePath: result.notePath,
|
||||||
noteTitle: title,
|
noteTitle: title,
|
||||||
notePathTitle: `${icon} ${result.notePathTitle}`,
|
notePathTitle: `${icon} ${result.notePathTitle}`,
|
||||||
highlightedNotePathTitle: `<span class="${icon ?? "bx bx-note"}"></span> ${result.highlightedNotePathTitle}`
|
highlightedNotePathTitle: result.highlightedNotePathTitle,
|
||||||
|
icon: icon ?? "bx bx-note"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user