mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
reorganization of shortcuts in the options
This commit is contained in:
@@ -33,7 +33,7 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
|
||||
}
|
||||
});
|
||||
|
||||
function setActionHandler(actionName, handler) {
|
||||
function setGlobalActionHandler(actionName, handler) {
|
||||
keyboardActionsLoaded.then(() => {
|
||||
const action = keyboardActionRepo[actionName];
|
||||
|
||||
@@ -51,6 +51,24 @@ function setActionHandler(actionName, handler) {
|
||||
});
|
||||
}
|
||||
|
||||
function setElementActionHandler($el, actionName, handler) {
|
||||
keyboardActionsLoaded.then(() => {
|
||||
const action = keyboardActionRepo[actionName];
|
||||
|
||||
if (!action) {
|
||||
throw new Error(`Cannot find keyboard action '${actionName}'`);
|
||||
}
|
||||
|
||||
// not setting action.handler since this is not global
|
||||
|
||||
for (const shortcut of action.effectiveShortcuts) {
|
||||
if (shortcut) {
|
||||
utils.bindElShortcut($el, shortcut, handler);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function triggerAction(actionName) {
|
||||
const action = getAction(actionName);
|
||||
|
||||
@@ -105,7 +123,8 @@ function updateDisplayedShortcuts($container) {
|
||||
$(() => updateDisplayedShortcuts($(document)));
|
||||
|
||||
export default {
|
||||
setActionHandler,
|
||||
setGlobalActionHandler,
|
||||
setElementActionHandler,
|
||||
triggerAction,
|
||||
getAction,
|
||||
updateDisplayedShortcuts
|
||||
|
||||
Reference in New Issue
Block a user