shortcuts WIP

This commit is contained in:
zadam
2019-11-19 20:53:04 +01:00
parent 0ae9c8da17
commit 4bd7438fca
12 changed files with 160 additions and 63 deletions

View File

@@ -4,6 +4,7 @@ import zoomService from "./zoom.js";
import protectedSessionService from "./protected_session.js";
import searchNotesService from "./search_notes.js";
import treeService from "./tree.js";
import server from "./server.js";
const NOTE_REVISIONS = "../dialogs/note_revisions.js";
const OPTIONS = "../dialogs/options.js";
@@ -208,6 +209,43 @@ function registerEntrypoints() {
}
class KeyboardAction {
constructor(params) {
/** @property {string} */
this.optionName = params.optionName;
/** @property {string[]} */
this.defaultShortcuts = Array.isArray(params.defaultShortcuts) ? params.defaultShortcuts : [params.defaultShortcuts];
/** @property {string[]} */
this.activeShortcuts = this.defaultShortcuts.slice();
/** @property {string} */
this.description = params.description;
}
addShortcut(shortcut) {
this.activeShortcuts.push(shortcut);
}
/**
* @param {string|string[]} shortcuts
*/
replaceShortcuts(shortcuts) {
this.activeShortcuts = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
}
/** @return {KeyboardAction[]} */
static get allActions() {
return Object.keys(KeyboardAction)
.map(key => KeyboardAction[key])
.filter(obj => obj instanceof KeyboardAction);
}
}
server.get('keyboard-actions').then(actions => {
for (const action of actions) {
}
});
export default {
registerEntrypoints
}