mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	small fixes in context menu item visibility
This commit is contained in:
		
							
								
								
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "trilium", | ||||
|   "version": "0.36.1-beta", | ||||
|   "version": "0.36.2", | ||||
|   "lockfileVersion": 1, | ||||
|   "requires": true, | ||||
|   "dependencies": { | ||||
|   | ||||
| @@ -39,8 +39,9 @@ class TreeContextMenu { | ||||
|         const noSelectedNotes = selNodes.length === 0 | ||||
|                 || (selNodes.length === 1 && selNodes[0] === this.node); | ||||
|  | ||||
|         const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNote.type !== 'search'; | ||||
|         const insertChildNoteEnabled = note.type !== 'search'; | ||||
|         const parentNotSearch = parentNote.type !== 'search'; | ||||
|         const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch; | ||||
|         const notSearch = note.type !== 'search'; | ||||
|  | ||||
|         return [ | ||||
|             { title: "Open in new tab", cmd: "openInTab", uiIcon: "empty", enabled: noSelectedNotes }, | ||||
| @@ -48,15 +49,15 @@ class TreeContextMenu { | ||||
|                 items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null, | ||||
|                 enabled: insertNoteAfterEnabled && noSelectedNotes }, | ||||
|             { title: "Insert child note <kbd>Ctrl+P</kbd>", cmd: "insertChildNote", uiIcon: "plus", | ||||
|                 items: insertChildNoteEnabled ? this.getNoteTypeItems("insertChildNote") : null, | ||||
|                 enabled: insertChildNoteEnabled && noSelectedNotes }, | ||||
|                 items: notSearch ? this.getNoteTypeItems("insertChildNote") : null, | ||||
|                 enabled: notSearch && noSelectedNotes }, | ||||
|             { title: "Delete <kbd>Delete</kbd>", cmd: "delete", uiIcon: "trash", | ||||
|                 enabled: isNotRoot && !isHoisted && parentNote.type !== 'search' }, | ||||
|                 enabled: isNotRoot && !isHoisted && parentNotSearch }, | ||||
|             { title: "----" }, | ||||
|             isHoisted ? null : { title: "Hoist note <kbd>Ctrl-H</kbd>", cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes }, | ||||
|             isHoisted ? null : { title: "Hoist note <kbd>Ctrl-H</kbd>", cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, | ||||
|             !isHoisted || !isNotRoot ? null : { title: "Unhoist note <kbd>Ctrl-H</kbd>", cmd: "unhoist", uiIcon: "arrow-up" }, | ||||
|             { title: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "empty", | ||||
|                 enabled: isNotRoot && parentNote.type !== 'search' && noSelectedNotes}, | ||||
|                 enabled: isNotRoot && parentNotSearch && noSelectedNotes}, | ||||
|             { title: "----" }, | ||||
|             { title: "Protect subtree", cmd: "protectSubtree", uiIcon: "shield-check", enabled: noSelectedNotes }, | ||||
|             { title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "shield-close", enabled: noSelectedNotes }, | ||||
| @@ -66,20 +67,20 @@ class TreeContextMenu { | ||||
|             { title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "scissors", | ||||
|                 enabled: isNotRoot }, | ||||
|             { title: "Paste into <kbd>Ctrl+V</kbd>", cmd: "pasteInto", uiIcon: "clipboard", | ||||
|                 enabled: !clipboard.isEmpty() && note.type !== 'search' && noSelectedNotes }, | ||||
|                 enabled: !clipboard.isEmpty() && notSearch && noSelectedNotes }, | ||||
|             { title: "Paste after", cmd: "pasteAfter", uiIcon: "clipboard", | ||||
|                 enabled: !clipboard.isEmpty() && isNotRoot && parentNote.type !== 'search' && noSelectedNotes }, | ||||
|                 enabled: !clipboard.isEmpty() && isNotRoot && parentNotSearch && noSelectedNotes }, | ||||
|             { title: "Duplicate note here", cmd: "duplicateNote", uiIcon: "empty", | ||||
|                 enabled: noSelectedNotes && (!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) }, | ||||
|                 enabled: noSelectedNotes && parentNotSearch && (!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) }, | ||||
|             { title: "----" }, | ||||
|             { title: "Export", cmd: "export", uiIcon: "empty", | ||||
|                 enabled: note.type !== 'search' && noSelectedNotes }, | ||||
|                 enabled: notSearch && noSelectedNotes }, | ||||
|             { title: "Import into note", cmd: "importIntoNote", uiIcon: "empty", | ||||
|                 enabled: note.type !== 'search' && noSelectedNotes }, | ||||
|                 enabled: notSearch && noSelectedNotes }, | ||||
|             { title: "----" }, | ||||
|             { title: "Collapse subtree <kbd>Alt+-</kbd>", cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes }, | ||||
|             { title: "Force note sync", cmd: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes }, | ||||
|             { title: "Sort alphabetically <kbd>Alt+S</kbd>", cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes } | ||||
|             { title: "Sort alphabetically <kbd>Alt+S</kbd>", cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch } | ||||
|         ].filter(row => row !== null); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,7 @@ import treeChangesService from "./branches.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import hoistedNoteService from "./hoisted_note.js"; | ||||
| import clipboard from "./clipboard.js"; | ||||
| import treeCache from "./tree_cache.js"; | ||||
|  | ||||
| const keyBindings = { | ||||
|     "del": node => { | ||||
| @@ -130,12 +131,16 @@ const keyBindings = { | ||||
|         } | ||||
|     }, | ||||
|     "ctrl+h": node => { | ||||
|         hoistedNoteService.getHoistedNoteId().then(hoistedNoteId => { | ||||
|         hoistedNoteService.getHoistedNoteId().then(async hoistedNoteId => { | ||||
|             if (node.data.noteId === hoistedNoteId) { | ||||
|                 hoistedNoteService.unhoist(); | ||||
|             } | ||||
|             else { | ||||
|                 hoistedNoteService.setHoistedNoteId(node.data.noteId); | ||||
|                 const note = await treeCache.getNote(node.data.noteId); | ||||
|  | ||||
|                 if (note.type !== 'search') { | ||||
|                     hoistedNoteService.setHoistedNoteId(node.data.noteId); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user