feat(keyboard_actions): add friendly names to all actions

This commit is contained in:
Elian Doran 2025-07-27 16:50:02 +03:00
parent 793867269b
commit 0b24553ace
No known key found for this signature in database
5 changed files with 125 additions and 35 deletions

View File

@ -172,7 +172,7 @@ class CommandRegistry {
// Create a command definition from the keyboard action // Create a command definition from the keyboard action
const commandDef: CommandDefinition = { const commandDef: CommandDefinition = {
id: action.actionName, id: action.actionName,
name: this.formatActionName(action.actionName), name: action.friendlyName,
description: action.description, description: action.description,
icon: this.getIconForAction(action.actionName), icon: this.getIconForAction(action.actionName),
shortcut: primaryShortcut ? this.formatShortcut(primaryShortcut) : undefined, shortcut: primaryShortcut ? this.formatShortcut(primaryShortcut) : undefined,
@ -184,14 +184,6 @@ class CommandRegistry {
} }
} }
private formatActionName(actionName: string): string {
// Convert camelCase to Title Case
return actionName
.replace(/([A-Z])/g, ' $1')
.replace(/^./, str => str.toUpperCase())
.trim();
}
private formatShortcut(shortcut: string): string { private formatShortcut(shortcut: string): string {
// Convert electron accelerator format to display format // Convert electron accelerator format to display format
return shortcut return shortcut

View File

@ -3,7 +3,7 @@
import optionService from "./options.js"; import optionService from "./options.js";
import log from "./log.js"; import log from "./log.js";
import { isElectron, isMac } from "./utils.js"; import { isElectron, isMac } from "./utils.js";
import type { KeyboardShortcut } from "@triliumnext/commons"; import type { ActionKeyboardShortcut, KeyboardShortcut } from "@triliumnext/commons";
import { t } from "i18next"; import { t } from "i18next";
function getDefaultKeyboardActions() { function getDefaultKeyboardActions() {
@ -17,6 +17,7 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "backInNoteHistory", actionName: "backInNoteHistory",
friendlyName: "Back in Note History",
// 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 ? ["CommandOrControl+Left"] : ["Alt+Left"], defaultShortcuts: isMac ? ["CommandOrControl+Left"] : ["Alt+Left"],
description: t("keyboard_actions.back-in-note-history"), description: t("keyboard_actions.back-in-note-history"),
@ -24,6 +25,7 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "forwardInNoteHistory", actionName: "forwardInNoteHistory",
friendlyName: "Forward in Note History",
// 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 ? ["CommandOrControl+Right"] : ["Alt+Right"], defaultShortcuts: isMac ? ["CommandOrControl+Right"] : ["Alt+Right"],
description: t("keyboard_actions.forward-in-note-history"), description: t("keyboard_actions.forward-in-note-history"),
@ -31,54 +33,63 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "jumpToNote", actionName: "jumpToNote",
friendlyName: "Jump to Note",
defaultShortcuts: ["CommandOrControl+J"], defaultShortcuts: ["CommandOrControl+J"],
description: t("keyboard_actions.open-jump-to-note-dialog"), description: t("keyboard_actions.open-jump-to-note-dialog"),
scope: "window" scope: "window"
}, },
{ {
actionName: "commandPalette", actionName: "commandPalette",
friendlyName: "Command Palette",
defaultShortcuts: ["CommandOrControl+Shift+J"], defaultShortcuts: ["CommandOrControl+Shift+J"],
description: t("keyboard_actions.open-command-palette"), description: t("keyboard_actions.open-command-palette"),
scope: "window" scope: "window"
}, },
{ {
actionName: "scrollToActiveNote", actionName: "scrollToActiveNote",
friendlyName: "Scroll to Active Note",
defaultShortcuts: ["CommandOrControl+."], defaultShortcuts: ["CommandOrControl+."],
description: t("keyboard_actions.scroll-to-active-note"), description: t("keyboard_actions.scroll-to-active-note"),
scope: "window" scope: "window"
}, },
{ {
actionName: "quickSearch", actionName: "quickSearch",
friendlyName: "Quick Search",
defaultShortcuts: ["CommandOrControl+S"], defaultShortcuts: ["CommandOrControl+S"],
description: t("keyboard_actions.quick-search"), description: t("keyboard_actions.quick-search"),
scope: "window" scope: "window"
}, },
{ {
actionName: "searchInSubtree", actionName: "searchInSubtree",
friendlyName: "Search in Subtree",
defaultShortcuts: ["CommandOrControl+Shift+S"], defaultShortcuts: ["CommandOrControl+Shift+S"],
description: t("keyboard_actions.search-in-subtree"), description: t("keyboard_actions.search-in-subtree"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "expandSubtree", actionName: "expandSubtree",
friendlyName: "Expand Subtree",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.expand-subtree"), description: t("keyboard_actions.expand-subtree"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "collapseTree", actionName: "collapseTree",
friendlyName: "Collapse Tree",
defaultShortcuts: ["Alt+C"], defaultShortcuts: ["Alt+C"],
description: t("keyboard_actions.collapse-tree"), description: t("keyboard_actions.collapse-tree"),
scope: "window" scope: "window"
}, },
{ {
actionName: "collapseSubtree", actionName: "collapseSubtree",
friendlyName: "Collapse Subtree",
defaultShortcuts: ["Alt+-"], defaultShortcuts: ["Alt+-"],
description: t("keyboard_actions.collapse-subtree"), description: t("keyboard_actions.collapse-subtree"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "sortChildNotes", actionName: "sortChildNotes",
friendlyName: "Sort Child Notes",
defaultShortcuts: ["Alt+S"], defaultShortcuts: ["Alt+S"],
description: t("keyboard_actions.sort-child-notes"), description: t("keyboard_actions.sort-child-notes"),
scope: "note-tree" scope: "note-tree"
@ -89,72 +100,84 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "createNoteAfter", actionName: "createNoteAfter",
friendlyName: "Create Note After",
defaultShortcuts: ["CommandOrControl+O"], defaultShortcuts: ["CommandOrControl+O"],
description: t("keyboard_actions.create-note-after"), description: t("keyboard_actions.create-note-after"),
scope: "window" scope: "window"
}, },
{ {
actionName: "createNoteInto", actionName: "createNoteInto",
friendlyName: "Create Note Into",
defaultShortcuts: ["CommandOrControl+P"], defaultShortcuts: ["CommandOrControl+P"],
description: t("keyboard_actions.create-note-into"), description: t("keyboard_actions.create-note-into"),
scope: "window" scope: "window"
}, },
{ {
actionName: "createNoteIntoInbox", actionName: "createNoteIntoInbox",
friendlyName: "Create Note Into Inbox",
defaultShortcuts: ["global:CommandOrControl+Alt+P"], defaultShortcuts: ["global:CommandOrControl+Alt+P"],
description: t("keyboard_actions.create-note-into-inbox"), description: t("keyboard_actions.create-note-into-inbox"),
scope: "window" scope: "window"
}, },
{ {
actionName: "deleteNotes", actionName: "deleteNotes",
friendlyName: "Delete Notes",
defaultShortcuts: ["Delete"], defaultShortcuts: ["Delete"],
description: t("keyboard_actions.delete-note"), description: t("keyboard_actions.delete-note"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "moveNoteUp", actionName: "moveNoteUp",
friendlyName: "Move Note Up",
defaultShortcuts: isMac ? ["Alt+Up"] : ["CommandOrControl+Up"], defaultShortcuts: isMac ? ["Alt+Up"] : ["CommandOrControl+Up"],
description: t("keyboard_actions.move-note-up"), description: t("keyboard_actions.move-note-up"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "moveNoteDown", actionName: "moveNoteDown",
friendlyName: "Move Note Down",
defaultShortcuts: isMac ? ["Alt+Down"] : ["CommandOrControl+Down"], defaultShortcuts: isMac ? ["Alt+Down"] : ["CommandOrControl+Down"],
description: t("keyboard_actions.move-note-down"), description: t("keyboard_actions.move-note-down"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "moveNoteUpInHierarchy", actionName: "moveNoteUpInHierarchy",
friendlyName: "Move Note Up in Hierarchy",
defaultShortcuts: isMac ? ["Alt+Left"] : ["CommandOrControl+Left"], defaultShortcuts: isMac ? ["Alt+Left"] : ["CommandOrControl+Left"],
description: t("keyboard_actions.move-note-up-in-hierarchy"), description: t("keyboard_actions.move-note-up-in-hierarchy"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "moveNoteDownInHierarchy", actionName: "moveNoteDownInHierarchy",
friendlyName: "Move Note Down in Hierarchy",
defaultShortcuts: isMac ? ["Alt+Right"] : ["CommandOrControl+Right"], defaultShortcuts: isMac ? ["Alt+Right"] : ["CommandOrControl+Right"],
description: t("keyboard_actions.move-note-down-in-hierarchy"), description: t("keyboard_actions.move-note-down-in-hierarchy"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "editNoteTitle", actionName: "editNoteTitle",
friendlyName: "Edit Note Title",
defaultShortcuts: ["Enter"], defaultShortcuts: ["Enter"],
description: t("keyboard_actions.edit-note-title"), description: t("keyboard_actions.edit-note-title"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "editBranchPrefix", actionName: "editBranchPrefix",
friendlyName: "Edit Branch Prefix",
defaultShortcuts: ["F2"], defaultShortcuts: ["F2"],
description: t("keyboard_actions.edit-branch-prefix"), description: t("keyboard_actions.edit-branch-prefix"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "cloneNotesTo", actionName: "cloneNotesTo",
friendlyName: "Clone Notes To",
defaultShortcuts: ["CommandOrControl+Shift+C"], defaultShortcuts: ["CommandOrControl+Shift+C"],
description: t("keyboard_actions.clone-notes-to"), description: t("keyboard_actions.clone-notes-to"),
scope: "window" scope: "window"
}, },
{ {
actionName: "moveNotesTo", actionName: "moveNotesTo",
friendlyName: "Move Notes To",
defaultShortcuts: ["CommandOrControl+Shift+X"], defaultShortcuts: ["CommandOrControl+Shift+X"],
description: t("keyboard_actions.move-notes-to"), description: t("keyboard_actions.move-notes-to"),
scope: "window" scope: "window"
@ -166,42 +189,49 @@ function getDefaultKeyboardActions() {
{ {
actionName: "copyNotesToClipboard", actionName: "copyNotesToClipboard",
friendlyName: "Copy Notes to Clipboard",
defaultShortcuts: ["CommandOrControl+C"], defaultShortcuts: ["CommandOrControl+C"],
description: t("keyboard_actions.copy-notes-to-clipboard"), description: t("keyboard_actions.copy-notes-to-clipboard"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "pasteNotesFromClipboard", actionName: "pasteNotesFromClipboard",
friendlyName: "Paste Notes from Clipboard",
defaultShortcuts: ["CommandOrControl+V"], defaultShortcuts: ["CommandOrControl+V"],
description: t("keyboard_actions.paste-notes-from-clipboard"), description: t("keyboard_actions.paste-notes-from-clipboard"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "cutNotesToClipboard", actionName: "cutNotesToClipboard",
friendlyName: "Cut Notes to Clipboard",
defaultShortcuts: ["CommandOrControl+X"], defaultShortcuts: ["CommandOrControl+X"],
description: t("keyboard_actions.cut-notes-to-clipboard"), description: t("keyboard_actions.cut-notes-to-clipboard"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "selectAllNotesInParent", actionName: "selectAllNotesInParent",
friendlyName: "Select All Notes in Parent",
defaultShortcuts: ["CommandOrControl+A"], defaultShortcuts: ["CommandOrControl+A"],
description: t("keyboard_actions.select-all-notes-in-parent"), description: t("keyboard_actions.select-all-notes-in-parent"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "addNoteAboveToSelection", actionName: "addNoteAboveToSelection",
friendlyName: "Add Note Above to Selection",
defaultShortcuts: ["Shift+Up"], defaultShortcuts: ["Shift+Up"],
description: t("keyboard_actions.add-note-above-to-the-selection"), description: t("keyboard_actions.add-note-above-to-the-selection"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "addNoteBelowToSelection", actionName: "addNoteBelowToSelection",
friendlyName: "Add Note Below to Selection",
defaultShortcuts: ["Shift+Down"], defaultShortcuts: ["Shift+Down"],
description: t("keyboard_actions.add-note-below-to-selection"), description: t("keyboard_actions.add-note-below-to-selection"),
scope: "note-tree" scope: "note-tree"
}, },
{ {
actionName: "duplicateSubtree", actionName: "duplicateSubtree",
friendlyName: "Duplicate Subtree",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.duplicate-subtree"), description: t("keyboard_actions.duplicate-subtree"),
scope: "note-tree" scope: "note-tree"
@ -212,109 +242,127 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "openNewTab", actionName: "openNewTab",
friendlyName: "Open New Tab",
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [],
description: t("keyboard_actions.open-new-tab"), description: t("keyboard_actions.open-new-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "closeActiveTab", actionName: "closeActiveTab",
friendlyName: "Close Active Tab",
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [],
description: t("keyboard_actions.close-active-tab"), description: t("keyboard_actions.close-active-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "reopenLastTab", actionName: "reopenLastTab",
friendlyName: "Reopen Last Tab",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [],
description: t("keyboard_actions.reopen-last-tab"), description: t("keyboard_actions.reopen-last-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "activateNextTab", actionName: "activateNextTab",
friendlyName: "Activate Next Tab",
defaultShortcuts: isElectron ? ["CommandOrControl+Tab", "CommandOrControl+PageDown"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+Tab", "CommandOrControl+PageDown"] : [],
description: t("keyboard_actions.activate-next-tab"), description: t("keyboard_actions.activate-next-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "activatePreviousTab", actionName: "activatePreviousTab",
friendlyName: "Activate Previous Tab",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab", "CommandOrControl+PageUp"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab", "CommandOrControl+PageUp"] : [],
description: t("keyboard_actions.activate-previous-tab"), description: t("keyboard_actions.activate-previous-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "openNewWindow", actionName: "openNewWindow",
friendlyName: "Open New Window",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.open-new-window"), description: t("keyboard_actions.open-new-window"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleTray", actionName: "toggleTray",
friendlyName: "Toggle System Tray Icon",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-tray"), description: t("keyboard_actions.toggle-tray"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleZenMode", actionName: "toggleZenMode",
friendlyName: "Toggle Zen Mode",
defaultShortcuts: ["F9"], defaultShortcuts: ["F9"],
description: t("keyboard_actions.toggle-zen-mode"), description: t("keyboard_actions.toggle-zen-mode"),
scope: "window" scope: "window"
}, },
{ {
actionName: "firstTab", actionName: "firstTab",
friendlyName: "Switch to First Tab",
defaultShortcuts: ["CommandOrControl+1"], defaultShortcuts: ["CommandOrControl+1"],
description: t("keyboard_actions.first-tab"), description: t("keyboard_actions.first-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "secondTab", actionName: "secondTab",
friendlyName: "Switch to Second Tab",
defaultShortcuts: ["CommandOrControl+2"], defaultShortcuts: ["CommandOrControl+2"],
description: t("keyboard_actions.second-tab"), description: t("keyboard_actions.second-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "thirdTab", actionName: "thirdTab",
friendlyName: "Switch to Third Tab",
defaultShortcuts: ["CommandOrControl+3"], defaultShortcuts: ["CommandOrControl+3"],
description: t("keyboard_actions.third-tab"), description: t("keyboard_actions.third-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "fourthTab", actionName: "fourthTab",
friendlyName: "Switch to Fourth Tab",
defaultShortcuts: ["CommandOrControl+4"], defaultShortcuts: ["CommandOrControl+4"],
description: t("keyboard_actions.fourth-tab"), description: t("keyboard_actions.fourth-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "fifthTab", actionName: "fifthTab",
friendlyName: "Switch to Fifth Tab",
defaultShortcuts: ["CommandOrControl+5"], defaultShortcuts: ["CommandOrControl+5"],
description: t("keyboard_actions.fifth-tab"), description: t("keyboard_actions.fifth-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "sixthTab", actionName: "sixthTab",
friendlyName: "Switch to Sixth Tab",
defaultShortcuts: ["CommandOrControl+6"], defaultShortcuts: ["CommandOrControl+6"],
description: t("keyboard_actions.sixth-tab"), description: t("keyboard_actions.sixth-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "seventhTab", actionName: "seventhTab",
friendlyName: "Switch to Seventh Tab",
defaultShortcuts: ["CommandOrControl+7"], defaultShortcuts: ["CommandOrControl+7"],
description: t("keyboard_actions.seventh-tab"), description: t("keyboard_actions.seventh-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "eigthTab", actionName: "eigthTab",
friendlyName: "Switch to Eighth Tab",
defaultShortcuts: ["CommandOrControl+8"], defaultShortcuts: ["CommandOrControl+8"],
description: t("keyboard_actions.eight-tab"), description: t("keyboard_actions.eight-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "ninthTab", actionName: "ninthTab",
friendlyName: "Switch to Ninth Tab",
defaultShortcuts: ["CommandOrControl+9"], defaultShortcuts: ["CommandOrControl+9"],
description: t("keyboard_actions.ninth-tab"), description: t("keyboard_actions.ninth-tab"),
scope: "window" scope: "window"
}, },
{ {
actionName: "lastTab", actionName: "lastTab",
defaultShortcuts: [], friendlyName: "Switch to Last Tab",
defaultShortcuts: ["CommandOrControl+0"],
description: t("keyboard_actions.last-tab"), description: t("keyboard_actions.last-tab"),
scope: "window" scope: "window"
}, },
@ -323,48 +371,56 @@ function getDefaultKeyboardActions() {
separator: t("keyboard_actions.dialogs") separator: t("keyboard_actions.dialogs")
}, },
{ {
friendlyName: "Show Note Source",
actionName: "showNoteSource", actionName: "showNoteSource",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.show-note-source"), description: t("keyboard_actions.show-note-source"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Options",
actionName: "showOptions", actionName: "showOptions",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.show-options"), description: t("keyboard_actions.show-options"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Revisions",
actionName: "showRevisions", actionName: "showRevisions",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.show-revisions"), description: t("keyboard_actions.show-revisions"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Recent Changes",
actionName: "showRecentChanges", actionName: "showRecentChanges",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.show-recent-changes"), description: t("keyboard_actions.show-recent-changes"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show SQL Console",
actionName: "showSQLConsole", actionName: "showSQLConsole",
defaultShortcuts: ["Alt+O"], defaultShortcuts: ["Alt+O"],
description: t("keyboard_actions.show-sql-console"), description: t("keyboard_actions.show-sql-console"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Backend Log",
actionName: "showBackendLog", actionName: "showBackendLog",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.show-backend-log"), description: t("keyboard_actions.show-backend-log"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Help",
actionName: "showHelp", actionName: "showHelp",
defaultShortcuts: ["F1"], defaultShortcuts: ["F1"],
description: t("keyboard_actions.show-help"), description: t("keyboard_actions.show-help"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Show Cheatsheet",
actionName: "showCheatsheet", actionName: "showCheatsheet",
defaultShortcuts: ["Shift+F1"], defaultShortcuts: ["Shift+F1"],
description: t("keyboard_actions.show-cheatsheet"), description: t("keyboard_actions.show-cheatsheet"),
@ -376,42 +432,49 @@ function getDefaultKeyboardActions() {
}, },
{ {
friendlyName: "Add Link to Text",
actionName: "addLinkToText", actionName: "addLinkToText",
defaultShortcuts: ["CommandOrControl+L"], defaultShortcuts: ["CommandOrControl+L"],
description: t("keyboard_actions.add-link-to-text"), description: t("keyboard_actions.add-link-to-text"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Follow Link Under Cursor",
actionName: "followLinkUnderCursor", actionName: "followLinkUnderCursor",
defaultShortcuts: ["CommandOrControl+Enter"], defaultShortcuts: ["CommandOrControl+Enter"],
description: t("keyboard_actions.follow-link-under-cursor"), description: t("keyboard_actions.follow-link-under-cursor"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Insert Date and Time to Text",
actionName: "insertDateTimeToText", actionName: "insertDateTimeToText",
defaultShortcuts: ["Alt+T"], defaultShortcuts: ["Alt+T"],
description: t("keyboard_actions.insert-date-and-time-to-text"), description: t("keyboard_actions.insert-date-and-time-to-text"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Paste Markdown into Text",
actionName: "pasteMarkdownIntoText", actionName: "pasteMarkdownIntoText",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.paste-markdown-into-text"), description: t("keyboard_actions.paste-markdown-into-text"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Cut into Note",
actionName: "cutIntoNote", actionName: "cutIntoNote",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.cut-into-note"), description: t("keyboard_actions.cut-into-note"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Add Include Note to Text",
actionName: "addIncludeNoteToText", actionName: "addIncludeNoteToText",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.add-include-note-to-text"), description: t("keyboard_actions.add-include-note-to-text"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
friendlyName: "Edit Read-Only Note",
actionName: "editReadOnlyNote", actionName: "editReadOnlyNote",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.edit-readonly-note"), description: t("keyboard_actions.edit-readonly-note"),
@ -423,12 +486,14 @@ function getDefaultKeyboardActions() {
}, },
{ {
friendlyName: "Add New Label",
actionName: "addNewLabel", actionName: "addNewLabel",
defaultShortcuts: ["Alt+L"], defaultShortcuts: ["Alt+L"],
description: t("keyboard_actions.add-new-label"), description: t("keyboard_actions.add-new-label"),
scope: "window" scope: "window"
}, },
{ {
friendlyName: "Add New Relation",
actionName: "addNewRelation", actionName: "addNewRelation",
defaultShortcuts: ["Alt+R"], defaultShortcuts: ["Alt+R"],
description: t("keyboard_actions.create-new-relation"), description: t("keyboard_actions.create-new-relation"),
@ -440,6 +505,7 @@ function getDefaultKeyboardActions() {
}, },
{ {
friendlyName: "Toggle Ribbon Tab Classic Editor",
actionName: "toggleRibbonTabClassicEditor", actionName: "toggleRibbonTabClassicEditor",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-classic-editor-toolbar"), description: t("keyboard_actions.toggle-classic-editor-toolbar"),
@ -447,36 +513,42 @@ function getDefaultKeyboardActions() {
}, },
{ {
actionName: "toggleRibbonTabBasicProperties", actionName: "toggleRibbonTabBasicProperties",
friendlyName: "Toggle Ribbon Tab Basic Properties",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-basic-properties"), description: t("keyboard_actions.toggle-basic-properties"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabBookProperties", actionName: "toggleRibbonTabBookProperties",
friendlyName: "Toggle Ribbon Tab Book Properties",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-book-properties"), description: t("keyboard_actions.toggle-book-properties"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabFileProperties", actionName: "toggleRibbonTabFileProperties",
friendlyName: "Toggle Ribbon Tab File Properties",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-file-properties"), description: t("keyboard_actions.toggle-file-properties"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabImageProperties", actionName: "toggleRibbonTabImageProperties",
friendlyName: "Toggle Ribbon Tab Image Properties",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-image-properties"), description: t("keyboard_actions.toggle-image-properties"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabOwnedAttributes", actionName: "toggleRibbonTabOwnedAttributes",
friendlyName: "Toggle Ribbon Tab Owned Attributes",
defaultShortcuts: ["Alt+A"], defaultShortcuts: ["Alt+A"],
description: t("keyboard_actions.toggle-owned-attributes"), description: t("keyboard_actions.toggle-owned-attributes"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabInheritedAttributes", actionName: "toggleRibbonTabInheritedAttributes",
friendlyName: "Toggle Ribbon Tab Inherited Attributes",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-inherited-attributes"), description: t("keyboard_actions.toggle-inherited-attributes"),
scope: "window" scope: "window"
@ -484,30 +556,35 @@ function getDefaultKeyboardActions() {
// TODO: Remove or change since promoted attributes have been changed. // TODO: Remove or change since promoted attributes have been changed.
{ {
actionName: "toggleRibbonTabPromotedAttributes", actionName: "toggleRibbonTabPromotedAttributes",
friendlyName: "Toggle Ribbon Tab Promoted Attributes",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-promoted-attributes"), description: t("keyboard_actions.toggle-promoted-attributes"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabNoteMap", actionName: "toggleRibbonTabNoteMap",
friendlyName: "Toggle Ribbon Tab Note Map",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-link-map"), description: t("keyboard_actions.toggle-link-map"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabNoteInfo", actionName: "toggleRibbonTabNoteInfo",
friendlyName: "Toggle Ribbon Tab Note Info",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-note-info"), description: t("keyboard_actions.toggle-note-info"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabNotePaths", actionName: "toggleRibbonTabNotePaths",
friendlyName: "Toggle Ribbon Tab Note Paths",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-note-paths"), description: t("keyboard_actions.toggle-note-paths"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleRibbonTabSimilarNotes", actionName: "toggleRibbonTabSimilarNotes",
friendlyName: "Toggle Ribbon Tab Similar Notes",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-similar-notes"), description: t("keyboard_actions.toggle-similar-notes"),
scope: "window" scope: "window"
@ -519,108 +596,126 @@ function getDefaultKeyboardActions() {
{ {
actionName: "toggleRightPane", actionName: "toggleRightPane",
friendlyName: "Toggle Right Pane",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-right-pane"), description: t("keyboard_actions.toggle-right-pane"),
scope: "window" scope: "window"
}, },
{ {
actionName: "printActiveNote", actionName: "printActiveNote",
friendlyName: "Print Active Note",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.print-active-note"), description: t("keyboard_actions.print-active-note"),
scope: "window" scope: "window"
}, },
{ {
actionName: "exportAsPdf", actionName: "exportAsPdf",
friendlyName: "Export Active Note as PDF",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.export-as-pdf"), description: t("keyboard_actions.export-as-pdf"),
scope: "window" scope: "window"
}, },
{ {
actionName: "openNoteExternally", actionName: "openNoteExternally",
friendlyName: "Open Note Externally",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.open-note-externally"), description: t("keyboard_actions.open-note-externally"),
scope: "window" scope: "window"
}, },
{ {
actionName: "renderActiveNote", actionName: "renderActiveNote",
friendlyName: "Render Active Note",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.render-active-note"), description: t("keyboard_actions.render-active-note"),
scope: "window" scope: "window"
}, },
{ {
actionName: "runActiveNote", actionName: "runActiveNote",
friendlyName: "Run Active Note",
defaultShortcuts: ["CommandOrControl+Enter"], defaultShortcuts: ["CommandOrControl+Enter"],
description: t("keyboard_actions.run-active-note"), description: t("keyboard_actions.run-active-note"),
scope: "code-detail" scope: "code-detail"
}, },
{ {
actionName: "toggleNoteHoisting", actionName: "toggleNoteHoisting",
friendlyName: "Toggle Note Hoisting",
defaultShortcuts: ["Alt+H"], defaultShortcuts: ["Alt+H"],
description: t("keyboard_actions.toggle-note-hoisting"), description: t("keyboard_actions.toggle-note-hoisting"),
scope: "window" scope: "window"
}, },
{ {
actionName: "unhoist", actionName: "unhoist",
friendlyName: "Unhoist Note",
defaultShortcuts: ["Alt+U"], defaultShortcuts: ["Alt+U"],
description: t("keyboard_actions.unhoist"), description: t("keyboard_actions.unhoist"),
scope: "window" scope: "window"
}, },
{ {
actionName: "reloadFrontendApp", actionName: "reloadFrontendApp",
friendlyName: "Reload Frontend App",
defaultShortcuts: ["F5", "CommandOrControl+R"], defaultShortcuts: ["F5", "CommandOrControl+R"],
description: t("keyboard_actions.reload-frontend-app"), description: t("keyboard_actions.reload-frontend-app"),
scope: "window" scope: "window"
}, },
{ {
actionName: "openDevTools", actionName: "openDevTools",
friendlyName: "Open Developer Tools",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
description: t("keyboard_actions.open-dev-tools"), description: t("keyboard_actions.open-dev-tools"),
scope: "window" scope: "window"
}, },
{ {
actionName: "findInText", actionName: "findInText",
friendlyName: "Find In Text",
defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
description: t("keyboard_actions.find-in-text"), description: t("keyboard_actions.find-in-text"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleLeftPane", actionName: "toggleLeftPane",
friendlyName: "Toggle Left Pane",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.toggle-left-note-tree-panel"), description: t("keyboard_actions.toggle-left-note-tree-panel"),
scope: "window" scope: "window"
}, },
{ {
actionName: "toggleFullscreen", actionName: "toggleFullscreen",
friendlyName: "Toggle Full Screen",
defaultShortcuts: ["F11"], defaultShortcuts: ["F11"],
description: t("keyboard_actions.toggle-full-screen"), description: t("keyboard_actions.toggle-full-screen"),
scope: "window" scope: "window"
}, },
{ {
actionName: "zoomOut", actionName: "zoomOut",
friendlyName: "Zoom Out",
defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
description: t("keyboard_actions.zoom-out"), description: t("keyboard_actions.zoom-out"),
scope: "window" scope: "window"
}, },
{ {
actionName: "zoomIn", actionName: "zoomIn",
friendlyName: "Zoom In",
description: t("keyboard_actions.zoom-in"), description: t("keyboard_actions.zoom-in"),
defaultShortcuts: isElectron ? ["CommandOrControl+="] : [], defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
scope: "window" scope: "window"
}, },
{ {
actionName: "zoomReset", actionName: "zoomReset",
friendlyName: "Reset Zoom Level",
description: t("keyboard_actions.reset-zoom-level"), description: t("keyboard_actions.reset-zoom-level"),
defaultShortcuts: isElectron ? ["CommandOrControl+0"] : [], defaultShortcuts: isElectron ? ["CommandOrControl+0"] : [],
scope: "window" scope: "window"
}, },
{ {
actionName: "copyWithoutFormatting", actionName: "copyWithoutFormatting",
friendlyName: "Copy Without Formatting",
defaultShortcuts: ["CommandOrControl+Alt+C"], defaultShortcuts: ["CommandOrControl+Alt+C"],
description: t("keyboard_actions.copy-without-formatting"), description: t("keyboard_actions.copy-without-formatting"),
scope: "text-detail" scope: "text-detail"
}, },
{ {
actionName: "forceSaveRevision", actionName: "forceSaveRevision",
friendlyName: "Force Save Revision",
defaultShortcuts: [], defaultShortcuts: [],
description: t("keyboard_actions.force-save-revision"), description: t("keyboard_actions.force-save-revision"),
scope: "window" scope: "window"
@ -633,7 +728,7 @@ function getDefaultKeyboardActions() {
const platformModifier = isMac ? "Meta" : "Ctrl"; const platformModifier = isMac ? "Meta" : "Ctrl";
for (const action of DEFAULT_KEYBOARD_ACTIONS) { for (const action of DEFAULT_KEYBOARD_ACTIONS) {
if (action.defaultShortcuts) { if ("defaultShortcuts" in action && action.defaultShortcuts) {
action.defaultShortcuts = action.defaultShortcuts.map((shortcut) => shortcut.replace("CommandOrControl", platformModifier)); action.defaultShortcuts = action.defaultShortcuts.map((shortcut) => shortcut.replace("CommandOrControl", platformModifier));
} }
} }
@ -645,7 +740,9 @@ function getKeyboardActions() {
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(getDefaultKeyboardActions())); const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(getDefaultKeyboardActions()));
for (const action of actions) { for (const action of actions) {
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : []; if ("effectiveShortcuts" in action && action.effectiveShortcuts) {
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
}
} }
for (const option of optionService.getOptions()) { for (const option of optionService.getOptions()) {
@ -653,7 +750,7 @@ function getKeyboardActions() {
let actionName = option.name.substring(17); let actionName = option.name.substring(17);
actionName = actionName.charAt(0).toLowerCase() + actionName.slice(1); actionName = actionName.charAt(0).toLowerCase() + actionName.slice(1);
const action = actions.find((ea) => ea.actionName === actionName); const action = actions.find((ea) => "actionName" in ea && ea.actionName === actionName) as ActionKeyboardShortcut;
if (action) { if (action) {
try { try {

View File

@ -251,7 +251,7 @@ function initStartupOptions() {
} }
function getKeyboardDefaultOptions() { function getKeyboardDefaultOptions() {
return (keyboardActions.getDefaultKeyboardActions().filter((ka) => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[]).map((ka) => ({ return (keyboardActions.getDefaultKeyboardActions().filter((ka) => "actionName" in ka) as KeyboardShortcutWithRequiredActionName[]).map((ka) => ({
name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`, name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`,
value: JSON.stringify(ka.defaultShortcuts), value: JSON.stringify(ka.defaultShortcuts),
isSynced: false isSynced: false

View File

@ -295,7 +295,7 @@ async function registerGlobalShortcuts() {
const allActions = keyboardActionsService.getKeyboardActions(); const allActions = keyboardActionsService.getKeyboardActions();
for (const action of allActions) { for (const action of allActions) {
if (!action.effectiveShortcuts) { if (!("effectiveShortcuts" in action) || !action.effectiveShortcuts) {
continue; continue;
} }

View File

@ -102,8 +102,9 @@ export interface KeyboardShortcutSeparator {
separator: string; separator: string;
} }
export interface KeyboardShortcutBase { export interface ActionKeyboardShortcut {
actionName: KeyboardActionNames; actionName: KeyboardActionNames;
friendlyName: string;
description?: string; description?: string;
defaultShortcuts?: string[]; defaultShortcuts?: string[];
effectiveShortcuts?: string[]; effectiveShortcuts?: string[];
@ -118,8 +119,8 @@ export interface KeyboardShortcutBase {
scope?: "window" | "note-tree" | "text-detail" | "code-detail"; scope?: "window" | "note-tree" | "text-detail" | "code-detail";
} }
type KeyboardShortcut = KeyboardShortcutBase | KeyboardShortcutSeparator; export type KeyboardShortcut = ActionKeyboardShortcut | KeyboardShortcutSeparator;
export interface KeyboardShortcutWithRequiredActionName extends KeyboardShortcut { export interface KeyboardShortcutWithRequiredActionName extends ActionKeyboardShortcut {
actionName: KeyboardActionNames; actionName: KeyboardActionNames;
} }