keyboard shortcuts WIP

This commit is contained in:
zadam
2019-11-19 23:02:54 +01:00
parent 4bd7438fca
commit 3c4ec7fe1a
6 changed files with 119 additions and 75 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const optionService = require('./options');
const utils = require('./utils');
const log = require('./log');
const ELECTRON = "electron";
@@ -107,12 +108,36 @@ const DEFAULT_KEYBOARD_ACTIONS = [
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: "OpenSQLConsole",
actionName: "ShowSQLConsole",
defaultShortcuts: ["alt+o"]
},
{
@@ -157,6 +182,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
}
];
if (process.platform === "darwin") {
// 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 === 'ForwardInNoteHistory').defaultShortcuts = ["meta+right"];
}
async function getKeyboardActions() {
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
@@ -183,6 +214,8 @@ async function getKeyboardActions() {
}
}
}
return actions;
}
module.exports = {

View File

@@ -102,7 +102,7 @@ async function initStartupOptions() {
function getKeyboardDefaultOptions() {
return keyboardActions.DEFAULT_KEYBOARD_ACTIONS.map(ka => {
return {
name: "keyboardShortcuts" + ka.optionName,
name: "keyboardShortcuts" + ka.actionName,
value: JSON.stringify(ka.defaultShortcuts),
isSynced: false
};