mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added collapse sub-tree in context menu
This commit is contained in:
parent
ab6e78f726
commit
dd69e0135b
@ -69,7 +69,9 @@ const contextMenu = (function() {
|
|||||||
{title: "Copy / clone <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"},
|
{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: "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 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) => {
|
beforeOpen: (event, ui) => {
|
||||||
const node = $.ui.fancytree.getNode(ui.target);
|
const node = $.ui.fancytree.getNode(ui.target);
|
||||||
@ -120,6 +122,9 @@ const contextMenu = (function() {
|
|||||||
else if (ui.cmd === "delete") {
|
else if (ui.cmd === "delete") {
|
||||||
treeChanges.deleteNode(node);
|
treeChanges.deleteNode(node);
|
||||||
}
|
}
|
||||||
|
else if (ui.cmd === "collapse-sub-tree") {
|
||||||
|
noteTree.collapseTree(node);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
messaging.logError("Unknown command: " + ui.cmd);
|
messaging.logError("Unknown command: " + ui.cmd);
|
||||||
}
|
}
|
||||||
|
@ -429,6 +429,9 @@ const noteTree = (function() {
|
|||||||
"f2": node => {
|
"f2": node => {
|
||||||
editTreePrefix.showDialog(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
|
// 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
|
// after opening context menu, standard shortcuts don't work, but they are detected here
|
||||||
// so we essentially takeover the standard handling with our implementation.
|
// so we essentially takeover the standard handling with our implementation.
|
||||||
@ -531,9 +534,9 @@ const noteTree = (function() {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Handle Ctrl-C, -X and -V
|
// Handle Ctrl+C, +X and +V
|
||||||
case 67:
|
case 67:
|
||||||
if (event.ctrlKey) { // Ctrl-C
|
if (event.ctrlKey) { // Ctrl+C
|
||||||
contextMenu.copy(node);
|
contextMenu.copy(node);
|
||||||
|
|
||||||
showMessage("Note copied into clipboard.");
|
showMessage("Note copied into clipboard.");
|
||||||
@ -542,7 +545,7 @@ const noteTree = (function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 88:
|
case 88:
|
||||||
if (event.ctrlKey) { // Ctrl-X
|
if (event.ctrlKey) { // Ctrl+X
|
||||||
contextMenu.cut(node);
|
contextMenu.cut(node);
|
||||||
|
|
||||||
showMessage("Note cut into clipboard.");
|
showMessage("Note cut into clipboard.");
|
||||||
@ -551,7 +554,7 @@ const noteTree = (function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 86:
|
case 86:
|
||||||
if (event.ctrlKey) { // Ctrl-V
|
if (event.ctrlKey) { // Ctrl+V
|
||||||
contextMenu.pasteInto(node);
|
contextMenu.pasteInto(node);
|
||||||
|
|
||||||
showMessage("Note pasted from clipboard into current note.");
|
showMessage("Note pasted from clipboard into current note.");
|
||||||
@ -603,10 +606,14 @@ const noteTree = (function() {
|
|||||||
|
|
||||||
$(() => loadTree().then(noteTree => initFancyTree(noteTree)));
|
$(() => loadTree().then(noteTree => initFancyTree(noteTree)));
|
||||||
|
|
||||||
function collapseTree() {
|
function collapseTree(node = null) {
|
||||||
treeEl.fancytree("getRootNode").visit(node => {
|
if (!node) {
|
||||||
node.setExpanded(false);
|
node = treeEl.fancytree("getRootNode");
|
||||||
});
|
}
|
||||||
|
|
||||||
|
node.setExpanded(false);
|
||||||
|
|
||||||
|
node.visit(node => node.setExpanded(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).bind('keydown', 'alt+c', collapseTree);
|
$(document).bind('keydown', 'alt+c', collapseTree);
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="flex-grow: 100;">
|
<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="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="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="recentChanges.showDialog();">Recent changes</button>
|
||||||
<button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button>
|
<button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button>
|
||||||
</div>
|
</div>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<img src="images/icons/list.png" alt="Collapse note tree"/>
|
<img src="images/icons/list.png" alt="Collapse note tree"/>
|
||||||
</a>
|
</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"/>
|
<img src="images/icons/crosshair.png" alt="Scroll to current note"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user