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
added collapse sub-tree in context menu
azivnerdd69e0135b70
diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.jsindex 32f151aee8..ca2af98d56 100644--- a/public/javascripts/context_menu.js+++ b/public/javascripts/context_menu.js@@ -69,7 +69,9 @@ const contextMenu = (function() {{title: "Copy / clone <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"},{title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "ui-icon-scissors"},{title: "Paste into <kbd>Ctrl+V</kbd>", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"},- {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"}+ {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"},+ {title: "----"},+ {title: "Collapse sub-tree <kbd>Alt+-</kbd>", cmd: "collapse-sub-tree", uiIcon: "ui-icon-minus"}],beforeOpen: (event, ui) => {const node = $.ui.fancytree.getNode(ui.target);@@ -120,6 +122,9 @@ const contextMenu = (function() {else if (ui.cmd === "delete") {treeChanges.deleteNode(node);}+ else if (ui.cmd === "collapse-sub-tree") {+ noteTree.collapseTree(node);+ }else {messaging.logError("Unknown command: " + ui.cmd);}diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.jsindex 402543d1bc..68a5604948 100644--- a/public/javascripts/note_tree.js+++ b/public/javascripts/note_tree.js@@ -429,6 +429,9 @@ const noteTree = (function() {"f2": node => {editTreePrefix.showDialog(node);},+ "alt+-": node => {+ collapseTree(node);+ },// code below shouldn't be necessary normally, however there's some problem with interaction with context menu plugin// after opening context menu, standard shortcuts don't work, but they are detected here// so we essentially takeover the standard handling with our implementation.@@ -531,9 +534,9 @@ const noteTree = (function() {});return false;- // Handle Ctrl-C, -X and -V+ // Handle Ctrl+C, +X and +Vcase 67:- if (event.ctrlKey) { // Ctrl-C+ if (event.ctrlKey) { // Ctrl+CcontextMenu.copy(node);showMessage("Note copied into clipboard.");@@ -542,7 +545,7 @@ const noteTree = (function() {}break;case 88:- if (event.ctrlKey) { // Ctrl-X+ if (event.ctrlKey) { // Ctrl+XcontextMenu.cut(node);showMessage("Note cut into clipboard.");@@ -551,7 +554,7 @@ const noteTree = (function() {}break;case 86:- if (event.ctrlKey) { // Ctrl-V+ if (event.ctrlKey) { // Ctrl+VcontextMenu.pasteInto(node);showMessage("Note pasted from clipboard into current note.");@@ -603,10 +606,14 @@ const noteTree = (function() {$(() => loadTree().then(noteTree => initFancyTree(noteTree)));- function collapseTree() {- treeEl.fancytree("getRootNode").visit(node => {- node.setExpanded(false);- });+ function collapseTree(node = null) {+ if (!node) {+ node = treeEl.fancytree("getRootNode");+ }++ node.setExpanded(false);++ node.visit(node => node.setExpanded(false));}$(document).bind('keydown', 'alt+c', collapseTree);diff --git a/views/index.ejs b/views/index.ejsindex 0deae0479c..509eea2997 100644--- a/views/index.ejs+++ b/views/index.ejs@@ -16,8 +16,8 @@</div><div style="flex-grow: 100;">- <button class="btn btn-xs" onclick="jumpToNote.showDialog();" title="CTRL-J">Jump to note</button>- <button class="btn btn-xs" onclick="recentNotes.showDialog();" title="CTRL-E">Recent notes</button>+ <button class="btn btn-xs" onclick="jumpToNote.showDialog();" title="CTRL+J">Jump to note</button>+ <button class="btn btn-xs" onclick="recentNotes.showDialog();" title="CTRL+E">Recent notes</button><button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button><button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button></div>@@ -45,7 +45,7 @@<img src="images/icons/list.png" alt="Collapse note tree"/></a>- <a onclick="noteTree.scrollToCurrentNote()" title="Scroll to current note. Shortcut CTRL-." class="icon-action">+ <a onclick="noteTree.scrollToCurrentNote()" title="Scroll to current note. Shortcut CTRL+." class="icon-action"><img src="images/icons/crosshair.png" alt="Scroll to current note"/></a>