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
quick unhoist link/button
azivner841420360eab
diff --git a/src/public/javascripts/services/bootstrap.js b/src/public/javascripts/services/bootstrap.jsindex 5c9a10d0eb..a15072a174 100644--- a/src/public/javascripts/services/bootstrap.js+++ b/src/public/javascripts/services/bootstrap.js@@ -32,6 +32,7 @@ import tooltip from './tooltip.js';import bundle from "./bundle.js";import treeCache from "./tree_cache.js";import libraryLoader from "./library_loader.js";+import hoistedNoteService from './hoisted_note.js';// required for CKEditor image upload pluginwindow.glob.getCurrentNode = treeService.getCurrentNode;@@ -84,6 +85,8 @@ $(document).on("click", "button[data-help-page]", e => {$("#logout-button").toggle(!utils.isElectron());+$("#tree").on("click", ".unhoist-button", hoistedNoteService.unhoist);+if (utils.isElectron()) {require('electron').ipcRenderer.on('create-day-sub-note', async function(event, parentNoteId) {// this might occur when day note had to be createddiff --git a/src/public/javascripts/services/hoisted_note.js b/src/public/javascripts/services/hoisted_note.jsindex 2a64ad822e..db567239d6 100644--- a/src/public/javascripts/services/hoisted_note.js+++ b/src/public/javascripts/services/hoisted_note.js@@ -22,7 +22,12 @@ async function setHoistedNoteId(noteId) {await tree.reload();}+async function unhoist() {+ await setHoistedNoteId('root');+}+export default {getHoistedNoteId,- setHoistedNoteId+ setHoistedNoteId,+ unhoist}\ No newline at end of filediff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex 7389f733f3..4ad1fcc8b2 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -122,7 +122,7 @@ async function activateNote(notePath, newNote) {}// unhoist so we can activate the note- await hoistedNoteService.setHoistedNoteId('root');+ await hoistedNoteService.unhoist();}if (glob.activeDialog) {@@ -417,6 +417,15 @@ function initFancyTree(tree) {},clones: {highlightActiveClones: true+ },+ renderNode: async function (event, data) {+ const node = data.node;++ if (node.data.noteId !== 'root' && node.data.noteId === await hoistedNoteService.getHoistedNoteId()) {+ const unhoistButton = $('<span> (<a class="unhoist-button">unhoist</a>)</span>');++ $(node.span).append(unhoistButton);+ }}});diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.jsindex d8d1f05fcb..03d5a04259 100644--- a/src/public/javascripts/services/tree_context_menu.js+++ b/src/public/javascripts/services/tree_context_menu.js@@ -215,7 +215,7 @@ function selectContextMenuItem(event, cmd) {hoistedNoteService.setHoistedNoteId(node.data.noteId);}else if (cmd === "unhoist") {- hoistedNoteService.setHoistedNoteId('root');+ hoistedNoteService.unhoist();}else {messagingService.logError("Unknown command: " + cmd);diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.jsindex b3c8fca263..b5c63ca73d 100644--- a/src/public/javascripts/services/tree_keybindings.js+++ b/src/public/javascripts/services/tree_keybindings.js@@ -117,7 +117,7 @@ const keyBindings = {"ctrl+h": node => {hoistedNoteService.getHoistedNoteId().then(hoistedNoteId => {if (node.data.noteId === hoistedNoteId) {- hoistedNoteService.setHoistedNoteId('root');+ hoistedNoteService.unhoist();}else {hoistedNoteService.setHoistedNoteId(node.data.noteId);diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.cssindex d33276dcfa..420ba1bd18 100644--- a/src/public/stylesheets/style.css+++ b/src/public/stylesheets/style.css@@ -698,4 +698,10 @@ div[data-notify="container"] {#export-form .form-check-label {padding: 2px;+}++.unhoist-button {+ text-decoration: underline !important;+ color: blue !important;+ cursor: pointer !important;}\ No newline at end of file