Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
keyboard shortcuts for focusing the attributes, adding a new label and relation
zadam32c88c74812a
diff --git a/src/public/app/services/keyboard_actions.js b/src/public/app/services/keyboard_actions.jsindex 2eebf152c8..ab7fffbfce 100644--- a/src/public/app/services/keyboard_actions.js+++ b/src/public/app/services/keyboard_actions.js@@ -27,7 +27,7 @@ async function setupActionsForElement(scope, $el, component) {for (const action of actions) {for (const shortcut of action.effectiveShortcuts) {- utils.bindElShortcut($el, shortcut, () => component.triggerCommand(action.actionName));+ utils.bindElShortcut($el, shortcut, () => component.triggerCommand(action.actionName, {tabId: appContext.tabManager.activeTabId}));}}}@@ -35,7 +35,7 @@ async function setupActionsForElement(scope, $el, component) {getActionsForScope("window").then(actions => {for (const action of actions) {for (const shortcut of action.effectiveShortcuts) {- utils.bindGlobalShortcut(shortcut, () => appContext.triggerCommand(action.actionName));+ utils.bindGlobalShortcut(shortcut, () => appContext.triggerCommand(action.actionName, {tabId: appContext.tabManager.activeTabId}));}}});@@ -112,4 +112,4 @@ export default {updateDisplayedShortcuts,setupActionsForElement,getActionsForScope-};\ No newline at end of file+};diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.jsindex b67576a693..d018d500cb 100644--- a/src/public/app/widgets/attribute_detail.js+++ b/src/public/app/widgets/attribute_detail.js@@ -330,6 +330,8 @@ export default class AttributeDetailWidget extends TabAwareWidget {await this.triggerCommand('saveAttributes');this.hide();++ this.triggerCommand('focusOnAttributes', {tabId: this.tabContext.tabId});}userEditedAttribute() {diff --git a/src/public/app/widgets/attribute_editor.js b/src/public/app/widgets/attribute_editor.jsindex f579a22f12..9d231f59ba 100644--- a/src/public/app/widgets/attribute_editor.js+++ b/src/public/app/widgets/attribute_editor.js@@ -221,8 +221,8 @@ export default class AttributeEditorWidget extends TabAwareWidget {y: e.pageY,orientation: 'left',items: [- {title: "Add new label", command: "addNewLabel", uiIcon: "hash"},- {title: "Add new relation", command: "addNewRelation", uiIcon: "transfer"},+ {title: `Add new label <kbd data-command="addNewLabel"></kbd>`, command: "addNewLabel", uiIcon: "hash"},+ {title: `Add new relation <kbd data-command="addNewRelation"></kbd>`, command: "addNewRelation", uiIcon: "transfer"},{title: "----"},{title: "Add new label definition", command: "addNewLabelDefinition", uiIcon: "empty"},{title: "Add new relation definition", command: "addNewRelationDefinition", uiIcon: "empty"},@@ -231,6 +231,16 @@ export default class AttributeEditorWidget extends TabAwareWidget {});}+ // triggered from keyboard shortcut+ addNewLabelEvent() {+ this.handleAddNewAttributeCommand('addNewLabel');+ }++ // triggered from keyboard shortcut+ addNewRelationEvent() {+ this.handleAddNewAttributeCommand('addNewRelation');+ }+async handleAddNewAttributeCommand(command) {const attrs = this.parseAttributes();@@ -466,6 +476,10 @@ export default class AttributeEditorWidget extends TabAwareWidget {if (this.tabContext.tabId === tabId) {if (this.$editor.is(":visible")) {this.$editor.trigger('focus');++ this.textEditor.model.change(writer => { // put focus to the end of the content+ writer.setSelection(writer.createPositionAt(this.textEditor.model.document.getRoot(), 'end'));+ });}else {this.triggerCommand('focusOnDetail', {tabId: this.tabContext.tabId});diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.jsindex cbbd064742..82c9104e16 100644--- a/src/services/keyboard_actions.js+++ b/src/services/keyboard_actions.js@@ -224,12 +224,6 @@ const DEFAULT_KEYBOARD_ACTIONS = [{separator: "Dialogs"},- { // FIXME- actionName: "showAttributes",- defaultShortcuts: ["Alt+A"],- description: "Shows Attributes",- scope: "window"- },{actionName: "showNoteInfo",defaultShortcuts: [],@@ -314,6 +308,29 @@ const DEFAULT_KEYBOARD_ACTIONS = [scope: "text-detail"},+ {+ separator: "Attributes (labels & relations)"+ },++ {+ actionName: "focusOnAttributes",+ defaultShortcuts: ["Alt+A"],+ description: "Put focus into attribute editor",+ scope: "window"+ },+ {+ actionName: "addNewLabel",+ defaultShortcuts: ["Alt+L"],+ description: "Create new label",+ scope: "window"+ },+ {+ actionName: "addNewRelation",+ defaultShortcuts: ["Alt+R"],+ description: "Create new relation",+ scope: "window"+ },+{separator: "Other"},