mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
keyboard shortcuts for focusing the attributes, adding a new label and relation
This commit is contained in:
parent
0aef99b98e
commit
32c88c7481
@ -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
|
||||
};
|
||||
};
|
||||
|
@ -330,6 +330,8 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
||||
await this.triggerCommand('saveAttributes');
|
||||
|
||||
this.hide();
|
||||
|
||||
this.triggerCommand('focusOnAttributes', {tabId: this.tabContext.tabId});
|
||||
}
|
||||
|
||||
userEditedAttribute() {
|
||||
|
@ -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});
|
||||
|
@ -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"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user