Notes/src/routes/api/keys.js

33 lines
678 B
JavaScript
Raw Normal View History

2019-11-19 20:53:04 +01:00
"use strict";
const keyboardActions = require('../../services/keyboard_actions');
2021-12-19 10:50:38 +01:00
const becca = require('../../becca/becca');
2019-11-19 20:53:04 +01:00
2020-06-20 12:31:38 +02:00
function getKeyboardActions() {
return keyboardActions.getKeyboardActions();
2019-11-19 20:53:04 +01:00
}
2020-06-20 12:31:38 +02:00
function getShortcutsForNotes() {
2021-12-19 10:50:38 +01:00
const attrs = becca.findAttributes('label', 'keyboardShortcut');
const map = {};
for (const attr of attrs) {
2022-12-01 10:03:04 +01:00
const note = becca.getNote(attr.noteId);
if (note?.type === 'launcher') {
// launchers have different handling
continue;
}
2021-12-19 10:50:38 +01:00
map[attr.value] = attr.noteId;
}
return map;
}
2019-11-19 20:53:04 +01:00
module.exports = {
getKeyboardActions,
getShortcutsForNotes
2020-06-20 12:31:38 +02:00
};