This commit is contained in:
zadam 2020-02-16 11:22:37 +01:00
parent e06f3ef97e
commit 2c3f07521d
4 changed files with 9 additions and 8 deletions

View file

@ -98,7 +98,7 @@ class AppContext {
this.trigger('treeCacheReloaded');
}
async triggerCommand(name, data) {
async triggerCommand(name, data = {}) {
for (const executor of this.executors) {
const fun = executor[name + 'Command'];

View file

@ -35,9 +35,8 @@ async function setupActionsForElement(scope, $el, component) {
getActionsForScope("window").then(actions => {
for (const action of actions) {
for (const shortcut of action.effectiveShortcuts) {
// empty object param so that destructuring with optional params work
utils.bindGlobalShortcut(shortcut, () => appContext.trigger(action.actionName, {}));
for (const shortcut of action.effectiveShortcuts) {console.log(`Binding ${shortcut} for ${action.actionName}`);
utils.bindGlobalShortcut(shortcut, () => appContext.triggerCommand(action.actionName));
}
}
});

View file

@ -227,9 +227,11 @@ function focusSavedElement() {
if ($lastFocusedElement.hasClass("ck")) {
// must handle CKEditor separately because of this bug: https://github.com/ckeditor/ckeditor5/issues/607
import("./note_detail.js").then(noteDetail => {
noteDetail.default.getActiveEditor().editing.view.focus();
});
const editor = $lastFocusedElement
.closest('.ck-editor__editable')
.prop('ckeditorInstance');
editor.editing.view.focus();
} else {
$lastFocusedElement.focus();
}

View file

@ -52,7 +52,7 @@ export default class Component {
await Promise.all(promises);
}
async triggerCommand(name, data) {
async triggerCommand(name, data = {}) {
const fun = this[name + 'Command'];
const called = await this.callMethod(fun, data);