Skip to content

Build your personal knowledge base with Trilium Notes

feat(text): render note icons in autocompletion (closes #8188)

Elian Doran9f26d6efdcde
diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts
index 9ca4fa86fb..18982307ac 100644
--- a/apps/client/src/services/note_autocomplete.ts
+++ b/apps/client/src/services/note_autocomplete.ts
@@ -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
};
})
);
diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts
index 29b1a02699..f36eaadbd2 100644
--- a/apps/client/src/widgets/type_widgets/text/config.ts
+++ b/apps/client/src/widgets/type_widgets/text/config.ts
@@ -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;
},