Skip to content

Build your personal knowledge base with Trilium Notes

using enhanceTitle event instead of renderNode per https://github.com/mar10/fancytree/issues/927

azivner927415838cee
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js
index affcd7022f..8be2a0b9cf 100644
--- a/src/public/javascripts/services/tree.js
+++ b/src/public/javascripts/services/tree.js
@@ -81,9 +81,6 @@ async function setNodeTitleWithPrefix(node) {
const title = (prefix ? (prefix + " - ") : "") + noteTitle;
node.setTitle(utils.escapeHtml(title));
-
- // workaround for this: https://github.com/mar10/fancytree/issues/927
- node.render(true, false);
}
function getNode(childNoteId, parentNoteId) {
@@ -429,13 +426,17 @@ function initFancyTree(tree) {
clones: {
highlightActiveClones: true
},
- renderNode: async function (event, data) {
+ enhanceTitle: async function (event, data) {
const node = data.node;
+ const $span = $(node.span);
+
+ if (node.data.noteId !== 'root'
+ && node.data.noteId === await hoistedNoteService.getHoistedNoteId()
+ && $span.find('.unhoist-button').length === 0) {
- if (node.data.noteId !== 'root' && node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {
const unhoistButton = $('<span>&nbsp; (<a class="unhoist-button">unhoist</a>)</span>');
- $(node.span).append(unhoistButton);
+ $span.append(unhoistButton);
}
}
});