mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
reduce flicker of "create new day note"
This commit is contained in:
@@ -1,35 +1,11 @@
|
||||
import server from "./server.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
class KeyboardAction {
|
||||
constructor(params) {
|
||||
/** @property {string} */
|
||||
this.actionName = params.actionName;
|
||||
/** @property {string[]} */
|
||||
this.defaultShortcuts = params.defaultShortcuts;
|
||||
/** @property {string[]} */
|
||||
this.effectiveShortcuts = params.effectiveShortcuts;
|
||||
/** @property {string} */
|
||||
this.description = params.description;
|
||||
}
|
||||
|
||||
addShortcut(shortcut) {
|
||||
this.effectiveShortcuts.push(shortcut);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|string[]} shortcuts
|
||||
*/
|
||||
replaceShortcuts(shortcuts) {
|
||||
this.effectiveShortcuts = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
|
||||
}
|
||||
}
|
||||
|
||||
const keyboardActionRepo = {};
|
||||
|
||||
const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
|
||||
for (const action of actions) {
|
||||
keyboardActionRepo[action.actionName] = new KeyboardAction(action);
|
||||
keyboardActionRepo[action.actionName] = action;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -54,7 +30,7 @@ function setGlobalActionHandler(actionName, handler) {
|
||||
action.handler = handler;
|
||||
|
||||
for (const shortcut of action.effectiveShortcuts) {
|
||||
if (shortcut) {
|
||||
if (shortcut && !shortcut.startsWith("global:")) { // global shortcuts should be handled in the electron code
|
||||
utils.bindGlobalShortcut(shortcut, handler);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +56,7 @@ function setElementActionHandler($el, actionName, handler) {
|
||||
}
|
||||
|
||||
async function triggerAction(actionName) {
|
||||
const action = getAction(actionName);
|
||||
const action = await getAction(actionName);
|
||||
|
||||
if (!action.handler) {
|
||||
throw new Error(`Action ${actionName} has no handler`);
|
||||
|
||||
Reference in New Issue
Block a user