Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
separators and fixes
zadam587134c2f8e7
diff --git a/src/public/javascripts/dialogs/options/keyboard_shortcuts.js b/src/public/javascripts/dialogs/options/keyboard_shortcuts.jsindex 5120f3a878..5266eb5cce 100644--- a/src/public/javascripts/dialogs/options/keyboard_shortcuts.js+++ b/src/public/javascripts/dialogs/options/keyboard_shortcuts.js@@ -35,17 +35,27 @@ export default class KeyboardShortcutsOptions {server.get('keyboard-actions').then(actions => {for (const action of actions) {- const $tr = $("<tr>")- .append($("<td>").text(action.actionName))- .append($("<td>").append(- $(`<input type="text" class="form-control">`)- .val(action.effectiveShortcuts.join(", "))- .attr('data-keyboard-action-name', action.actionName)- .attr('data-default-keyboard-shortcuts', action.defaultShortcuts.join(", "))- )+ const $tr = $("<tr>");++ if (action.separator) {+ $tr.append(+ $('<td colspan="4">')+ .attr("style","background-color: var(--accented-background-color); font-weight: bold;")+ .text(action.separator))- .append($("<td>").text(action.defaultShortcuts.join(", ")))- .append($("<td>").text(action.description));+ }+ else {+ $tr.append($("<td>").text(action.actionName))+ .append($("<td>").append(+ $(`<input type="text" class="form-control">`)+ .val(action.effectiveShortcuts.join(", "))+ .attr('data-keyboard-action-name', action.actionName)+ .attr('data-default-keyboard-shortcuts', action.defaultShortcuts.join(", "))+ )+ )+ .append($("<td>").text(action.defaultShortcuts.join(", ")))+ .append($("<td>").text(action.description));+ }$table.append($tr);}@@ -57,7 +67,8 @@ export default class KeyboardShortcutsOptions {const shortcuts = $input.val().replace('+,', "+Comma").split(",")- .map(shortcut => shortcut.replace("+Comma", "+,"));+ .map(shortcut => shortcut.replace("+Comma", "+,"))+ .filter(shortcut => !!shortcut);const opts = {};opts['keyboardShortcuts' + actionName] = JSON.stringify(shortcuts);diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.jsindex 31e6ee6c5c..57601c6fe4 100644--- a/src/public/javascripts/services/entrypoints.js+++ b/src/public/javascripts/services/entrypoints.js@@ -259,7 +259,9 @@ function setActionHandler(actionName, handler) {action.handler = handler;for (const shortcut of action.effectiveShortcuts) {- utils.bindGlobalShortcut(shortcut, handler);+ if (shortcut) {+ utils.bindGlobalShortcut(shortcut, handler);+ }}});}diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.jsindex e8a9283481..5c4788beed 100644--- a/src/services/keyboard_actions.js+++ b/src/services/keyboard_actions.js@@ -6,14 +6,26 @@ const log = require('./log');const ELECTRON = "electron";const DEFAULT_KEYBOARD_ACTIONS = [+ {+ separator: "Note navigation"+ },+ {+ actionName: "BackInNoteHistory",+ defaultShortcuts: ["Alt+Left"]+ },+ {+ actionName: "ForwardInNoteHistory",+ defaultShortcuts: ["Alt+Right"]+ },{actionName: "JumpToNote",defaultShortcuts: ["Mod+J"],description: 'Open "Jump to note" dialog'},++{- actionName: "MarkdownToHTML",- defaultShortcuts: ["Mod+Return"]+ separator: "Tabs"},{actionName: "NewTab",@@ -32,9 +44,46 @@ const DEFAULT_KEYBOARD_ACTIONS = [},{actionName: "PreviousTab",- defaultShortcuts: ["Mod+SHIFT+Tab"],+ defaultShortcuts: ["Mod+Shift+Tab"],only: ELECTRON},+++ {+ separator: "Dialogs"+ },+ {+ actionName: "ShowAttributes",+ defaultShortcuts: ["Alt+A"]+ },+ {+ actionName: "ShowNoteInfo",+ defaultShortcuts: []+ },+ {+ actionName: "ShowNoteSource",+ defaultShortcuts: []+ },+ {+ actionName: "ShowLinkMap",+ defaultShortcuts: []+ },+ {+ actionName: "ShowOptions",+ defaultShortcuts: []+ },+ {+ actionName: "ShowNoteRevisions",+ defaultShortcuts: []+ },+ {+ actionName: "ShowRecentChanges",+ defaultShortcuts: []+ },+ {+ actionName: "ShowHelp",+ defaultShortcuts: ["F1"]+ },{actionName: "CreateNoteAfter",defaultShortcuts: ["Mod+O"]@@ -51,10 +100,6 @@ const DEFAULT_KEYBOARD_ACTIONS = [actionName: "CollapseTree",defaultShortcuts: ["Alt+C"]},- {- actionName: "RunSQL",- defaultShortcuts: ["Mod+return"]- },{actionName: "FocusNote",defaultShortcuts: ["return"]@@ -65,31 +110,41 @@ const DEFAULT_KEYBOARD_ACTIONS = [},{actionName: "ClipboardCopy",- defaultShortcuts: ["Mod+C"]+ defaultShortcuts: ["Mod+C"],+ description: "Copy selected notes to the clipboard"},{actionName: "ClipboardPaste",- defaultShortcuts: ["Mod+V"]+ defaultShortcuts: ["Mod+V"],+ description: "Paste notes from the clipboard into active note"},{actionName: "ClipboardCut",- defaultShortcuts: ["Mod+X"]+ defaultShortcuts: ["Mod+X"],+ description: "Copy selected notes to the clipboard"},{actionName: "SelectAllNotesInParent",- defaultShortcuts: ["Mod+A"]+ defaultShortcuts: ["Mod+A"],+ description: "Select all notes from the current note level"+ },+ {+ separator: "Text note operations"},{actionName: "Undo",- defaultShortcuts: ["Mod+Z"]+ defaultShortcuts: ["Mod+Z"],+ description: "Undo last text operation (applicable on MacOS only)"},{actionName: "Redo",- defaultShortcuts: ["Mod+Y"]+ defaultShortcuts: ["Mod+Y"],+ description: "Undo last text operation (applicable on MacOS only)"},{actionName: "AddLinkToText",- defaultShortcuts: ["Mod+L"]+ defaultShortcuts: ["Mod+L"],+ description: "Open dialog to add link to the text"},{actionName: "CloneNotesTo",@@ -103,53 +158,13 @@ const DEFAULT_KEYBOARD_ACTIONS = [actionName: "SearchNotes",defaultShortcuts: ["Mod+S"]},- {- actionName: "ShowAttributes",- defaultShortcuts: ["Alt+A"]- },- {- actionName: "ShowNoteInfo",- defaultShortcuts: []- },- {- actionName: "ShowNoteSource",- defaultShortcuts: []- },- {- actionName: "ShowLinkMap",- defaultShortcuts: []- },- {- actionName: "ShowOptions",- defaultShortcuts: []- },- {- actionName: "ShowNoteRevisions",- defaultShortcuts: []- },- {- actionName: "ShowRecentChanges",- defaultShortcuts: []- },- {- actionName: "ShowHelp",- defaultShortcuts: ["F1"]- },{actionName: "ShowSQLConsole",defaultShortcuts: ["Alt+O"]},{- actionName: "BackInNoteHistory",- defaultShortcuts: ["Alt+Left"]- },- {- actionName: "ForwardInNoteHistory",- defaultShortcuts: ["Alt+Right"]- },- {- actionName: "ToggleZenMode",- defaultShortcuts: ["Alt+M"]+ actionName: "RunSQL",+ defaultShortcuts: ["Mod+return"]},{actionName: "InsertDateTime",@@ -161,7 +176,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [},{actionName: "OpenDevTools",- defaultShortcuts: ["Mod+SHIFT+I"]+ defaultShortcuts: ["Mod+Shift+I"]},{actionName: "FindInText",@@ -171,6 +186,10 @@ const DEFAULT_KEYBOARD_ACTIONS = [actionName: "ToggleFullscreen",defaultShortcuts: ["F11"]},+ {+ actionName: "ToggleZenMode",+ defaultShortcuts: ["Alt+M"]+ },{actionName: "ZoomOut",defaultShortcuts: ["Mod+-"]@@ -178,12 +197,18 @@ const DEFAULT_KEYBOARD_ACTIONS = [{actionName: "ZoomIn",defaultShortcuts: ["Mod+="]- }+ },+ {+ actionName: "MarkdownToHTML",+ defaultShortcuts: ["Mod+Return"]+ },];if (process.platform === "darwin") {for (const action of DEFAULT_KEYBOARD_ACTIONS) {- action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Meta"));+ if (action.defaultShortcuts) {+ action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Meta"));+ }}// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376@@ -192,7 +217,9 @@ if (process.platform === "darwin") {}else {for (const action of DEFAULT_KEYBOARD_ACTIONS) {- action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Ctrl"));+ if (action.defaultShortcuts) {+ action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Ctrl"));+ }}}@@ -200,7 +227,9 @@ async function getKeyboardActions() {const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));for (const action of actions) {- action.effectiveShortcuts = action.defaultShortcuts.slice();+ if (action.defaultShortcuts) {+ action.effectiveShortcuts = action.defaultShortcuts.slice();+ }}for (const option of await optionService.getOptions()) {