Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(tree): use template for create child to improve performance
Elian Doran0867b81c7ad4
diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.tsindex 3e9481458c..b0446fae93 100644--- a/apps/client/src/widgets/note_tree.ts+++ b/apps/client/src/widgets/note_tree.ts@@ -1789,11 +1789,16 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {}function buildEnhanceTitle() {- return async (event: Event,+ const createChildTemplate = document.createElement("span");+ createChildTemplate.className = "tree-item-button tn-icon add-note-button bx bx-plus";+ createChildTemplate.title = t("note_tree.create-child-note");+ createChildTemplate.addEventListener("click", cancelClickPropagation);++ return async function enhanceTitle(event: Event,data: {node: Fancytree.FancytreeNode;noteId: string;- }) => {+ }) {const node = data.node;if (!node.data.noteId) {@@ -1841,11 +1846,7 @@ function buildEnhanceTitle() {&& !note.isLaunchBarConfig()&& !note.noteId.startsWith("_help")) {- 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);+ node.span.append(createChildTemplate.cloneNode());}if (isHoistedNote) {