mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	refactored KB handling and add link dialog
This commit is contained in:
		
							parent
							
								
									b2a48a1f3a
								
							
						
					
					
						commit
						7e41a2750c
					
				| @ -9,14 +9,13 @@ const $autoComplete = $("#add-link-note-autocomplete"); | |||||||
| const $linkTitle = $("#link-title"); | const $linkTitle = $("#link-title"); | ||||||
| const $addLinkTitleFormGroup = $("#add-link-title-form-group"); | const $addLinkTitleFormGroup = $("#add-link-title-form-group"); | ||||||
| 
 | 
 | ||||||
| export async function showDialog() { | /** @var TextTypeWidget */ | ||||||
|     appContext.trigger('executeInActiveEditor', { | let textTypeWidget; | ||||||
|         callback: textEditor => { |  | ||||||
|             const hasSelection = !textEditor.model.document.selection.isCollapsed; |  | ||||||
| 
 | 
 | ||||||
|             $addLinkTitleFormGroup.toggle(!hasSelection); | export async function showDialog(widget) { | ||||||
|         } |     textTypeWidget = widget; | ||||||
|     }); | 
 | ||||||
|  |     $addLinkTitleFormGroup.toggle(!textTypeWidget.hasSelection()); | ||||||
| 
 | 
 | ||||||
|     utils.openDialog($dialog); |     utils.openDialog($dialog); | ||||||
| 
 | 
 | ||||||
| @ -58,10 +57,7 @@ $form.on('submit', () => { | |||||||
|     if (notePath) { |     if (notePath) { | ||||||
|         $dialog.modal('hide'); |         $dialog.modal('hide'); | ||||||
| 
 | 
 | ||||||
|         appContext.trigger(`addLinkToActiveEditor`, { |         textTypeWidget.addLink($linkTitle.val(), '#' + notePath); | ||||||
|             linkTitle: $linkTitle.val(), |  | ||||||
|             linkHref: '#' + notePath |  | ||||||
|         }); |  | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|         console.error("No path to add link."); |         console.error("No path to add link."); | ||||||
|  | |||||||
| @ -42,10 +42,6 @@ export default class DialogCommandExecutor extends Component { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     addLinkToTextCommand() { |  | ||||||
|         import("../dialogs/add_link.js").then(d => d.showDialog()); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async cloneNoteIdsToCommand({noteIds}) { |     async cloneNoteIdsToCommand({noteIds}) { | ||||||
|         const d = await import("../dialogs/clone_to.js"); |         const d = await import("../dialogs/clone_to.js"); | ||||||
|         d.showDialog(noteIds); |         d.showDialog(noteIds); | ||||||
|  | |||||||
| @ -5,18 +5,39 @@ import appContext from "./app_context.js"; | |||||||
| const keyboardActionRepo = {}; | const keyboardActionRepo = {}; | ||||||
| 
 | 
 | ||||||
| const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => { | const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => { | ||||||
|  | 	actions = actions.filter(a => !!a.actionName); // filter out separators
 | ||||||
|  | 
 | ||||||
| 	for (const action of actions) { | 	for (const action of actions) { | ||||||
|  | 		action.effectiveShortcuts = action.effectiveShortcuts.filter(shortcut => !shortcut.startsWith("global:")); | ||||||
|  | 		action.actionName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1); | ||||||
|  | 
 | ||||||
| 		keyboardActionRepo[action.actionName] = action; | 		keyboardActionRepo[action.actionName] = action; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 		for (const shortcut of action.effectiveShortcuts || []) { | 	return actions; | ||||||
| 			if (shortcut && !shortcut.startsWith("global:")) { // global shortcuts should be handled in the electron code
 | }); | ||||||
| 				const eventName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1); |  | ||||||
| 
 | 
 | ||||||
| 				if (action.scope !== 'note-tree') { | async function getActionsForScope(scope) { | ||||||
| 					// empty object param so that destructuring with optional params work
 | 	const actions = await keyboardActionsLoaded; | ||||||
| 					utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {})); | 
 | ||||||
| 				} | 	return actions.filter(action => action.scope === scope); | ||||||
| 			} | } | ||||||
|  | 
 | ||||||
|  | async function setupActionsForElement(scope, $el, component) { | ||||||
|  | 	const actions = await getActionsForScope(scope); | ||||||
|  | 
 | ||||||
|  | 	for (const action of actions) { | ||||||
|  | 		for (const shortcut of action.effectiveShortcuts) { | ||||||
|  | 			utils.bindElShortcut($el, shortcut, () => component.triggerCommand(action.actionName)); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | getActionsForScope("window").then(actions => { | ||||||
|  | 	for (const action of actions) { | ||||||
|  | 		for (const shortcut of action.effectiveShortcuts) { | ||||||
|  | 			// empty object param so that destructuring with optional params work
 | ||||||
|  | 			utils.bindGlobalShortcut(shortcut, () => appContext.trigger(action.actionName, {})); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| }); | }); | ||||||
| @ -24,8 +45,6 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => { | |||||||
| server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => { | server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => { | ||||||
| 	for (const shortcut in shortcutForNotes) { | 	for (const shortcut in shortcutForNotes) { | ||||||
| 		utils.bindGlobalShortcut(shortcut, async () => { | 		utils.bindGlobalShortcut(shortcut, async () => { | ||||||
| 			const treeService = (await import("./tree.js")).default; |  | ||||||
| 
 |  | ||||||
| 			appContext.tabManager.getActiveTabContext().setNote(shortcutForNotes[shortcut]); | 			appContext.tabManager.getActiveTabContext().setNote(shortcutForNotes[shortcut]); | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| @ -104,5 +123,7 @@ export default { | |||||||
| 	setElementActionHandler, | 	setElementActionHandler, | ||||||
| 	triggerAction, | 	triggerAction, | ||||||
| 	getAction, | 	getAction, | ||||||
| 	updateDisplayedShortcuts | 	updateDisplayedShortcuts, | ||||||
|  | 	getActionsForScope, | ||||||
|  | 	setupActionsForElement | ||||||
| }; | }; | ||||||
| @ -51,39 +51,39 @@ class TreeContextMenu { | |||||||
| 
 | 
 | ||||||
|         return [ |         return [ | ||||||
|             { title: 'Open in new tab', cmd: "openInTab", uiIcon: "empty", enabled: noSelectedNotes }, |             { title: 'Open in new tab', cmd: "openInTab", uiIcon: "empty", enabled: noSelectedNotes }, | ||||||
|             { title: 'Insert note after <kbd data-kb-action="CreateNoteAfter"></kbd>', cmd: "insertNoteAfter", uiIcon: "plus", |             { title: 'Insert note after <kbd data-kb-action="createNoteAfter"></kbd>', cmd: "insertNoteAfter", uiIcon: "plus", | ||||||
|                 items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null, |                 items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null, | ||||||
|                 enabled: insertNoteAfterEnabled && noSelectedNotes }, |                 enabled: insertNoteAfterEnabled && noSelectedNotes }, | ||||||
|             { title: 'Insert child note <kbd data-kb-action="CreateNoteInto"></kbd>', cmd: "insertChildNote", uiIcon: "plus", |             { title: 'Insert child note <kbd data-kb-action="createNoteInto"></kbd>', cmd: "insertChildNote", uiIcon: "plus", | ||||||
|                 items: notSearch ? this.getNoteTypeItems("insertChildNote") : null, |                 items: notSearch ? this.getNoteTypeItems("insertChildNote") : null, | ||||||
|                 enabled: notSearch && noSelectedNotes }, |                 enabled: notSearch && noSelectedNotes }, | ||||||
|             { title: 'Delete <kbd data-kb-action="DeleteNotes"></kbd>', cmd: "delete", uiIcon: "trash", |             { title: 'Delete <kbd data-kb-action="deleteNotes"></kbd>', cmd: "delete", uiIcon: "trash", | ||||||
|                 enabled: isNotRoot && !isHoisted && parentNotSearch }, |                 enabled: isNotRoot && !isHoisted && parentNotSearch }, | ||||||
|             { title: "----" }, |             { title: "----" }, | ||||||
|             { title: 'Search in subtree <kbd data-kb-action="SearchInSubtree"></kbd>', cmd: "searchInSubtree", uiIcon: "search", |             { title: 'Search in subtree <kbd data-kb-action="searchInSubtree"></kbd>', cmd: "searchInSubtree", uiIcon: "search", | ||||||
|                 enabled: notSearch && noSelectedNotes }, |                 enabled: notSearch && noSelectedNotes }, | ||||||
|             isHoisted ? null : { title: 'Hoist note <kbd data-kb-action="ToggleNoteHoisting"></kbd>', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, |             isHoisted ? null : { title: 'Hoist note <kbd data-kb-action="toggleNoteHoisting"></kbd>', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, | ||||||
|             !isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-kb-action="ToggleNoteHoisting"></kbd>', cmd: "unhoist", uiIcon: "arrow-up" }, |             !isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-kb-action="ToggleNoteHoisting"></kbd>', cmd: "unhoist", uiIcon: "arrow-up" }, | ||||||
|             { title: 'Edit branch prefix <kbd data-kb-action="EditBranchPrefix"></kbd>', cmd: "editBranchPrefix", uiIcon: "empty", |             { title: 'Edit branch prefix <kbd data-kb-action="editBranchPrefix"></kbd>', cmd: "editBranchPrefix", uiIcon: "empty", | ||||||
|                 enabled: isNotRoot && parentNotSearch && noSelectedNotes}, |                 enabled: isNotRoot && parentNotSearch && noSelectedNotes}, | ||||||
|             { title: "Advanced", uiIcon: "empty", enabled: true, items: [ |             { title: "Advanced", uiIcon: "empty", enabled: true, items: [ | ||||||
|                     { title: 'Collapse subtree <kbd data-kb-action="CollapseSubtree"></kbd>', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes }, |                     { title: 'Collapse subtree <kbd data-kb-action="collapseSubtree"></kbd>', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes }, | ||||||
|                     { title: "Force note sync", cmd: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes }, |                     { title: "Force note sync", cmd: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes }, | ||||||
|                     { title: 'Sort alphabetically <kbd data-kb-action="SortChildNotes"></kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch } |                     { title: 'Sort alphabetically <kbd data-kb-action="sortChildNotes"></kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch } | ||||||
|                 ] }, |                 ] }, | ||||||
|             { title: "----" }, |             { title: "----" }, | ||||||
|             { title: "Protect subtree", cmd: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes }, |             { title: "Protect subtree", cmd: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes }, | ||||||
|             { title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "shield", enabled: noSelectedNotes }, |             { title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "shield", enabled: noSelectedNotes }, | ||||||
|             { title: "----" }, |             { title: "----" }, | ||||||
|             { title: 'Copy / clone <kbd data-kb-action="CopyNotesToClipboard"></kbd>', cmd: "copy", uiIcon: "copy", |             { title: 'Copy / clone <kbd data-kb-action="copyNotesToClipboard"></kbd>', cmd: "copy", uiIcon: "copy", | ||||||
|                 enabled: isNotRoot && !isHoisted }, |                 enabled: isNotRoot && !isHoisted }, | ||||||
|             { title: 'Clone to ... <kbd data-kb-action="CloneNotesTo"></kbd>', cmd: "cloneTo", uiIcon: "empty", |             { title: 'Clone to ... <kbd data-kb-action="cloneNotesTo"></kbd>', cmd: "cloneTo", uiIcon: "empty", | ||||||
|                 enabled: isNotRoot && !isHoisted }, |                 enabled: isNotRoot && !isHoisted }, | ||||||
|             { title: 'Cut <kbd data-kb-action="CutNotesToClipboard"></kbd>', cmd: "cut", uiIcon: "cut", |             { title: 'Cut <kbd data-kb-action="cutNotesToClipboard"></kbd>', cmd: "cut", uiIcon: "cut", | ||||||
|                 enabled: isNotRoot && !isHoisted && parentNotSearch }, |                 enabled: isNotRoot && !isHoisted && parentNotSearch }, | ||||||
|             { title: 'Move to ... <kbd data-kb-action="MoveNotesTo"></kbd>', cmd: "moveTo", uiIcon: "empty", |             { title: 'Move to ... <kbd data-kb-action="moveNotesTo"></kbd>', cmd: "moveTo", uiIcon: "empty", | ||||||
|                 enabled: isNotRoot && !isHoisted && parentNotSearch }, |                 enabled: isNotRoot && !isHoisted && parentNotSearch }, | ||||||
|             { title: 'Paste into <kbd data-kb-action="PasteNotesFromClipboard"></kbd>', cmd: "pasteInto", uiIcon: "paste", |             { title: 'Paste into <kbd data-kb-action="pasteNotesFromClipboard"></kbd>', cmd: "pasteInto", uiIcon: "paste", | ||||||
|                 enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes }, |                 enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes }, | ||||||
|             { title: 'Paste after', cmd: "pasteAfter", uiIcon: "paste", |             { title: 'Paste after', cmd: "pasteAfter", uiIcon: "paste", | ||||||
|                 enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes }, |                 enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes }, | ||||||
|  | |||||||
| @ -52,12 +52,12 @@ function getSelectedOrActiveBranchIds(treeWidget, node) { | |||||||
|  */ |  */ | ||||||
| function getTemplates(treeWidget) { | function getTemplates(treeWidget) { | ||||||
|     return { |     return { | ||||||
|         "DeleteNotes": node => { |         "deleteNotes": node => { | ||||||
|             const branchIds = getSelectedOrActiveBranchIds(treeWidget, node); |             const branchIds = getSelectedOrActiveBranchIds(treeWidget, node); | ||||||
| 
 | 
 | ||||||
|             treeChangesService.deleteNotes(treeWidget, branchIds); |             treeChangesService.deleteNotes(treeWidget, branchIds); | ||||||
|         }, |         }, | ||||||
|         "MoveNoteUp": node => { |         "moveNoteUp": node => { | ||||||
|             const beforeNode = node.getPrevSibling(); |             const beforeNode = node.getPrevSibling(); | ||||||
| 
 | 
 | ||||||
|             if (beforeNode !== null) { |             if (beforeNode !== null) { | ||||||
| @ -66,7 +66,7 @@ function getTemplates(treeWidget) { | |||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "MoveNoteDown": node => { |         "moveNoteDown": node => { | ||||||
|             const afterNode = node.getNextSibling(); |             const afterNode = node.getNextSibling(); | ||||||
|             if (afterNode !== null) { |             if (afterNode !== null) { | ||||||
|                 treeChangesService.moveAfterBranch([node.data.branchId], afterNode.data.branchId); |                 treeChangesService.moveAfterBranch([node.data.branchId], afterNode.data.branchId); | ||||||
| @ -74,12 +74,12 @@ function getTemplates(treeWidget) { | |||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "MoveNoteUpInHierarchy": node => { |         "moveNoteUpInHierarchy": node => { | ||||||
|             treeChangesService.moveNodeUpInHierarchy(node); |             treeChangesService.moveNodeUpInHierarchy(node); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "MoveNoteDownInHierarchy": node => { |         "moveNoteDownInHierarchy": node => { | ||||||
|             const toNode = node.getPrevSibling(); |             const toNode = node.getPrevSibling(); | ||||||
| 
 | 
 | ||||||
|             if (toNode !== null) { |             if (toNode !== null) { | ||||||
| @ -88,7 +88,7 @@ function getTemplates(treeWidget) { | |||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "AddNoteAboveToSelection": () => { |         "addNoteAboveToSelection": () => { | ||||||
|             const node = treeWidget.getFocusedNode(); |             const node = treeWidget.getFocusedNode(); | ||||||
| 
 | 
 | ||||||
|             if (!node) { |             if (!node) { | ||||||
| @ -113,7 +113,7 @@ function getTemplates(treeWidget) { | |||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "AddNoteBelowToSelection": () => { |         "addNoteBelowToSelection": () => { | ||||||
|             const node = treeWidget.getFocusedNode(); |             const node = treeWidget.getFocusedNode(); | ||||||
| 
 | 
 | ||||||
|             if (!node) { |             if (!node) { | ||||||
| @ -138,42 +138,42 @@ function getTemplates(treeWidget) { | |||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "CollapseSubtree": node => { |         "collapseSubtree": node => { | ||||||
|             treeWidget.collapseTree(node); |             treeWidget.collapseTree(node); | ||||||
|         }, |         }, | ||||||
|         "SortChildNotes": node => { |         "sortChildNotes": node => { | ||||||
|             treeService.sortAlphabetically(node.data.noteId); |             treeService.sortAlphabetically(node.data.noteId); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "SelectAllNotesInParent": node => { |         "selectAllNotesInParent": node => { | ||||||
|             for (const child of node.getParent().getChildren()) { |             for (const child of node.getParent().getChildren()) { | ||||||
|                 child.setSelected(true); |                 child.setSelected(true); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "CopyNotesToClipboard": node => { |         "copyNotesToClipboard": node => { | ||||||
|             clipboard.copy(getSelectedOrActiveBranchIds(treeWidget, node)); |             clipboard.copy(getSelectedOrActiveBranchIds(treeWidget, node)); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "CutNotesToClipboard": node => { |         "cutNotesToClipboard": node => { | ||||||
|             clipboard.cut(getSelectedOrActiveBranchIds(treeWidget, node)); |             clipboard.cut(getSelectedOrActiveBranchIds(treeWidget, node)); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "PasteNotesFromClipboard": node => { |         "pasteNotesFromClipboard": node => { | ||||||
|             clipboard.pasteInto(node.data.noteId); |             clipboard.pasteInto(node.data.noteId); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "EditNoteTitle": node => { |         "editNoteTitle": node => { | ||||||
|             appContext.trigger('focusOnTitle'); |             appContext.trigger('focusOnTitle'); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
|         }, |         }, | ||||||
|         "ActivateParentNote": node => { |         "activateParentNote": node => { | ||||||
|             if (!hoistedNoteService.isRootNode(node)) { |             if (!hoistedNoteService.isRootNode(node)) { | ||||||
|                 node.getParent().setActive().then(treeWidget.clearSelectedNodes); |                 node.getParent().setActive().then(treeWidget.clearSelectedNodes); | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -19,17 +19,17 @@ const WIDGET_TPL = ` | |||||||
| 
 | 
 | ||||||
|     <a data-trigger-event="collapseTree" |     <a data-trigger-event="collapseTree" | ||||||
|        title="Collapse note tree"  |        title="Collapse note tree"  | ||||||
|        data-kb-action="CollapseTree"  |        data-kb-action="collapseTree"  | ||||||
|        class="icon-action bx bx-layer-minus"></a> |        class="icon-action bx bx-layer-minus"></a> | ||||||
| 
 | 
 | ||||||
|     <a data-trigger-event="scrollToActiveNote" |     <a data-trigger-event="scrollToActiveNote" | ||||||
|        title="Scroll to active note"  |        title="Scroll to active note"  | ||||||
|        data-kb-action="ScrollToActiveNote"  |        data-kb-action="scrollToActiveNote"  | ||||||
|        class="icon-action bx bx-crosshair"></a> |        class="icon-action bx bx-crosshair"></a> | ||||||
| 
 | 
 | ||||||
|     <a data-trigger-event="searchNotes" |     <a data-trigger-event="searchNotes" | ||||||
|        title="Search in notes" |        title="Search in notes" | ||||||
|        data-kb-action="SearchNotes" |        data-kb-action="searchNotes" | ||||||
|        class="icon-action bx bx-search"></a> |        class="icon-action bx bx-search"></a> | ||||||
| </div> | </div> | ||||||
| `;
 | `;
 | ||||||
|  | |||||||
| @ -42,44 +42,44 @@ const TPL = ` | |||||||
|             <a class="dropdown-item open-dev-tools-button" data-trigger-event="openDevTools"> |             <a class="dropdown-item open-dev-tools-button" data-trigger-event="openDevTools"> | ||||||
|                 <span class="bx bx-terminal"></span> |                 <span class="bx bx-terminal"></span> | ||||||
|                 Open Dev Tools |                 Open Dev Tools | ||||||
|                 <kbd data-kb-action="OpenDevTools"></kbd> |                 <kbd data-kb-action="openDevTools"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="showSQLConsole"> |             <a class="dropdown-item" data-trigger-event="showSQLConsole"> | ||||||
|                 <span class="bx bx-data"></span> |                 <span class="bx bx-data"></span> | ||||||
|                 Open SQL Console |                 Open SQL Console | ||||||
|                 <kbd data-kb-action="ShowSQLConsole"></kbd> |                 <kbd data-kb-action="showSQLConsole"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="showBackendLog"> |             <a class="dropdown-item" data-trigger-event="showBackendLog"> | ||||||
|                 <span class="bx bx-empty"></span> |                 <span class="bx bx-empty"></span> | ||||||
|                 Show backend log |                 Show backend log | ||||||
|                 <kbd data-kb-action="ShowBackendLog"></kbd> |                 <kbd data-kb-action="showBackendLog"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="reloadFrontendApp"  |             <a class="dropdown-item" data-trigger-event="reloadFrontendApp"  | ||||||
|                 title="Reload can help with some visual glitches without restarting the whole app."> |                 title="Reload can help with some visual glitches without restarting the whole app."> | ||||||
|                 <span class="bx bx-empty"></span> |                 <span class="bx bx-empty"></span> | ||||||
|                 Reload frontend |                 Reload frontend | ||||||
|                 <kbd data-kb-action="ReloadFrontendApp"></kbd> |                 <kbd data-kb-action="reloadFrontendApp"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="toggleZenMode"> |             <a class="dropdown-item" data-trigger-event="toggleZenMode"> | ||||||
|                 <span class="bx bx-empty"></span> |                 <span class="bx bx-empty"></span> | ||||||
|                 Toggle Zen mode |                 Toggle Zen mode | ||||||
|                 <kbd data-kb-action="ToggleZenMode"></kbd> |                 <kbd data-kb-action="toggleZenMode"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="toggleFullscreen"> |             <a class="dropdown-item" data-trigger-event="toggleFullscreen"> | ||||||
|                 <span class="bx bx-empty"></span> |                 <span class="bx bx-empty"></span> | ||||||
|                 Toggle fullscreen |                 Toggle fullscreen | ||||||
|                 <kbd data-kb-action="ToggleFullscreen"></kbd> |                 <kbd data-kb-action="toggleFullscreen"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item" data-trigger-event="showHelp"> |             <a class="dropdown-item" data-trigger-event="showHelp"> | ||||||
|                 <span class="bx bx-info-circle"></span> |                 <span class="bx bx-info-circle"></span> | ||||||
|                 Show Help |                 Show Help | ||||||
|                 <kbd data-kb-action="ShowHelp"></kbd> |                 <kbd data-kb-action="showHelp"></kbd> | ||||||
|             </a> |             </a> | ||||||
| 
 | 
 | ||||||
|             <a class="dropdown-item show-about-dialog-button"> |             <a class="dropdown-item show-about-dialog-button"> | ||||||
|  | |||||||
| @ -8,13 +8,13 @@ const TPL = ` | |||||||
|     </button> |     </button> | ||||||
|     <div class="dropdown-menu dropdown-menu-right"> |     <div class="dropdown-menu dropdown-menu-right"> | ||||||
|         <a data-trigger-event="showNoteRevisions" class="dropdown-item show-note-revisions-button">Revisions</a> |         <a data-trigger-event="showNoteRevisions" class="dropdown-item show-note-revisions-button">Revisions</a> | ||||||
|         <a data-trigger-event="showAttributes" class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a> |         <a data-trigger-event="showAttributes" class="dropdown-item show-attributes-button"><kbd data-kb-action="showAttributes"></kbd> Attributes</a> | ||||||
|         <a data-trigger-event="showLinkMap" class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a> |         <a data-trigger-event="showLinkMap" class="dropdown-item show-link-map-button"><kbd data-kb-action="showLinkMap"></kbd> Link map</a> | ||||||
|         <a data-trigger-event="showNoteSource" class="dropdown-item show-source-button"><kbd data-kb-action="ShowNoteSource"></kbd> Note source</a> |         <a data-trigger-event="showNoteSource" class="dropdown-item show-source-button"><kbd data-kb-action="showNoteSource"></kbd> Note source</a> | ||||||
|         <a class="dropdown-item import-files-button">Import files</a> |         <a class="dropdown-item import-files-button">Import files</a> | ||||||
|         <a class="dropdown-item export-note-button">Export note</a> |         <a class="dropdown-item export-note-button">Export note</a> | ||||||
|         <a data-trigger-event="printActiveNote" class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a> |         <a data-trigger-event="printActiveNote" class="dropdown-item print-note-button"><kbd data-kb-action="printActiveNote"></kbd> Print note</a> | ||||||
|         <a data-trigger-event="showNoteInfo" class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a> |         <a data-trigger-event="showNoteInfo" class="dropdown-item show-note-info-button"><kbd data-kb-action="showNoteInfo"></kbd> Note info</a> | ||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -98,7 +98,7 @@ export default class NoteDetailWidget extends TabAwareWidget { | |||||||
|         if (!(this.type in this.typeWidgets)) { |         if (!(this.type in this.typeWidgets)) { | ||||||
|             const clazz = typeWidgetClasses[this.type]; |             const clazz = typeWidgetClasses[this.type]; | ||||||
| 
 | 
 | ||||||
|             const typeWidget = this.typeWidgets[this.type] = new clazz(this.appContext); |             const typeWidget = this.typeWidgets[this.type] = new clazz(this.appContext, this); | ||||||
|             typeWidget.spacedUpdate = this.spacedUpdate; |             typeWidget.spacedUpdate = this.spacedUpdate; | ||||||
| 
 | 
 | ||||||
|             this.children.push(typeWidget); |             this.children.push(typeWidget); | ||||||
|  | |||||||
| @ -32,12 +32,12 @@ const TPL = ` | |||||||
|     </style> |     </style> | ||||||
| 
 | 
 | ||||||
|     <div style="flex-grow: 100; display: flex;"> |     <div style="flex-grow: 100; display: flex;"> | ||||||
|         <button class="btn btn-sm jump-to-note-dialog-button" data-kb-action="JumpToNote"> |         <button class="btn btn-sm jump-to-note-dialog-button" data-kb-action="jumpToNote"> | ||||||
|             <span class="bx bx-crosshair"></span> |             <span class="bx bx-crosshair"></span> | ||||||
|             Jump to note |             Jump to note | ||||||
|         </button> |         </button> | ||||||
|      |      | ||||||
|         <button class="btn btn-sm recent-changes-button" data-kb-action="ShowRecentChanges"> |         <button class="btn btn-sm recent-changes-button" data-kb-action="showRecentChanges"> | ||||||
|             <span class="bx bx-history"></span> |             <span class="bx bx-history"></span> | ||||||
|      |      | ||||||
|             Recent changes |             Recent changes | ||||||
|  | |||||||
| @ -28,11 +28,11 @@ const TAB_TPL = ` | |||||||
|   <div class="note-tab-wrapper"> |   <div class="note-tab-wrapper"> | ||||||
|     <div class="note-tab-title"></div> |     <div class="note-tab-title"></div> | ||||||
|     <div class="note-tab-drag-handle"></div> |     <div class="note-tab-drag-handle"></div> | ||||||
|     <div class="note-tab-close kb-in-title" title="Close tab" data-kb-action="CloseActiveTab"><span>×</span></div> |     <div class="note-tab-close kb-in-title" title="Close tab" data-kb-action="closeActiveTab"><span>×</span></div> | ||||||
|   </div> |   </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| const NEW_TAB_BUTTON_TPL = `<div class="note-new-tab kb-in-title" data-kb-action="OpenNewTab" title="Add new tab">+</div>`; | const NEW_TAB_BUTTON_TPL = `<div class="note-new-tab kb-in-title" data-kb-action="openNewTab" title="Add new tab">+</div>`; | ||||||
| const FILLER_TPL = `<div class="tab-row-filler">
 | const FILLER_TPL = `<div class="tab-row-filler">
 | ||||||
|     <div class="tab-row-border"></div> |     <div class="tab-row-border"></div> | ||||||
| </div>`; | </div>`; | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import mimeTypesService from '../../services/mime_types.js'; | |||||||
| import TypeWidget from "./type_widget.js"; | import TypeWidget from "./type_widget.js"; | ||||||
| import utils from "../../services/utils.js"; | import utils from "../../services/utils.js"; | ||||||
| import appContext from "../../services/app_context.js"; | import appContext from "../../services/app_context.js"; | ||||||
|  | import keyboardActionService from "../../services/keyboard_actions.js"; | ||||||
| 
 | 
 | ||||||
| const ENABLE_INSPECTOR = false; | const ENABLE_INSPECTOR = false; | ||||||
| 
 | 
 | ||||||
| @ -99,6 +100,8 @@ export default class TextTypeWidget extends TypeWidget { | |||||||
| 
 | 
 | ||||||
|         this.initialized = this.initEditor(); |         this.initialized = this.initEditor(); | ||||||
| 
 | 
 | ||||||
|  |         keyboardActionService.setupActionsForElement('text-detail', this.$widget, this); | ||||||
|  | 
 | ||||||
|         return this.$widget; |         return this.$widget; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -184,11 +187,7 @@ export default class TextTypeWidget extends TypeWidget { | |||||||
|         this.$widget.scrollTop(0); |         this.$widget.scrollTop(0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     insertDateTimeToTextListener() { |     insertDateTimeToTextCommand() { | ||||||
|         if (!this.isActive()) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         const date = new Date(); |         const date = new Date(); | ||||||
|         const dateString = utils.formatDateTime(date); |         const dateString = utils.formatDateTime(date); | ||||||
| 
 | 
 | ||||||
| @ -221,11 +220,7 @@ export default class TextTypeWidget extends TypeWidget { | |||||||
|         this.addTextToEditor(text); |         this.addTextToEditor(text); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async addLinkToActiveEditorListener({linkTitle, linkHref}) { |     async addLink(linkTitle, linkHref) { | ||||||
|         if (!this.isActive()) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         await this.initialized; |         await this.initialized; | ||||||
| 
 | 
 | ||||||
|         if (this.hasSelection()) { |         if (this.hasSelection()) { | ||||||
| @ -255,4 +250,8 @@ export default class TextTypeWidget extends TypeWidget { | |||||||
| 
 | 
 | ||||||
|         callback(this.textEditor); |         callback(this.textEditor); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     addLinkToTextCommand() { | ||||||
|  |         import("../../dialogs/add_link.js").then(d => d.showDialog(this)); | ||||||
|  |     } | ||||||
| } | } | ||||||
| @ -14,25 +14,30 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "BackInNoteHistory", |         actionName: "BackInNoteHistory", | ||||||
|         // Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
 |         // Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
 | ||||||
|         defaultShortcuts: isMac ? ["Meta+Left"] : ["Alt+Left"] |         defaultShortcuts: isMac ? ["Meta+Left"] : ["Alt+Left"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ForwardInNoteHistory", |         actionName: "ForwardInNoteHistory", | ||||||
|         // Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
 |         // Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
 | ||||||
|         defaultShortcuts: isMac ? ["Meta+Right"] : ["Alt+Right"] |         defaultShortcuts: isMac ? ["Meta+Right"] : ["Alt+Right"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "JumpToNote", |         actionName: "JumpToNote", | ||||||
|         defaultShortcuts: ["CommandOrControl+J"], |         defaultShortcuts: ["CommandOrControl+J"], | ||||||
|         description: 'Open "Jump to note" dialog' |         description: 'Open "Jump to note" dialog', | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ScrollToActiveNote", |         actionName: "ScrollToActiveNote", | ||||||
|         defaultShortcuts: ["CommandOrControl+."] |         defaultShortcuts: ["CommandOrControl+."], | ||||||
|  |         scope: "window" // FIXME - how do we find what note tree should be updated?
 | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "SearchNotes", |         actionName: "SearchNotes", | ||||||
|         defaultShortcuts: ["CommandOrControl+S"] |         defaultShortcuts: ["CommandOrControl+S"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "SearchInSubtree", |         actionName: "SearchInSubtree", | ||||||
| @ -43,6 +48,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "CollapseTree", |         actionName: "CollapseTree", | ||||||
|         defaultShortcuts: ["Alt+C"], |         defaultShortcuts: ["Alt+C"], | ||||||
|  |         scope: "note-tree" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CollapseSubtree", |         actionName: "CollapseSubtree", | ||||||
| @ -69,16 +75,19 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CreateNoteAfter", |         actionName: "CreateNoteAfter", | ||||||
|         defaultShortcuts: ["CommandOrControl+O"] |         defaultShortcuts: ["CommandOrControl+O"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CreateNoteInto", |         actionName: "CreateNoteInto", | ||||||
|         defaultShortcuts: ["CommandOrControl+P"] |         defaultShortcuts: ["CommandOrControl+P"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CreateNoteIntoDayNote", |         actionName: "CreateNoteIntoDayNote", | ||||||
|         defaultShortcuts: ["global:CommandOrControl+Alt+P"], |         defaultShortcuts: ["global:CommandOrControl+Alt+P"], | ||||||
|         description: "Create and open subnote of a current day note" |         description: "Create and open subnote of a current day note", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "DeleteNotes", |         actionName: "DeleteNotes", | ||||||
| @ -119,15 +128,18 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "EditBranchPrefix", |         actionName: "EditBranchPrefix", | ||||||
|         defaultShortcuts: ["F2"], |         defaultShortcuts: ["F2"], | ||||||
|         description: "Show Edit branch prefix dialog" |         description: "Show Edit branch prefix dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CloneNotesTo", |         actionName: "CloneNotesTo", | ||||||
|         defaultShortcuts: ["CommandOrControl+Shift+C"] |         defaultShortcuts: ["CommandOrControl+Shift+C"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "MoveNotesTo", |         actionName: "MoveNotesTo", | ||||||
|         defaultShortcuts: ["CommandOrControl+Shift+X"] |         defaultShortcuts: ["CommandOrControl+Shift+X"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     { |     { | ||||||
| @ -179,22 +191,26 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "OpenNewTab", |         actionName: "OpenNewTab", | ||||||
|         defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [], |         defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [], | ||||||
|         description: "Opens new tab" |         description: "Opens new tab", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CloseActiveTab", |         actionName: "CloseActiveTab", | ||||||
|         defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [], |         defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [], | ||||||
|         description: "Closes active tab" |         description: "Closes active tab", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ActivateNextTab", |         actionName: "ActivateNextTab", | ||||||
|         defaultShortcuts: isElectron ? ["CommandOrControl+Tab"] : [], |         defaultShortcuts: isElectron ? ["CommandOrControl+Tab"] : [], | ||||||
|         description: "Activates tab on the right" |         description: "Activates tab on the right", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ActivatePreviousTab", |         actionName: "ActivatePreviousTab", | ||||||
|         defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab"] : [], |         defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab"] : [], | ||||||
|         description: "Activates tab on the left" |         description: "Activates tab on the left", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -204,52 +220,62 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "ShowAttributes", |         actionName: "ShowAttributes", | ||||||
|         defaultShortcuts: ["Alt+A"], |         defaultShortcuts: ["Alt+A"], | ||||||
|         description: "Shows Attributes dialog" |         description: "Shows Attributes dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowNoteInfo", |         actionName: "ShowNoteInfo", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Note Info dialog" |         description: "Shows Note Info dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowNoteSource", |         actionName: "ShowNoteSource", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Note Source dialog" |         description: "Shows Note Source dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowLinkMap", |         actionName: "ShowLinkMap", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Link Map dialog" |         description: "Shows Link Map dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowOptions", |         actionName: "ShowOptions", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Options dialog" |         description: "Shows Options dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowNoteRevisions", |         actionName: "ShowNoteRevisions", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Note Revisions dialog" |         description: "Shows Note Revisions dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowRecentChanges", |         actionName: "ShowRecentChanges", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Recent Changes dialog" |         description: "Shows Recent Changes dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowSQLConsole", |         actionName: "ShowSQLConsole", | ||||||
|         defaultShortcuts: ["Alt+O"], |         defaultShortcuts: ["Alt+O"], | ||||||
|         description: "Shows SQL Console dialog" |         description: "Shows SQL Console dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowBackendLog", |         actionName: "ShowBackendLog", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Shows Backend Log dialog" |         description: "Shows Backend Log dialog", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ShowHelp", |         actionName: "ShowHelp", | ||||||
|         defaultShortcuts: ["F1"], |         defaultShortcuts: ["F1"], | ||||||
|         description: "Shows built-in Help / cheatsheet" |         description: "Shows built-in Help / cheatsheet", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -260,21 +286,25 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
|     { |     { | ||||||
|         actionName: "AddLinkToText", |         actionName: "AddLinkToText", | ||||||
|         defaultShortcuts: ["CommandOrControl+L"], |         defaultShortcuts: ["CommandOrControl+L"], | ||||||
|         description: "Open dialog to add link to the text" |         description: "Open dialog to add link to the text", | ||||||
|  |         scope: "text-detail" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "InsertDateTimeToText", |         actionName: "InsertDateTimeToText", | ||||||
|         defaultShortcuts: ["Alt+T"] |         defaultShortcuts: ["Alt+T"], | ||||||
|  |         scope: "text-detail" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "PasteMarkdownIntoText", |         actionName: "PasteMarkdownIntoText", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Pastes Markdown from clipboard into text note" |         description: "Pastes Markdown from clipboard into text note", | ||||||
|  |         scope: "text-detail" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CutIntoNote", |         actionName: "CutIntoNote", | ||||||
|         defaultShortcuts: [], |         defaultShortcuts: [], | ||||||
|         description: "Cuts the selection from the current note and creates subnote with the selected text" |         description: "Cuts the selection from the current note and creates subnote with the selected text", | ||||||
|  |         scope: "text-detail" | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     { |     { | ||||||
| @ -283,49 +313,60 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | |||||||
| 
 | 
 | ||||||
|     { |     { | ||||||
|         actionName: "PrintActiveNote", |         actionName: "PrintActiveNote", | ||||||
|         defaultShortcuts: [] |         defaultShortcuts: [], | ||||||
|  |         scope: "note-detail" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "RunActiveNote", |         actionName: "RunActiveNote", | ||||||
|         defaultShortcuts: ["CommandOrControl+Enter"], |         defaultShortcuts: ["CommandOrControl+Enter"], | ||||||
|         description: "Run active JavaScript (frontend/backend) code note" |         description: "Run active JavaScript (frontend/backend) code note", | ||||||
|  |         scope: "code-detail" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ToggleNoteHoisting", |         actionName: "ToggleNoteHoisting", | ||||||
|         defaultShortcuts: ["Alt+H"], |         defaultShortcuts: ["Alt+H"], | ||||||
|         description: "Toggles note hoisting of active note" |         description: "Toggles note hoisting of active note", | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ReloadFrontendApp", |         actionName: "ReloadFrontendApp", | ||||||
|         defaultShortcuts: ["F5", "CommandOrControl+R"] |         defaultShortcuts: ["F5", "CommandOrControl+R"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "OpenDevTools", |         actionName: "OpenDevTools", | ||||||
|         defaultShortcuts: ["CommandOrControl+Shift+I"] |         defaultShortcuts: ["CommandOrControl+Shift+I"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "FindInText", |         actionName: "FindInText", | ||||||
|         defaultShortcuts: ["CommandOrControl+F"] |         defaultShortcuts: ["CommandOrControl+F"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ToggleFullscreen", |         actionName: "ToggleFullscreen", | ||||||
|         defaultShortcuts: ["F11"] |         defaultShortcuts: ["F11"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ToggleZenMode", |         actionName: "ToggleZenMode", | ||||||
|         defaultShortcuts: ["Alt+M"] |         defaultShortcuts: ["Alt+M"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ZoomOut", |         actionName: "ZoomOut", | ||||||
|         defaultShortcuts: ["CommandOrControl+-"] |         defaultShortcuts: ["CommandOrControl+-"], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "ZoomIn", |         actionName: "ZoomIn", | ||||||
|         defaultShortcuts: ["CommandOrControl+="] |         defaultShortcuts: ["CommandOrControl+="], | ||||||
|  |         scope: "window" | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         actionName: "CopyWithoutFormatting", |         actionName: "CopyWithoutFormatting", | ||||||
|         defaultShortcuts: ["CommandOrControl+Alt+C"] |         defaultShortcuts: ["CommandOrControl+Alt+C"], | ||||||
|  |         scope: "text-detail" | ||||||
|     } |     } | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| @ -341,9 +382,7 @@ async function getKeyboardActions() { | |||||||
|     const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); |     const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); | ||||||
| 
 | 
 | ||||||
|     for (const action of actions) { |     for (const action of actions) { | ||||||
|         if (action.defaultShortcuts) { |         action.effectiveShortcuts = action.effectiveShortcuts ? action.defaultShortcuts.slice() : []; | ||||||
|             action.effectiveShortcuts = action.defaultShortcuts.slice(); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for (const option of await optionService.getOptions()) { |     for (const option of await optionService.getOptions()) { | ||||||
|  | |||||||
| @ -18,12 +18,12 @@ | |||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd>UP</kbd>, <kbd>DOWN</kbd> - go up/down in the list of notes</li> |                                     <li><kbd>UP</kbd>, <kbd>DOWN</kbd> - go up/down in the list of notes</li> | ||||||
|                                     <li><kbd>LEFT</kbd>, <kbd>RIGHT</kbd> - collapse/expand node</li> |                                     <li><kbd>LEFT</kbd>, <kbd>RIGHT</kbd> - collapse/expand node</li> | ||||||
|                                     <li><kbd data-kb-action="BackInNoteHistory"></kbd>, <kbd data-kb-action="BackInNoteHistory"></kbd> - go back / forwards in the history</li> |                                     <li><kbd data-kb-action="backInNoteHistory"></kbd>, <kbd data-kb-action="BackInNoteHistory"></kbd> - go back / forwards in the history</li> | ||||||
|                                     <li><kbd data-kb-action="JumpToNote"></kbd> - show <a class="external" href="https://github.com/zadam/trilium/wiki/Note-navigation#jump-to-note">"Jump to" dialog</a></li> |                                     <li><kbd data-kb-action="jumpToNote"></kbd> - show <a class="external" href="https://github.com/zadam/trilium/wiki/Note-navigation#jump-to-note">"Jump to" dialog</a></li> | ||||||
|                                     <li><kbd data-kb-action="ScrollToActiveNote"></kbd> - scroll to active note</li> |                                     <li><kbd data-kb-action="scrollToActiveNote"></kbd> - scroll to active note</li> | ||||||
|                                     <li><kbd data-kb-action="ActivateParentNote"></kbd> - jumps to parent note</li> |                                     <li><kbd data-kb-action="activateParentNote"></kbd> - jumps to parent note</li> | ||||||
|                                     <li><kbd data-kb-action="CollapseTree"></kbd> - collapse whole note tree</li> |                                     <li><kbd data-kb-action="collapseTree"></kbd> - collapse whole note tree</li> | ||||||
|                                     <li><kbd data-kb-action="CollapseSubtree"></kbd> - collapse sub-tree</li> |                                     <li><kbd data-kb-action="collapseSubtree"></kbd> - collapse sub-tree</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -40,10 +40,10 @@ | |||||||
| 
 | 
 | ||||||
|                             Only in desktop (electron build): |                             Only in desktop (electron build): | ||||||
|                             <ul> |                             <ul> | ||||||
|                                 <li><kbd data-kb-action="OpenNewTab"></kbd> opens empty tab</li> |                                 <li><kbd data-kb-action="openNewTab"></kbd> opens empty tab</li> | ||||||
|                                 <li><kbd data-kb-action="CloseActiveTab"></kbd> closes active tab</li> |                                 <li><kbd data-kb-action="closeActiveTab"></kbd> closes active tab</li> | ||||||
|                                 <li><kbd data-kb-action="ActivateNextTab"></kbd> activates next tab</li> |                                 <li><kbd data-kb-action="activateNextTab"></kbd> activates next tab</li> | ||||||
|                                 <li><kbd data-kb-action="ActivatePreviousTab"></kbd> activates previous tab</li> |                                 <li><kbd data-kb-action="activatePreviousTab"></kbd> activates previous tab</li> | ||||||
|                             </ul> |                             </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -55,9 +55,9 @@ | |||||||
| 
 | 
 | ||||||
|                             <p class="card-text"> |                             <p class="card-text"> | ||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd data-kb-action="CreateNoteAfter"></kbd> - creates new note after the active note</li> |                                     <li><kbd data-kb-action="createNoteAfter"></kbd> - creates new note after the active note</li> | ||||||
|                                     <li><kbd data-kb-action="CreateNoteInto"></kbd> - creates new sub-note into active note</li> |                                     <li><kbd data-kb-action="createNoteInto"></kbd> - creates new sub-note into active note</li> | ||||||
|                                     <li><kbd data-kb-action="EditBranchPrefix"></kbd> - edit <a class="external" href="https://github.com/zadam/trilium/wiki/Tree concepts#prefix">prefix</a> of active note clone</li> |                                     <li><kbd data-kb-action="editBranchPrefix"></kbd> - edit <a class="external" href="https://github.com/zadam/trilium/wiki/Tree concepts#prefix">prefix</a> of active note clone</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -69,15 +69,15 @@ | |||||||
| 
 | 
 | ||||||
|                             <p class="card-text"> |                             <p class="card-text"> | ||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd data-kb-action="MoveNoteUp"></kbd>, <kbd data-kb-action="MoveNoteDown"></kbd> - move note up/down in the note list</li> |                                     <li><kbd data-kb-action="moveNoteUp"></kbd>, <kbd data-kb-action="MoveNoteDown"></kbd> - move note up/down in the note list</li> | ||||||
|                                     <li><kbd data-kb-action="MoveNoteUpInHierarchy"></kbd>, <kbd data-kb-action="MoveNoteDownInHierarchy"></kbd> - move note up in the hierarchy</li> |                                     <li><kbd data-kb-action="moveNoteUpInHierarchy"></kbd>, <kbd data-kb-action="MoveNoteDownInHierarchy"></kbd> - move note up in the hierarchy</li> | ||||||
|                                     <li><kbd data-kb-action="AddNoteAboveToSelection"></kbd>, <kbd data-kb-action="AddNoteBelowToSelection"></kbd> - multi-select note above/below</li> |                                     <li><kbd data-kb-action="addNoteAboveToSelection"></kbd>, <kbd data-kb-action="AddNoteBelowToSelection"></kbd> - multi-select note above/below</li> | ||||||
|                                     <li><kbd data-kb-action="SelectAllNotesInParent"></kbd> - select all notes in the current level</li> |                                     <li><kbd data-kb-action="selectAllNotesInParent"></kbd> - select all notes in the current level</li> | ||||||
|                                     <li><kbd>Shift+click</kbd> - select note</li> |                                     <li><kbd>Shift+click</kbd> - select note</li> | ||||||
|                                     <li><kbd data-kb-action="CopyNotesToClipboard"></kbd> - copies active note (or current selection) into clipboard (used for <a class="external" href="https://github.com/zadam/trilium/wiki/Cloning notes">cloning</a>)</li> |                                     <li><kbd data-kb-action="copyNotesToClipboard"></kbd> - copies active note (or current selection) into clipboard (used for <a class="external" href="https://github.com/zadam/trilium/wiki/Cloning notes">cloning</a>)</li> | ||||||
|                                     <li><kbd data-kb-action="CutNotesToClipboard"></kbd> - cuts current (or current selection) note into clipboard (used for moving notes)</li> |                                     <li><kbd data-kb-action="cutNotesToClipboard"></kbd> - cuts current (or current selection) note into clipboard (used for moving notes)</li> | ||||||
|                                     <li><kbd data-kb-action="PasteNotesFromClipboard"></kbd> - pastes note(s) as sub-note into active note (which is either move or clone depending on whether it was copied or cut into clipboard)</li> |                                     <li><kbd data-kb-action="pasteNotesFromClipboard"></kbd> - pastes note(s) as sub-note into active note (which is either move or clone depending on whether it was copied or cut into clipboard)</li> | ||||||
|                                     <li><kbd data-kb-action="DeleteNotes"></kbd> - delete note / sub-tree</li> |                                     <li><kbd data-kb-action="deleteNotes"></kbd> - delete note / sub-tree</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -89,12 +89,12 @@ | |||||||
| 
 | 
 | ||||||
|                             <p class="card-text"> |                             <p class="card-text"> | ||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd data-kb-action="EditNoteTitle"></kbd> in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor. |                                     <li><kbd data-kb-action="editNoteTitle"></kbd> in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor. | ||||||
|                                         <kbd data-kb-action="ScrollToActiveNote"></kbd> switches back from editor to tree pane.</li> |                                         <kbd data-kb-action="scrollToActiveNote"></kbd> switches back from editor to tree pane.</li> | ||||||
|                                     <li><kbd>Ctrl+K</kbd> - create / edit external link</li> |                                     <li><kbd>Ctrl+K</kbd> - create / edit external link</li> | ||||||
|                                     <li><kbd data-kb-action="AddLinkToText"></kbd> - create internal link</li> |                                     <li><kbd data-kb-action="addLinkToText"></kbd> - create internal link</li> | ||||||
|                                     <li><kbd data-kb-action="InsertDateTimeToText"></kbd> - inserts current date and time at caret position</li> |                                     <li><kbd data-kb-action="insertDateTimeToText"></kbd> - inserts current date and time at caret position</li> | ||||||
|                                     <li><kbd data-kb-action="ScrollToActiveNote"></kbd> - jump away to the tree pane and scroll to active note</li> |                                     <li><kbd data-kb-action="scrollToActiveNote"></kbd> - jump away to the tree pane and scroll to active note</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -121,9 +121,9 @@ | |||||||
| 
 | 
 | ||||||
|                             <p class="card-text"> |                             <p class="card-text"> | ||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd data-kb-action="ReloadFrontendApp"></kbd> - reloads Trilium frontend</li> |                                     <li><kbd data-kb-action="reloadFrontendApp"></kbd> - reloads Trilium frontend</li> | ||||||
|                                     <li><kbd data-kb-action="OpenDevTools"></kbd> - show developer tools</li> |                                     <li><kbd data-kb-action="openDevTools"></kbd> - show developer tools</li> | ||||||
|                                     <li><kbd data-kb-action="ShowSQLConsole"></kbd> - show SQL console</li> |                                     <li><kbd data-kb-action="showSQLConsole"></kbd> - show SQL console</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
| @ -135,10 +135,10 @@ | |||||||
| 
 | 
 | ||||||
|                             <p class="card-text"> |                             <p class="card-text"> | ||||||
|                                 <ul> |                                 <ul> | ||||||
|                                     <li><kbd data-kb-action="ToggleZenMode"></kbd> - Zen mode - display only note editor, everything else is hidden</li> |                                     <li><kbd data-kb-action="toggleZenMode"></kbd> - Zen mode - display only note editor, everything else is hidden</li> | ||||||
|                                     <li><kbd data-kb-action="SearchNotes"></kbd> - toggle search form in tree pane</li> |                                     <li><kbd data-kb-action="searchNotes"></kbd> - toggle search form in tree pane</li> | ||||||
|                                     <li><kbd data-kb-action="FindInText"></kbd> - in page search</li> |                                     <li><kbd data-kb-action="findInText"></kbd> - in page search</li> | ||||||
|                                     <li><kbd data-kb-action="ShowAttributes"></kbd> - show note attributes dialog</li> |                                     <li><kbd data-kb-action="showAttributes"></kbd> - show note attributes dialog</li> | ||||||
|                                 </ul> |                                 </ul> | ||||||
|                             </p> |                             </p> | ||||||
|                         </div> |                         </div> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam