From 7e41a2750c1ac8b105b1034f762151c4229555e1 Mon Sep 17 00:00:00 2001
From: zadam
Date: Sat, 15 Feb 2020 22:12:05 +0100
Subject: [PATCH] refactored KB handling and add link dialog
---
src/public/javascripts/dialogs/add_link.js | 18 +--
.../services/dialog_command_executor.js | 4 -
.../javascripts/services/keyboard_actions.js | 43 ++++--
.../javascripts/services/tree_context_menu.js | 26 ++--
.../javascripts/services/tree_keybindings.js | 30 ++---
.../javascripts/widgets/global_buttons.js | 6 +-
src/public/javascripts/widgets/global_menu.js | 14 +-
.../javascripts/widgets/note_actions.js | 10 +-
src/public/javascripts/widgets/note_detail.js | 2 +-
.../widgets/standard_top_widget.js | 4 +-
src/public/javascripts/widgets/tab_row.js | 4 +-
.../javascripts/widgets/type_widgets/text.js | 19 ++-
src/services/keyboard_actions.js | 125 ++++++++++++------
src/views/dialogs/help.ejs | 66 ++++-----
14 files changed, 211 insertions(+), 160 deletions(-)
diff --git a/src/public/javascripts/dialogs/add_link.js b/src/public/javascripts/dialogs/add_link.js
index d401f75f1..a75364cf3 100644
--- a/src/public/javascripts/dialogs/add_link.js
+++ b/src/public/javascripts/dialogs/add_link.js
@@ -9,14 +9,13 @@ const $autoComplete = $("#add-link-note-autocomplete");
const $linkTitle = $("#link-title");
const $addLinkTitleFormGroup = $("#add-link-title-form-group");
-export async function showDialog() {
- appContext.trigger('executeInActiveEditor', {
- callback: textEditor => {
- const hasSelection = !textEditor.model.document.selection.isCollapsed;
+/** @var TextTypeWidget */
+let textTypeWidget;
- $addLinkTitleFormGroup.toggle(!hasSelection);
- }
- });
+export async function showDialog(widget) {
+ textTypeWidget = widget;
+
+ $addLinkTitleFormGroup.toggle(!textTypeWidget.hasSelection());
utils.openDialog($dialog);
@@ -58,10 +57,7 @@ $form.on('submit', () => {
if (notePath) {
$dialog.modal('hide');
- appContext.trigger(`addLinkToActiveEditor`, {
- linkTitle: $linkTitle.val(),
- linkHref: '#' + notePath
- });
+ textTypeWidget.addLink($linkTitle.val(), '#' + notePath);
}
else {
console.error("No path to add link.");
diff --git a/src/public/javascripts/services/dialog_command_executor.js b/src/public/javascripts/services/dialog_command_executor.js
index bc6f3b7fc..06d718a9c 100644
--- a/src/public/javascripts/services/dialog_command_executor.js
+++ b/src/public/javascripts/services/dialog_command_executor.js
@@ -42,10 +42,6 @@ export default class DialogCommandExecutor extends Component {
}
}
- addLinkToTextCommand() {
- import("../dialogs/add_link.js").then(d => d.showDialog());
- }
-
async cloneNoteIdsToCommand({noteIds}) {
const d = await import("../dialogs/clone_to.js");
d.showDialog(noteIds);
diff --git a/src/public/javascripts/services/keyboard_actions.js b/src/public/javascripts/services/keyboard_actions.js
index 95bb46072..a4ee1defc 100644
--- a/src/public/javascripts/services/keyboard_actions.js
+++ b/src/public/javascripts/services/keyboard_actions.js
@@ -5,18 +5,39 @@ import appContext from "./app_context.js";
const keyboardActionRepo = {};
const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
+ actions = actions.filter(a => !!a.actionName); // filter out separators
+
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;
+ }
- for (const shortcut of action.effectiveShortcuts || []) {
- 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);
+ return actions;
+});
- if (action.scope !== 'note-tree') {
- // empty object param so that destructuring with optional params work
- utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {}));
- }
- }
+async function getActionsForScope(scope) {
+ const actions = await keyboardActionsLoaded;
+
+ 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 => {
for (const shortcut in shortcutForNotes) {
utils.bindGlobalShortcut(shortcut, async () => {
- const treeService = (await import("./tree.js")).default;
-
appContext.tabManager.getActiveTabContext().setNote(shortcutForNotes[shortcut]);
});
}
@@ -104,5 +123,7 @@ export default {
setElementActionHandler,
triggerAction,
getAction,
- updateDisplayedShortcuts
+ updateDisplayedShortcuts,
+ getActionsForScope,
+ setupActionsForElement
};
\ No newline at end of file
diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js
index 83b70689c..9ba209dc0 100644
--- a/src/public/javascripts/services/tree_context_menu.js
+++ b/src/public/javascripts/services/tree_context_menu.js
@@ -51,39 +51,39 @@ class TreeContextMenu {
return [
{ title: 'Open in new tab', cmd: "openInTab", uiIcon: "empty", enabled: noSelectedNotes },
- { title: 'Insert note after ', cmd: "insertNoteAfter", uiIcon: "plus",
+ { title: 'Insert note after ', cmd: "insertNoteAfter", uiIcon: "plus",
items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null,
enabled: insertNoteAfterEnabled && noSelectedNotes },
- { title: 'Insert child note ', cmd: "insertChildNote", uiIcon: "plus",
+ { title: 'Insert child note ', cmd: "insertChildNote", uiIcon: "plus",
items: notSearch ? this.getNoteTypeItems("insertChildNote") : null,
enabled: notSearch && noSelectedNotes },
- { title: 'Delete ', cmd: "delete", uiIcon: "trash",
+ { title: 'Delete ', cmd: "delete", uiIcon: "trash",
enabled: isNotRoot && !isHoisted && parentNotSearch },
{ title: "----" },
- { title: 'Search in subtree ', cmd: "searchInSubtree", uiIcon: "search",
+ { title: 'Search in subtree ', cmd: "searchInSubtree", uiIcon: "search",
enabled: notSearch && noSelectedNotes },
- isHoisted ? null : { title: 'Hoist note ', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
+ isHoisted ? null : { title: 'Hoist note ', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
!isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', cmd: "unhoist", uiIcon: "arrow-up" },
- { title: 'Edit branch prefix ', cmd: "editBranchPrefix", uiIcon: "empty",
+ { title: 'Edit branch prefix ', cmd: "editBranchPrefix", uiIcon: "empty",
enabled: isNotRoot && parentNotSearch && noSelectedNotes},
{ title: "Advanced", uiIcon: "empty", enabled: true, items: [
- { title: 'Collapse subtree ', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes },
+ { title: 'Collapse subtree ', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes },
{ title: "Force note sync", cmd: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes },
- { title: 'Sort alphabetically ', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }
+ { title: 'Sort alphabetically ', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }
] },
{ title: "----" },
{ title: "Protect subtree", cmd: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes },
{ title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "shield", enabled: noSelectedNotes },
{ title: "----" },
- { title: 'Copy / clone ', cmd: "copy", uiIcon: "copy",
+ { title: 'Copy / clone ', cmd: "copy", uiIcon: "copy",
enabled: isNotRoot && !isHoisted },
- { title: 'Clone to ... ', cmd: "cloneTo", uiIcon: "empty",
+ { title: 'Clone to ... ', cmd: "cloneTo", uiIcon: "empty",
enabled: isNotRoot && !isHoisted },
- { title: 'Cut ', cmd: "cut", uiIcon: "cut",
+ { title: 'Cut ', cmd: "cut", uiIcon: "cut",
enabled: isNotRoot && !isHoisted && parentNotSearch },
- { title: 'Move to ... ', cmd: "moveTo", uiIcon: "empty",
+ { title: 'Move to ... ', cmd: "moveTo", uiIcon: "empty",
enabled: isNotRoot && !isHoisted && parentNotSearch },
- { title: 'Paste into ', cmd: "pasteInto", uiIcon: "paste",
+ { title: 'Paste into ', cmd: "pasteInto", uiIcon: "paste",
enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes },
{ title: 'Paste after', cmd: "pasteAfter", uiIcon: "paste",
enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes },
diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.js
index f9843f4f9..db89d1b10 100644
--- a/src/public/javascripts/services/tree_keybindings.js
+++ b/src/public/javascripts/services/tree_keybindings.js
@@ -52,12 +52,12 @@ function getSelectedOrActiveBranchIds(treeWidget, node) {
*/
function getTemplates(treeWidget) {
return {
- "DeleteNotes": node => {
+ "deleteNotes": node => {
const branchIds = getSelectedOrActiveBranchIds(treeWidget, node);
treeChangesService.deleteNotes(treeWidget, branchIds);
},
- "MoveNoteUp": node => {
+ "moveNoteUp": node => {
const beforeNode = node.getPrevSibling();
if (beforeNode !== null) {
@@ -66,7 +66,7 @@ function getTemplates(treeWidget) {
return false;
},
- "MoveNoteDown": node => {
+ "moveNoteDown": node => {
const afterNode = node.getNextSibling();
if (afterNode !== null) {
treeChangesService.moveAfterBranch([node.data.branchId], afterNode.data.branchId);
@@ -74,12 +74,12 @@ function getTemplates(treeWidget) {
return false;
},
- "MoveNoteUpInHierarchy": node => {
+ "moveNoteUpInHierarchy": node => {
treeChangesService.moveNodeUpInHierarchy(node);
return false;
},
- "MoveNoteDownInHierarchy": node => {
+ "moveNoteDownInHierarchy": node => {
const toNode = node.getPrevSibling();
if (toNode !== null) {
@@ -88,7 +88,7 @@ function getTemplates(treeWidget) {
return false;
},
- "AddNoteAboveToSelection": () => {
+ "addNoteAboveToSelection": () => {
const node = treeWidget.getFocusedNode();
if (!node) {
@@ -113,7 +113,7 @@ function getTemplates(treeWidget) {
return false;
},
- "AddNoteBelowToSelection": () => {
+ "addNoteBelowToSelection": () => {
const node = treeWidget.getFocusedNode();
if (!node) {
@@ -138,42 +138,42 @@ function getTemplates(treeWidget) {
return false;
},
- "CollapseSubtree": node => {
+ "collapseSubtree": node => {
treeWidget.collapseTree(node);
},
- "SortChildNotes": node => {
+ "sortChildNotes": node => {
treeService.sortAlphabetically(node.data.noteId);
return false;
},
- "SelectAllNotesInParent": node => {
+ "selectAllNotesInParent": node => {
for (const child of node.getParent().getChildren()) {
child.setSelected(true);
}
return false;
},
- "CopyNotesToClipboard": node => {
+ "copyNotesToClipboard": node => {
clipboard.copy(getSelectedOrActiveBranchIds(treeWidget, node));
return false;
},
- "CutNotesToClipboard": node => {
+ "cutNotesToClipboard": node => {
clipboard.cut(getSelectedOrActiveBranchIds(treeWidget, node));
return false;
},
- "PasteNotesFromClipboard": node => {
+ "pasteNotesFromClipboard": node => {
clipboard.pasteInto(node.data.noteId);
return false;
},
- "EditNoteTitle": node => {
+ "editNoteTitle": node => {
appContext.trigger('focusOnTitle');
return false;
},
- "ActivateParentNote": node => {
+ "activateParentNote": node => {
if (!hoistedNoteService.isRootNode(node)) {
node.getParent().setActive().then(treeWidget.clearSelectedNodes);
}
diff --git a/src/public/javascripts/widgets/global_buttons.js b/src/public/javascripts/widgets/global_buttons.js
index 9ee59d0b1..8953ad83a 100644
--- a/src/public/javascripts/widgets/global_buttons.js
+++ b/src/public/javascripts/widgets/global_buttons.js
@@ -19,17 +19,17 @@ const WIDGET_TPL = `
`;
diff --git a/src/public/javascripts/widgets/global_menu.js b/src/public/javascripts/widgets/global_menu.js
index 9b5f8d83f..7765e7adf 100644
--- a/src/public/javascripts/widgets/global_menu.js
+++ b/src/public/javascripts/widgets/global_menu.js
@@ -42,44 +42,44 @@ const TPL = `
Open Dev Tools
-
+
Open SQL Console
-
+
Show backend log
-
+
Reload frontend
-
+
Toggle Zen mode
-
+
Toggle fullscreen
-
+
Show Help
-
+
diff --git a/src/public/javascripts/widgets/note_actions.js b/src/public/javascripts/widgets/note_actions.js
index ff57fe56e..62cf491e5 100644
--- a/src/public/javascripts/widgets/note_actions.js
+++ b/src/public/javascripts/widgets/note_actions.js
@@ -8,13 +8,13 @@ const TPL = `
`;
diff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.js
index 076d2b727..79ad4d414 100644
--- a/src/public/javascripts/widgets/note_detail.js
+++ b/src/public/javascripts/widgets/note_detail.js
@@ -98,7 +98,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
if (!(this.type in this.typeWidgets)) {
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;
this.children.push(typeWidget);
diff --git a/src/public/javascripts/widgets/standard_top_widget.js b/src/public/javascripts/widgets/standard_top_widget.js
index 1e3261c58..1c067fd79 100644
--- a/src/public/javascripts/widgets/standard_top_widget.js
+++ b/src/public/javascripts/widgets/standard_top_widget.js
@@ -32,12 +32,12 @@ const TPL = `
-
`;
-const NEW_TAB_BUTTON_TPL = `+
`;
+const NEW_TAB_BUTTON_TPL = `+
`;
const FILLER_TPL = ``;
diff --git a/src/public/javascripts/widgets/type_widgets/text.js b/src/public/javascripts/widgets/type_widgets/text.js
index c3af07617..483b429bc 100644
--- a/src/public/javascripts/widgets/type_widgets/text.js
+++ b/src/public/javascripts/widgets/type_widgets/text.js
@@ -4,6 +4,7 @@ import mimeTypesService from '../../services/mime_types.js';
import TypeWidget from "./type_widget.js";
import utils from "../../services/utils.js";
import appContext from "../../services/app_context.js";
+import keyboardActionService from "../../services/keyboard_actions.js";
const ENABLE_INSPECTOR = false;
@@ -99,6 +100,8 @@ export default class TextTypeWidget extends TypeWidget {
this.initialized = this.initEditor();
+ keyboardActionService.setupActionsForElement('text-detail', this.$widget, this);
+
return this.$widget;
}
@@ -184,11 +187,7 @@ export default class TextTypeWidget extends TypeWidget {
this.$widget.scrollTop(0);
}
- insertDateTimeToTextListener() {
- if (!this.isActive()) {
- return;
- }
-
+ insertDateTimeToTextCommand() {
const date = new Date();
const dateString = utils.formatDateTime(date);
@@ -221,11 +220,7 @@ export default class TextTypeWidget extends TypeWidget {
this.addTextToEditor(text);
}
- async addLinkToActiveEditorListener({linkTitle, linkHref}) {
- if (!this.isActive()) {
- return;
- }
-
+ async addLink(linkTitle, linkHref) {
await this.initialized;
if (this.hasSelection()) {
@@ -255,4 +250,8 @@ export default class TextTypeWidget extends TypeWidget {
callback(this.textEditor);
}
+
+ addLinkToTextCommand() {
+ import("../../dialogs/add_link.js").then(d => d.showDialog(this));
+ }
}
\ No newline at end of file
diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js
index a07b16e0f..771d30a95 100644
--- a/src/services/keyboard_actions.js
+++ b/src/services/keyboard_actions.js
@@ -14,25 +14,30 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "BackInNoteHistory",
// 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",
// 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",
defaultShortcuts: ["CommandOrControl+J"],
- description: 'Open "Jump to note" dialog'
+ description: 'Open "Jump to note" dialog',
+ scope: "window"
},
{
actionName: "ScrollToActiveNote",
- defaultShortcuts: ["CommandOrControl+."]
+ defaultShortcuts: ["CommandOrControl+."],
+ scope: "window" // FIXME - how do we find what note tree should be updated?
},
{
actionName: "SearchNotes",
- defaultShortcuts: ["CommandOrControl+S"]
+ defaultShortcuts: ["CommandOrControl+S"],
+ scope: "window"
},
{
actionName: "SearchInSubtree",
@@ -43,6 +48,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "CollapseTree",
defaultShortcuts: ["Alt+C"],
+ scope: "note-tree"
},
{
actionName: "CollapseSubtree",
@@ -69,16 +75,19 @@ const DEFAULT_KEYBOARD_ACTIONS = [
},
{
actionName: "CreateNoteAfter",
- defaultShortcuts: ["CommandOrControl+O"]
+ defaultShortcuts: ["CommandOrControl+O"],
+ scope: "window"
},
{
actionName: "CreateNoteInto",
- defaultShortcuts: ["CommandOrControl+P"]
+ defaultShortcuts: ["CommandOrControl+P"],
+ scope: "window"
},
{
actionName: "CreateNoteIntoDayNote",
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",
@@ -119,15 +128,18 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "EditBranchPrefix",
defaultShortcuts: ["F2"],
- description: "Show Edit branch prefix dialog"
+ description: "Show Edit branch prefix dialog",
+ scope: "window"
},
{
actionName: "CloneNotesTo",
- defaultShortcuts: ["CommandOrControl+Shift+C"]
+ defaultShortcuts: ["CommandOrControl+Shift+C"],
+ scope: "window"
},
{
actionName: "MoveNotesTo",
- defaultShortcuts: ["CommandOrControl+Shift+X"]
+ defaultShortcuts: ["CommandOrControl+Shift+X"],
+ scope: "window"
},
{
@@ -179,22 +191,26 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "OpenNewTab",
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [],
- description: "Opens new tab"
+ description: "Opens new tab",
+ scope: "window"
},
{
actionName: "CloseActiveTab",
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [],
- description: "Closes active tab"
+ description: "Closes active tab",
+ scope: "window"
},
{
actionName: "ActivateNextTab",
defaultShortcuts: isElectron ? ["CommandOrControl+Tab"] : [],
- description: "Activates tab on the right"
+ description: "Activates tab on the right",
+ scope: "window"
},
{
actionName: "ActivatePreviousTab",
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",
defaultShortcuts: ["Alt+A"],
- description: "Shows Attributes dialog"
+ description: "Shows Attributes dialog",
+ scope: "window"
},
{
actionName: "ShowNoteInfo",
defaultShortcuts: [],
- description: "Shows Note Info dialog"
+ description: "Shows Note Info dialog",
+ scope: "window"
},
{
actionName: "ShowNoteSource",
defaultShortcuts: [],
- description: "Shows Note Source dialog"
+ description: "Shows Note Source dialog",
+ scope: "window"
},
{
actionName: "ShowLinkMap",
defaultShortcuts: [],
- description: "Shows Link Map dialog"
+ description: "Shows Link Map dialog",
+ scope: "window"
},
{
actionName: "ShowOptions",
defaultShortcuts: [],
- description: "Shows Options dialog"
+ description: "Shows Options dialog",
+ scope: "window"
},
{
actionName: "ShowNoteRevisions",
defaultShortcuts: [],
- description: "Shows Note Revisions dialog"
+ description: "Shows Note Revisions dialog",
+ scope: "window"
},
{
actionName: "ShowRecentChanges",
defaultShortcuts: [],
- description: "Shows Recent Changes dialog"
+ description: "Shows Recent Changes dialog",
+ scope: "window"
},
{
actionName: "ShowSQLConsole",
defaultShortcuts: ["Alt+O"],
- description: "Shows SQL Console dialog"
+ description: "Shows SQL Console dialog",
+ scope: "window"
},
{
actionName: "ShowBackendLog",
defaultShortcuts: [],
- description: "Shows Backend Log dialog"
+ description: "Shows Backend Log dialog",
+ scope: "window"
},
{
actionName: "ShowHelp",
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",
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",
- defaultShortcuts: ["Alt+T"]
+ defaultShortcuts: ["Alt+T"],
+ scope: "text-detail"
},
{
actionName: "PasteMarkdownIntoText",
defaultShortcuts: [],
- description: "Pastes Markdown from clipboard into text note"
+ description: "Pastes Markdown from clipboard into text note",
+ scope: "text-detail"
},
{
actionName: "CutIntoNote",
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",
- defaultShortcuts: []
+ defaultShortcuts: [],
+ scope: "note-detail"
},
{
actionName: "RunActiveNote",
defaultShortcuts: ["CommandOrControl+Enter"],
- description: "Run active JavaScript (frontend/backend) code note"
+ description: "Run active JavaScript (frontend/backend) code note",
+ scope: "code-detail"
},
{
actionName: "ToggleNoteHoisting",
defaultShortcuts: ["Alt+H"],
- description: "Toggles note hoisting of active note"
+ description: "Toggles note hoisting of active note",
+ scope: "window"
},
{
actionName: "ReloadFrontendApp",
- defaultShortcuts: ["F5", "CommandOrControl+R"]
+ defaultShortcuts: ["F5", "CommandOrControl+R"],
+ scope: "window"
},
{
actionName: "OpenDevTools",
- defaultShortcuts: ["CommandOrControl+Shift+I"]
+ defaultShortcuts: ["CommandOrControl+Shift+I"],
+ scope: "window"
},
{
actionName: "FindInText",
- defaultShortcuts: ["CommandOrControl+F"]
+ defaultShortcuts: ["CommandOrControl+F"],
+ scope: "window"
},
{
actionName: "ToggleFullscreen",
- defaultShortcuts: ["F11"]
+ defaultShortcuts: ["F11"],
+ scope: "window"
},
{
actionName: "ToggleZenMode",
- defaultShortcuts: ["Alt+M"]
+ defaultShortcuts: ["Alt+M"],
+ scope: "window"
},
{
actionName: "ZoomOut",
- defaultShortcuts: ["CommandOrControl+-"]
+ defaultShortcuts: ["CommandOrControl+-"],
+ scope: "window"
},
{
actionName: "ZoomIn",
- defaultShortcuts: ["CommandOrControl+="]
+ defaultShortcuts: ["CommandOrControl+="],
+ scope: "window"
},
{
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));
for (const action of actions) {
- if (action.defaultShortcuts) {
- action.effectiveShortcuts = action.defaultShortcuts.slice();
- }
+ action.effectiveShortcuts = action.effectiveShortcuts ? action.defaultShortcuts.slice() : [];
}
for (const option of await optionService.getOptions()) {
diff --git a/src/views/dialogs/help.ejs b/src/views/dialogs/help.ejs
index ab4b4a50a..6d25bdeb0 100644
--- a/src/views/dialogs/help.ejs
+++ b/src/views/dialogs/help.ejs
@@ -18,12 +18,12 @@
- UP, DOWN - go up/down in the list of notes
- LEFT, RIGHT - collapse/expand node
- - , - go back / forwards in the history
- - - show "Jump to" dialog
- - - scroll to active note
- - - jumps to parent note
- - - collapse whole note tree
- - - collapse sub-tree
+ - , - go back / forwards in the history
+ - - show "Jump to" dialog
+ - - scroll to active note
+ - - jumps to parent note
+ - - collapse whole note tree
+ - - collapse sub-tree
@@ -40,10 +40,10 @@
Only in desktop (electron build):
- - opens empty tab
- - closes active tab
- - activates next tab
- - activates previous tab
+ - opens empty tab
+ - closes active tab
+ - activates next tab
+ - activates previous tab
@@ -55,9 +55,9 @@
- - - creates new note after the active note
- - - creates new sub-note into active note
- - - edit prefix of active note clone
+ - - creates new note after the active note
+ - - creates new sub-note into active note
+ - - edit prefix of active note clone
@@ -69,15 +69,15 @@
- - , - move note up/down in the note list
- - , - move note up in the hierarchy
- - , - multi-select note above/below
- - - select all notes in the current level
+ - , - move note up/down in the note list
+ - , - move note up in the hierarchy
+ - , - multi-select note above/below
+ - - select all notes in the current level
- Shift+click - select note
- - - copies active note (or current selection) into clipboard (used for cloning)
- - - cuts current (or current selection) note into clipboard (used for moving notes)
- - - 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)
- - - delete note / sub-tree
+ - - copies active note (or current selection) into clipboard (used for cloning)
+ - - cuts current (or current selection) note into clipboard (used for moving notes)
+ - - 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)
+ - - delete note / sub-tree
@@ -89,12 +89,12 @@
- - in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor.
- switches back from editor to tree pane.
+ - in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor.
+ switches back from editor to tree pane.
- Ctrl+K - create / edit external link
- - - create internal link
- - - inserts current date and time at caret position
- - - jump away to the tree pane and scroll to active note
+ - - create internal link
+ - - inserts current date and time at caret position
+ - - jump away to the tree pane and scroll to active note
@@ -121,9 +121,9 @@
- - - reloads Trilium frontend
- - - show developer tools
- - - show SQL console
+ - - reloads Trilium frontend
+ - - show developer tools
+ - - show SQL console
@@ -135,10 +135,10 @@
- - - Zen mode - display only note editor, everything else is hidden
- - - toggle search form in tree pane
- - - in page search
- - - show note attributes dialog
+ - - Zen mode - display only note editor, everything else is hidden
+ - - toggle search form in tree pane
+ - - in page search
+ - - show note attributes dialog