mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
separators and fixes
This commit is contained in:
parent
5fac2c7633
commit
587134c2f8
@ -35,8 +35,17 @@ export default class KeyboardShortcutsOptions {
|
|||||||
|
|
||||||
server.get('keyboard-actions').then(actions => {
|
server.get('keyboard-actions').then(actions => {
|
||||||
for (const action of actions) {
|
for (const action of actions) {
|
||||||
const $tr = $("<tr>")
|
const $tr = $("<tr>");
|
||||||
.append($("<td>").text(action.actionName))
|
|
||||||
|
if (action.separator) {
|
||||||
|
$tr.append(
|
||||||
|
$('<td colspan="4">')
|
||||||
|
.attr("style","background-color: var(--accented-background-color); font-weight: bold;")
|
||||||
|
.text(action.separator)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tr.append($("<td>").text(action.actionName))
|
||||||
.append($("<td>").append(
|
.append($("<td>").append(
|
||||||
$(`<input type="text" class="form-control">`)
|
$(`<input type="text" class="form-control">`)
|
||||||
.val(action.effectiveShortcuts.join(", "))
|
.val(action.effectiveShortcuts.join(", "))
|
||||||
@ -46,6 +55,7 @@ export default class KeyboardShortcutsOptions {
|
|||||||
)
|
)
|
||||||
.append($("<td>").text(action.defaultShortcuts.join(", ")))
|
.append($("<td>").text(action.defaultShortcuts.join(", ")))
|
||||||
.append($("<td>").text(action.description));
|
.append($("<td>").text(action.description));
|
||||||
|
}
|
||||||
|
|
||||||
$table.append($tr);
|
$table.append($tr);
|
||||||
}
|
}
|
||||||
@ -57,7 +67,8 @@ export default class KeyboardShortcutsOptions {
|
|||||||
const shortcuts = $input.val()
|
const shortcuts = $input.val()
|
||||||
.replace('+,', "+Comma")
|
.replace('+,', "+Comma")
|
||||||
.split(",")
|
.split(",")
|
||||||
.map(shortcut => shortcut.replace("+Comma", "+,"));
|
.map(shortcut => shortcut.replace("+Comma", "+,"))
|
||||||
|
.filter(shortcut => !!shortcut);
|
||||||
|
|
||||||
const opts = {};
|
const opts = {};
|
||||||
opts['keyboardShortcuts' + actionName] = JSON.stringify(shortcuts);
|
opts['keyboardShortcuts' + actionName] = JSON.stringify(shortcuts);
|
||||||
|
@ -259,8 +259,10 @@ function setActionHandler(actionName, handler) {
|
|||||||
action.handler = handler;
|
action.handler = handler;
|
||||||
|
|
||||||
for (const shortcut of action.effectiveShortcuts) {
|
for (const shortcut of action.effectiveShortcuts) {
|
||||||
|
if (shortcut) {
|
||||||
utils.bindGlobalShortcut(shortcut, handler);
|
utils.bindGlobalShortcut(shortcut, handler);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,26 @@ const log = require('./log');
|
|||||||
const ELECTRON = "electron";
|
const ELECTRON = "electron";
|
||||||
|
|
||||||
const DEFAULT_KEYBOARD_ACTIONS = [
|
const DEFAULT_KEYBOARD_ACTIONS = [
|
||||||
|
{
|
||||||
|
separator: "Note navigation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "BackInNoteHistory",
|
||||||
|
defaultShortcuts: ["Alt+Left"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "ForwardInNoteHistory",
|
||||||
|
defaultShortcuts: ["Alt+Right"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
actionName: "JumpToNote",
|
actionName: "JumpToNote",
|
||||||
defaultShortcuts: ["Mod+J"],
|
defaultShortcuts: ["Mod+J"],
|
||||||
description: 'Open "Jump to note" dialog'
|
description: 'Open "Jump to note" dialog'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
actionName: "MarkdownToHTML",
|
separator: "Tabs"
|
||||||
defaultShortcuts: ["Mod+Return"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "NewTab",
|
actionName: "NewTab",
|
||||||
@ -32,76 +44,13 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "PreviousTab",
|
actionName: "PreviousTab",
|
||||||
defaultShortcuts: ["Mod+SHIFT+Tab"],
|
defaultShortcuts: ["Mod+Shift+Tab"],
|
||||||
only: ELECTRON
|
only: ELECTRON
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
actionName: "CreateNoteAfter",
|
separator: "Dialogs"
|
||||||
defaultShortcuts: ["Mod+O"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "CreateNoteInto",
|
|
||||||
defaultShortcuts: ["Mod+P"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ScrollToActiveNote",
|
|
||||||
defaultShortcuts: ["Mod+."]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "CollapseTree",
|
|
||||||
defaultShortcuts: ["Alt+C"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "RunSQL",
|
|
||||||
defaultShortcuts: ["Mod+return"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "FocusNote",
|
|
||||||
defaultShortcuts: ["return"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "RunCurrentNote",
|
|
||||||
defaultShortcuts: ["Mod+return"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ClipboardCopy",
|
|
||||||
defaultShortcuts: ["Mod+C"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ClipboardPaste",
|
|
||||||
defaultShortcuts: ["Mod+V"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ClipboardCut",
|
|
||||||
defaultShortcuts: ["Mod+X"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "SelectAllNotesInParent",
|
|
||||||
defaultShortcuts: ["Mod+A"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "Undo",
|
|
||||||
defaultShortcuts: ["Mod+Z"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "Redo",
|
|
||||||
defaultShortcuts: ["Mod+Y"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "AddLinkToText",
|
|
||||||
defaultShortcuts: ["Mod+L"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "CloneNotesTo",
|
|
||||||
defaultShortcuts: ["Mod+Shift+C"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "MoveNotesTo",
|
|
||||||
defaultShortcuts: ["Mod+Shift+C"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "SearchNotes",
|
|
||||||
defaultShortcuts: ["Mod+S"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "ShowAttributes",
|
actionName: "ShowAttributes",
|
||||||
@ -135,21 +84,87 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
actionName: "ShowHelp",
|
actionName: "ShowHelp",
|
||||||
defaultShortcuts: ["F1"]
|
defaultShortcuts: ["F1"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
actionName: "CreateNoteAfter",
|
||||||
|
defaultShortcuts: ["Mod+O"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "CreateNoteInto",
|
||||||
|
defaultShortcuts: ["Mod+P"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "ScrollToActiveNote",
|
||||||
|
defaultShortcuts: ["Mod+."]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "CollapseTree",
|
||||||
|
defaultShortcuts: ["Alt+C"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "FocusNote",
|
||||||
|
defaultShortcuts: ["return"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "RunCurrentNote",
|
||||||
|
defaultShortcuts: ["Mod+return"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "ClipboardCopy",
|
||||||
|
defaultShortcuts: ["Mod+C"],
|
||||||
|
description: "Copy selected notes to the clipboard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "ClipboardPaste",
|
||||||
|
defaultShortcuts: ["Mod+V"],
|
||||||
|
description: "Paste notes from the clipboard into active note"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "ClipboardCut",
|
||||||
|
defaultShortcuts: ["Mod+X"],
|
||||||
|
description: "Copy selected notes to the clipboard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "SelectAllNotesInParent",
|
||||||
|
defaultShortcuts: ["Mod+A"],
|
||||||
|
description: "Select all notes from the current note level"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
separator: "Text note operations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "Undo",
|
||||||
|
defaultShortcuts: ["Mod+Z"],
|
||||||
|
description: "Undo last text operation (applicable on MacOS only)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "Redo",
|
||||||
|
defaultShortcuts: ["Mod+Y"],
|
||||||
|
description: "Undo last text operation (applicable on MacOS only)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "AddLinkToText",
|
||||||
|
defaultShortcuts: ["Mod+L"],
|
||||||
|
description: "Open dialog to add link to the text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "CloneNotesTo",
|
||||||
|
defaultShortcuts: ["Mod+Shift+C"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "MoveNotesTo",
|
||||||
|
defaultShortcuts: ["Mod+Shift+C"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "SearchNotes",
|
||||||
|
defaultShortcuts: ["Mod+S"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
actionName: "ShowSQLConsole",
|
actionName: "ShowSQLConsole",
|
||||||
defaultShortcuts: ["Alt+O"]
|
defaultShortcuts: ["Alt+O"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "BackInNoteHistory",
|
actionName: "RunSQL",
|
||||||
defaultShortcuts: ["Alt+Left"]
|
defaultShortcuts: ["Mod+return"]
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ForwardInNoteHistory",
|
|
||||||
defaultShortcuts: ["Alt+Right"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
actionName: "ToggleZenMode",
|
|
||||||
defaultShortcuts: ["Alt+M"]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "InsertDateTime",
|
actionName: "InsertDateTime",
|
||||||
@ -161,7 +176,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "OpenDevTools",
|
actionName: "OpenDevTools",
|
||||||
defaultShortcuts: ["Mod+SHIFT+I"]
|
defaultShortcuts: ["Mod+Shift+I"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "FindInText",
|
actionName: "FindInText",
|
||||||
@ -171,6 +186,10 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
actionName: "ToggleFullscreen",
|
actionName: "ToggleFullscreen",
|
||||||
defaultShortcuts: ["F11"]
|
defaultShortcuts: ["F11"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
actionName: "ToggleZenMode",
|
||||||
|
defaultShortcuts: ["Alt+M"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
actionName: "ZoomOut",
|
actionName: "ZoomOut",
|
||||||
defaultShortcuts: ["Mod+-"]
|
defaultShortcuts: ["Mod+-"]
|
||||||
@ -178,13 +197,19 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
{
|
{
|
||||||
actionName: "ZoomIn",
|
actionName: "ZoomIn",
|
||||||
defaultShortcuts: ["Mod+="]
|
defaultShortcuts: ["Mod+="]
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
actionName: "MarkdownToHTML",
|
||||||
|
defaultShortcuts: ["Mod+Return"]
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||||
|
if (action.defaultShortcuts) {
|
||||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Meta"));
|
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Meta"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'BackInNoteHistory').defaultShortcuts = ["Meta+Left"];
|
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'BackInNoteHistory').defaultShortcuts = ["Meta+Left"];
|
||||||
@ -192,16 +217,20 @@ if (process.platform === "darwin") {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||||
|
if (action.defaultShortcuts) {
|
||||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Ctrl"));
|
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Ctrl"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getKeyboardActions() {
|
async function getKeyboardActions() {
|
||||||
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
|
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
|
||||||
|
|
||||||
for (const action of actions) {
|
for (const action of actions) {
|
||||||
|
if (action.defaultShortcuts) {
|
||||||
action.effectiveShortcuts = action.defaultShortcuts.slice();
|
action.effectiveShortcuts = action.defaultShortcuts.slice();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const option of await optionService.getOptions()) {
|
for (const option of await optionService.getOptions()) {
|
||||||
if (option.name.startsWith('keyboardShortcuts')) {
|
if (option.name.startsWith('keyboardShortcuts')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user