diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js index 32f151aee..ca2af98d5 100644 --- a/public/javascripts/context_menu.js +++ b/public/javascripts/context_menu.js @@ -69,7 +69,9 @@ const contextMenu = (function() { {title: "Copy / clone Ctrl+C", cmd: "copy", uiIcon: "ui-icon-copy"}, {title: "Cut Ctrl+X", cmd: "cut", uiIcon: "ui-icon-scissors"}, {title: "Paste into Ctrl+V", 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 Alt+-", 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.js index 402543d1b..68a560494 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 +V case 67: - if (event.ctrlKey) { // Ctrl-C + if (event.ctrlKey) { // Ctrl+C contextMenu.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+X contextMenu.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+V contextMenu.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.ejs index 0deae0479..509eea299 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -16,8 +16,8 @@
- - + +
@@ -45,7 +45,7 @@ Collapse note tree - + Scroll to current note