mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
note can be activated through 'keyboardShortcut' label
This commit is contained in:
parent
60c3b5cccc
commit
cd139bdd76
@ -1,5 +1,6 @@
|
||||
import server from "./server.js";
|
||||
import utils from "./utils.js";
|
||||
import tree from "./tree.js";
|
||||
|
||||
class KeyboardAction {
|
||||
constructor(params) {
|
||||
@ -33,6 +34,16 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
|
||||
}
|
||||
});
|
||||
|
||||
server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => {
|
||||
for (const shortcut in shortcutForNotes) {
|
||||
utils.bindGlobalShortcut(shortcut, async () => {
|
||||
const treeService = (await import("./tree.js")).default;
|
||||
|
||||
treeService.activateNote(shortcutForNotes[shortcut]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function setGlobalActionHandler(actionName, handler) {
|
||||
keyboardActionsLoaded.then(() => {
|
||||
const action = keyboardActionRepo[actionName];
|
||||
|
@ -1,11 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const keyboardActions = require('../../services/keyboard_actions');
|
||||
const sql = require('../../services/sql');
|
||||
|
||||
async function getKeyboardActions() {
|
||||
return await keyboardActions.getKeyboardActions();
|
||||
}
|
||||
|
||||
async function getShortcutsForNotes() {
|
||||
return await sql.getMap(`
|
||||
SELECT value, noteId
|
||||
FROM attributes
|
||||
WHERE isDeleted = 0
|
||||
AND type = 'label'
|
||||
AND name = 'keyboardShortcut'`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getKeyboardActions
|
||||
getKeyboardActions,
|
||||
getShortcutsForNotes
|
||||
};
|
@ -246,6 +246,7 @@ function register(app) {
|
||||
apiRoute(GET, '/api/similar-notes/:noteId', similarNotesRoute.getSimilarNotes);
|
||||
|
||||
apiRoute(GET, '/api/keyboard-actions', keysRoute.getKeyboardActions);
|
||||
apiRoute(GET, '/api/keyboard-shortcuts-for-notes', keysRoute.getShortcutsForNotes);
|
||||
|
||||
app.use('', router);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ const BUILTIN_ATTRIBUTES = [
|
||||
{ type: 'label', name: 'readOnly' },
|
||||
{ type: 'label', name: 'cssClass' },
|
||||
{ type: 'label', name: 'iconClass' },
|
||||
{ type: 'label', name: 'keyboardShortcut' },
|
||||
{ type: 'label', name: 'run', isDangerous: true },
|
||||
{ type: 'label', name: 'customRequestHandler', isDangerous: true },
|
||||
{ type: 'label', name: 'customResourceProvider', isDangerous: true },
|
||||
|
Loading…
x
Reference in New Issue
Block a user