mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
keyboard shortcuts for focusing the attributes, adding a new label and relation
This commit is contained in:
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user