Skip to content

Build your personal knowledge base with Trilium Notes

fixes

zadam2c3f07521dd0
diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.js
index 6b1bf0103b..8c57f08c92 100644
--- a/src/public/javascripts/services/app_context.js
+++ b/src/public/javascripts/services/app_context.js
@@ -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'];
diff --git a/src/public/javascripts/services/keyboard_actions.js b/src/public/javascripts/services/keyboard_actions.js
index a4ee1defcb..8b473658af 100644
--- a/src/public/javascripts/services/keyboard_actions.js
+++ b/src/public/javascripts/services/keyboard_actions.js
@@ -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));
}
}
});
diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js
index 7fb8ce265b..f76b1dcb0b 100644
--- a/src/public/javascripts/services/utils.js
+++ b/src/public/javascripts/services/utils.js
@@ -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();
}
diff --git a/src/public/javascripts/widgets/component.js b/src/public/javascripts/widgets/component.js
index c8294cfd50..59d3fcdab0 100644
--- a/src/public/javascripts/widgets/component.js
+++ b/src/public/javascripts/widgets/component.js
@@ -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);