mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 10:56:00 +02:00
feat(text): render note icons in autocompletion (closes #8188)
This commit is contained in:
@@ -68,7 +68,8 @@ async function autocompleteSourceForCKEditor(queryText: string) {
|
||||
name: row.notePathTitle || "",
|
||||
link: `#${row.notePath}`,
|
||||
notePath: row.notePath,
|
||||
highlightedNotePathTitle: row.highlightedNotePathTitle
|
||||
highlightedNotePathTitle: row.highlightedNotePathTitle,
|
||||
icon: row.icon
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
@@ -182,9 +182,16 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
|
||||
marker: "@",
|
||||
feed: (queryText: string) => noteAutocompleteService.autocompleteSourceForCKEditor(queryText),
|
||||
itemRenderer: (item) => {
|
||||
const suggestion = item as Suggestion;
|
||||
const itemElement = document.createElement("button");
|
||||
|
||||
itemElement.innerHTML = `${(item as Suggestion).highlightedNotePathTitle} `;
|
||||
// Choose appropriate icon based on action
|
||||
let iconClass = suggestion.icon ?? "bx bx-note";
|
||||
if (suggestion.action === "create-note") {
|
||||
iconClass = "bx bx-plus";
|
||||
}
|
||||
|
||||
itemElement.innerHTML = `<span class="${iconClass}"></span> ${suggestion.highlightedNotePathTitle} `;
|
||||
|
||||
return itemElement;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user