mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +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: "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);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user