2019-11-19 20:53:04 +01:00
|
|
|
"use strict";
|
|
|
|
|
2024-07-18 21:35:17 +03:00
|
|
|
import optionService from "./options.js";
|
|
|
|
import log from "./log.js";
|
|
|
|
import utils from "./utils.js";
|
2024-07-24 20:33:35 +03:00
|
|
|
import { KeyboardShortcut } from './keyboard_actions_interface.js';
|
2024-09-08 15:05:18 +03:00
|
|
|
import { t } from "i18next";
|
2019-11-19 20:53:04 +01:00
|
|
|
|
2019-11-24 09:50:19 +01:00
|
|
|
const isMac = process.platform === "darwin";
|
|
|
|
const isElectron = utils.isElectron();
|
2019-11-18 23:01:31 +01:00
|
|
|
|
2023-09-11 22:54:36 +02:00
|
|
|
/**
|
|
|
|
* Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,
|
|
|
|
* the focus has to be inside the element.
|
|
|
|
*
|
|
|
|
* So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.
|
|
|
|
* This allows to have the same shortcut have different actions attached based on the context
|
|
|
|
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
|
|
|
|
*/
|
|
|
|
|
2024-09-14 14:34:24 +03:00
|
|
|
if (!t("keyboard_actions.note-navigation")) {
|
|
|
|
throw new Error("Keyboard actions loaded before translations.");
|
|
|
|
}
|
|
|
|
|
2024-02-17 19:29:15 +02:00
|
|
|
const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
|
2019-11-20 23:10:41 +01:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.note-navigation")
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "backInNoteHistory",
|
2019-11-24 09:50:19 +01:00
|
|
|
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
2023-03-14 21:07:14 +01:00
|
|
|
defaultShortcuts: isMac ? ["CommandOrControl+Left"] : ["Alt+Left"],
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "forwardInNoteHistory",
|
2019-11-24 09:50:19 +01:00
|
|
|
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
2023-03-14 21:07:14 +01:00
|
|
|
defaultShortcuts: isMac ? ["CommandOrControl+Right"] : ["Alt+Right"],
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "jumpToNote",
|
2019-11-21 21:12:07 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+J"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.open-jump-to-note-dialog"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "scrollToActiveNote",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+."],
|
2020-06-03 11:06:45 +02:00
|
|
|
scope: "window"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2021-02-01 23:51:04 +01:00
|
|
|
actionName: "quickSearch",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+S"],
|
|
|
|
scope: "window"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "searchInSubtree",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+Shift+S"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.search-in-subtree"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
2020-04-29 23:13:05 +02:00
|
|
|
{
|
|
|
|
actionName: "expandSubtree",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.expand-subtree"),
|
2020-04-29 23:13:05 +02:00
|
|
|
scope: "note-tree"
|
|
|
|
},
|
2019-11-20 23:10:41 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "collapseTree",
|
2020-02-02 10:10:37 +01:00
|
|
|
defaultShortcuts: ["Alt+C"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.collapse-tree"),
|
2020-06-03 11:06:45 +02:00
|
|
|
scope: "window"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "collapseSubtree",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Alt+-"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.collapse-subtree"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "sortChildNotes",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Alt+S"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.sort-child-notes"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
|
|
|
|
|
2019-11-23 22:56:35 +01:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.creating-and-moving-notes")
|
2019-11-23 22:56:35 +01:00
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "createNoteAfter",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+O"],
|
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "createNoteInto",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+P"],
|
|
|
|
scope: "window"
|
2019-11-21 21:12:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-11-27 22:21:13 +01:00
|
|
|
actionName: "createNoteIntoInbox",
|
2019-11-21 21:12:07 +01:00
|
|
|
defaultShortcuts: ["global:CommandOrControl+Alt+P"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.create-note-into-inbox"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "deleteNotes",
|
2019-11-21 22:24:07 +01:00
|
|
|
defaultShortcuts: ["Delete"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.delete-note"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "moveNoteUp",
|
2022-06-09 23:38:07 +02:00
|
|
|
defaultShortcuts: isMac ? ["Alt+Up"] : ["CommandOrControl+Up"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.move-note-up"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "moveNoteDown",
|
2022-06-09 23:38:07 +02:00
|
|
|
defaultShortcuts: isMac ? ["Alt+Down"] : ["CommandOrControl+Down"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.move-note-down"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "moveNoteUpInHierarchy",
|
2022-06-09 23:38:07 +02:00
|
|
|
defaultShortcuts: isMac ? ["Alt+Left"] : ["CommandOrControl+Left"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.move-note-up-in-hierarchy"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "moveNoteDownInHierarchy",
|
2022-06-09 23:38:07 +02:00
|
|
|
defaultShortcuts: isMac ? ["Alt+Right"] : ["CommandOrControl+Right"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.move-note-down-in-hierarchy"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "editNoteTitle",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Enter"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.edit-note-title"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "editBranchPrefix",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["F2"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.edit-branch-prefix"),
|
2024-09-02 23:37:34 +03:00
|
|
|
scope: "note-tree"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "cloneNotesTo",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+Shift+C"],
|
|
|
|
scope: "window"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "moveNotesTo",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+Shift+X"],
|
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.note-clipboard")
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
|
2019-11-21 22:24:07 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "copyNotesToClipboard",
|
2019-11-21 21:12:07 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+C"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.copy-notes-to-clipboard"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "pasteNotesFromClipboard",
|
2019-11-21 21:12:07 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+V"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.paste-notes-from-clipboard"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "cutNotesToClipboard",
|
2019-11-21 21:12:07 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+X"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.cut-notes-to-clipboard"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "selectAllNotesInParent",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+A"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.select-all-notes-in-parent"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-20 23:10:41 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "addNoteAboveToSelection",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Shift+Up"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.add-note-above-to-the-selection"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "addNoteBelowToSelection",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Shift+Down"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.add-note-below-to-selection"),
|
2020-02-02 10:10:37 +01:00
|
|
|
scope: "note-tree"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
2020-11-23 19:44:49 +01:00
|
|
|
{
|
|
|
|
actionName: "duplicateSubtree",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.duplicate-subtree"),
|
2020-11-23 19:44:49 +01:00
|
|
|
scope: "note-tree"
|
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
|
|
|
|
|
2019-11-21 22:24:07 +01:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.tabs-and-windows")
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "openNewTab",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.open-new-tab"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "closeActiveTab",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.close-active-tab"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2021-10-09 21:20:12 +02:00
|
|
|
{
|
|
|
|
actionName: "reopenLastTab",
|
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.reopen-last-tab"),
|
2021-10-09 21:20:12 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "activateNextTab",
|
2022-11-27 19:33:05 -08:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+Tab", "CommandOrControl+PageDown"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.activate-next-tab"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "activatePreviousTab",
|
2022-11-27 19:33:05 -08:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab", "CommandOrControl+PageUp"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.activate-previous-tab"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-21 22:24:07 +01:00
|
|
|
},
|
2020-05-05 19:30:03 +02:00
|
|
|
{
|
|
|
|
actionName: "openNewWindow",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.open-new-window"),
|
2020-05-05 19:30:03 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2023-09-18 04:38:23 -04:00
|
|
|
{
|
|
|
|
actionName: "toggleTray",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-tray"),
|
2023-09-18 04:38:23 -04:00
|
|
|
scope: "window"
|
|
|
|
},
|
2023-09-08 22:53:21 -04:00
|
|
|
{
|
|
|
|
actionName: "firstTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+1"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.first-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "secondTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+2"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.second-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "thirdTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+3"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.third-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "fourthTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+4"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.fourth-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "fifthTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+5"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.fifth-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "sixthTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+6"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.sixth-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "seventhTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+7"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.seventh-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "eigthTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+8"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.eight-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "ninthTab",
|
|
|
|
defaultShortcuts: ["CommandOrControl+9"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.ninth-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "lastTab",
|
2024-01-09 22:52:13 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.last-tab"),
|
2023-09-11 18:03:49 -04:00
|
|
|
scope: "window"
|
2023-09-08 22:53:21 -04:00
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
|
|
|
|
|
2019-11-21 22:24:07 +01:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.dialogs")
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "showNoteSource",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-note-source"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "showOptions",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-options"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
{
|
2023-06-04 23:01:40 +02:00
|
|
|
actionName: "showRevisions",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-revisions"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "showRecentChanges",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-recent-changes"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "showSQLConsole",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: ["Alt+O"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-sql-console"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2019-12-05 21:25:36 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "showBackendLog",
|
2019-12-05 21:25:36 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-backend-log"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-12-05 21:25:36 +01:00
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2023-02-17 16:44:04 +01:00
|
|
|
actionName: "showHelp",
|
2019-11-24 22:15:33 +01:00
|
|
|
defaultShortcuts: ["F1"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.show-help"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.text-note-operations")
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "addLinkToText",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+L"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.add-link-to-text"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "text-detail"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2021-09-05 13:24:38 +03:00
|
|
|
{
|
|
|
|
actionName: "followLinkUnderCursor",
|
|
|
|
defaultShortcuts: ["CommandOrControl+Enter"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.follow-link-under-cursor"),
|
2021-09-05 13:24:38 +03:00
|
|
|
scope: "text-detail"
|
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "insertDateTimeToText",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["Alt+T"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.insert-date-and-time-to-text"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "text-detail"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2019-12-10 23:04:18 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "pasteMarkdownIntoText",
|
2019-12-10 23:04:18 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.paste-markdown-into-text"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "text-detail"
|
2019-12-10 23:04:18 +01:00
|
|
|
},
|
2020-01-01 22:59:51 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "cutIntoNote",
|
2020-01-01 22:59:51 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.cut-into-note"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "text-detail"
|
2020-01-01 22:59:51 +01:00
|
|
|
},
|
2020-11-22 22:44:06 +01:00
|
|
|
{
|
|
|
|
actionName: "addIncludeNoteToText",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.add-include-note-to-text"),
|
2020-11-22 22:44:06 +01:00
|
|
|
scope: "text-detail"
|
|
|
|
},
|
2021-06-24 20:27:04 +02:00
|
|
|
{
|
|
|
|
actionName: "editReadOnlyNote",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.edit-readonly-note"),
|
2021-06-24 20:27:04 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
|
2020-09-01 23:18:28 +02:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.attributes-labels-and-relations")
|
2020-09-01 23:18:28 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
actionName: "addNewLabel",
|
|
|
|
defaultShortcuts: ["Alt+L"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.add-new-label"),
|
2020-09-01 23:18:28 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "addNewRelation",
|
|
|
|
defaultShortcuts: ["Alt+R"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.create-new-relation"),
|
2020-09-01 23:18:28 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
|
2021-06-27 12:53:05 +02:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.ribbon-tabs")
|
2021-06-27 12:53:05 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabBasicProperties",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-basic-properties"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabBookProperties",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-book-properties"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabFileProperties",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-file-properties"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabImageProperties",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-image-properties"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabOwnedAttributes",
|
|
|
|
defaultShortcuts: ["Alt+A"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-owned-attributes"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabInheritedAttributes",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-inherited-attributes"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabPromotedAttributes",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-promoted-attributes"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
2021-09-22 21:11:36 +02:00
|
|
|
actionName: "toggleRibbonTabNoteMap",
|
2021-06-27 12:53:05 +02:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-link-map"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabNoteInfo",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-note-info"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabNotePaths",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-note-paths"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
actionName: "toggleRibbonTabSimilarNotes",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-similar-notes"),
|
2021-06-27 12:53:05 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
|
|
|
|
2019-11-24 10:40:18 +01:00
|
|
|
{
|
2024-09-08 15:33:06 +03:00
|
|
|
separator: t("keyboard_actions.other")
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
|
2024-01-28 08:58:40 +01:00
|
|
|
{
|
|
|
|
actionName: "toggleRightPane",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-right-pane"),
|
2024-01-28 08:58:40 +01:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "printActiveNote",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.print-active-note"),
|
2020-06-20 00:04:31 +02:00
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
2021-04-24 21:56:44 +02:00
|
|
|
{
|
|
|
|
actionName: "openNoteExternally",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.open-note-externally"),
|
2021-04-24 21:56:44 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2021-03-19 22:34:56 +01:00
|
|
|
{
|
|
|
|
actionName: "renderActiveNote",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.render-active-note"),
|
2021-03-19 22:34:56 +01:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-24 10:40:18 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "runActiveNote",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+Enter"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.run-active-note"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "code-detail"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "toggleNoteHoisting",
|
2019-11-24 10:40:18 +01:00
|
|
|
defaultShortcuts: ["Alt+H"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-note-hoisting"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-24 10:40:18 +01:00
|
|
|
},
|
2020-10-13 23:41:55 +02:00
|
|
|
{
|
|
|
|
actionName: "unhoist",
|
|
|
|
defaultShortcuts: ["Alt+U"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.unhoist"),
|
2020-10-13 23:41:55 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "reloadFrontendApp",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["F5", "CommandOrControl+R"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.reload-frontend-app"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "openDevTools",
|
2020-11-05 21:26:24 +01:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.open-dev-tools"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "findInText",
|
2020-09-13 00:19:50 +02:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
2021-10-12 19:29:42 +02:00
|
|
|
{
|
|
|
|
actionName: "toggleLeftPane",
|
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-left-note-tree-panel"),
|
2021-10-12 19:29:42 +02:00
|
|
|
scope: "window"
|
|
|
|
},
|
2019-11-18 23:01:31 +01:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "toggleFullscreen",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["F11"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.toggle-full-screen"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "zoomOut",
|
2020-08-24 23:33:27 +02:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.zoom-out"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2019-11-18 23:01:31 +01:00
|
|
|
},
|
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "zoomIn",
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.zoom-in"),
|
2020-08-24 23:33:27 +02:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "window"
|
2020-01-19 11:16:36 +03:00
|
|
|
},
|
2023-09-01 03:30:39 +00:00
|
|
|
{
|
|
|
|
actionName: "zoomReset",
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.reset-zoom-level"),
|
2023-09-01 03:30:39 +00:00
|
|
|
defaultShortcuts: isElectron ? ["CommandOrControl+0"] : [],
|
|
|
|
scope: "window"
|
|
|
|
},
|
2020-01-19 11:16:36 +03:00
|
|
|
{
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName: "copyWithoutFormatting",
|
2020-02-15 22:12:05 +01:00
|
|
|
defaultShortcuts: ["CommandOrControl+Alt+C"],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.copy-without-formatting"),
|
2020-02-15 22:12:05 +01:00
|
|
|
scope: "text-detail"
|
2022-11-08 22:36:15 +01:00
|
|
|
},
|
|
|
|
{
|
2023-06-04 23:01:40 +02:00
|
|
|
actionName: "forceSaveRevision",
|
2022-11-08 22:36:15 +01:00
|
|
|
defaultShortcuts: [],
|
2024-09-08 15:33:06 +03:00
|
|
|
description: t("keyboard_actions.force-save-revision"),
|
2022-11-08 22:36:15 +01:00
|
|
|
scope: "window"
|
2019-11-23 22:56:35 +01:00
|
|
|
}
|
2019-11-18 23:01:31 +01:00
|
|
|
];
|
|
|
|
|
2019-11-24 09:50:19 +01:00
|
|
|
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
2019-11-20 21:35:18 +01:00
|
|
|
|
2019-11-24 09:50:19 +01:00
|
|
|
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
|
|
|
if (action.defaultShortcuts) {
|
|
|
|
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", platformModifier));
|
2019-11-20 21:35:18 +01:00
|
|
|
}
|
2019-11-19 23:02:54 +01:00
|
|
|
}
|
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
function getKeyboardActions() {
|
2024-02-17 19:29:15 +02:00
|
|
|
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
|
2019-11-19 20:53:04 +01:00
|
|
|
|
|
|
|
for (const action of actions) {
|
2024-02-17 19:29:15 +02:00
|
|
|
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
|
2019-11-19 20:53:04 +01:00
|
|
|
}
|
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
for (const option of optionService.getOptions()) {
|
2019-11-19 20:53:04 +01:00
|
|
|
if (option.name.startsWith('keyboardShortcuts')) {
|
2024-04-03 19:22:49 +03:00
|
|
|
let actionName = option.name.substring(17);
|
2020-02-19 20:54:14 +01:00
|
|
|
actionName = actionName.charAt(0).toLowerCase() + actionName.slice(1);
|
2019-11-19 20:53:04 +01:00
|
|
|
|
|
|
|
const action = actions.find(ea => ea.actionName === actionName);
|
|
|
|
|
|
|
|
if (action) {
|
|
|
|
try {
|
|
|
|
action.effectiveShortcuts = JSON.parse(option.value);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
log.error(`Could not parse shortcuts for action ${actionName}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-11-23 22:56:35 +01:00
|
|
|
log.info(`Keyboard action ${actionName} found in database, but not in action definition.`);
|
2019-11-19 20:53:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 23:02:54 +01:00
|
|
|
|
|
|
|
return actions;
|
2019-11-19 20:53:04 +01:00
|
|
|
}
|
|
|
|
|
2024-07-18 21:47:30 +03:00
|
|
|
export default {
|
2019-11-19 20:53:04 +01:00
|
|
|
DEFAULT_KEYBOARD_ACTIONS,
|
|
|
|
getKeyboardActions
|
2020-06-03 11:06:45 +02:00
|
|
|
};
|