Skip to content

Build your personal knowledge base with Trilium Notes

feat(tree): use direct DOM manipulation instead of jQuery

Elian Doran47fd2affa4e3
diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts
index 9a2c61d227..742d6490a5 100644
--- a/apps/client/src/widgets/note_tree.ts
+++ b/apps/client/src/widgets/note_tree.ts
@@ -153,7 +153,7 @@ const TPL = /*html*/`
const MAX_SEARCH_RESULTS_IN_TREE = 100;
// this has to be hanged on the actual elements to effectively intercept and stop click event
-const cancelClickPropagation: (e: JQuery.ClickEvent) => void = (e) => e.stopPropagation();
+const cancelClickPropagation: (e: JQuery.ClickEvent | MouseEvent) => void = (e) => e.stopPropagation();
// TODO: Fix once we remove Node.js API from public
type Timeout = NodeJS.Timeout | string | number | undefined;
@@ -652,12 +652,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
&& !note.isLaunchBarConfig()
&& !note.noteId.startsWith("_help")
) {
- const $createChildNoteButton = $(`<span class="tree-item-button tn-icon add-note-button bx bx-plus" title="${t("note_tree.create-child-note")}"></span>`).on(
- "click",
- cancelClickPropagation
- );
-
- $span.append($createChildNoteButton);
+ const createChildEl = document.createElement("span");
+ createChildEl.className = "tree-item-button tn-icon add-note-button bx bx-plus";
+ createChildEl.title = t("note_tree.create-child-note");
+ createChildEl.addEventListener("click", cancelClickPropagation);
+ node.span.append(createChildEl);
}
if (isHoistedNote) {