mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 07:45:51 +01:00
shortcut improvements
This commit is contained in:
@@ -6,11 +6,17 @@ export default class ButtonFromNoteWidget extends ButtonWidget {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.settings.buttonNoteId = null;
|
||||
this.settings.buttonNoteIdProvider = null;
|
||||
this.settings.defaultIconProvider = null;
|
||||
}
|
||||
|
||||
buttonNoteId(noteId) {
|
||||
this.settings.buttonNoteId = noteId;
|
||||
buttonNoteIdProvider(provider) {
|
||||
this.settings.buttonNoteIdProvider = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
defaultIconProvider(provider) {
|
||||
this.settings.defaultIconProvider = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -21,18 +27,32 @@ export default class ButtonFromNoteWidget extends ButtonWidget {
|
||||
}
|
||||
|
||||
updateIcon() {
|
||||
froca.getNote(this.settings.buttonNoteId).then(note => {
|
||||
this.settings.icon = note.getLabelValue("iconClass");
|
||||
const buttonNoteId = this.settings.buttonNoteIdProvider();
|
||||
|
||||
if (!buttonNoteId && this.settings.defaultIconProvider()) {
|
||||
this.settings.icon = this.settings.defaultIconProvider();
|
||||
|
||||
this.refreshIcon();
|
||||
});
|
||||
} else {
|
||||
froca.getNote(buttonNoteId).then(note => {
|
||||
this.settings.icon = note.getIcon();
|
||||
|
||||
this.refreshIcon();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
const buttonNote = froca.getNoteFromCache(this.buttonNoteIdProvider());
|
||||
|
||||
if (!buttonNote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadResults.getAttributes(this.componentId).find(attr =>
|
||||
attr.type === 'label'
|
||||
&& attr.name === 'iconClass'
|
||||
&& attributeService.isAffecting(attr, this.note))) {
|
||||
&& attributeService.isAffecting(attr, buttonNote))) {
|
||||
|
||||
this.updateIcon();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class BackInHistoryButtonWidget extends AbstractHistoryNavigation
|
||||
.title("Go to previous note.")
|
||||
.command("backInNoteHistory")
|
||||
.titlePlacement("right")
|
||||
.buttonNoteId('lb_backinhistory')
|
||||
.buttonNoteIdProvider(() => 'lb_backinhistory')
|
||||
.onContextMenu(e => this.showContextMenu(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class ForwardInHistoryButtonWidget extends AbstractHistoryNavigat
|
||||
.title("Go to next note.")
|
||||
.command("forwardInNoteHistory")
|
||||
.titlePlacement("right")
|
||||
.buttonNoteId('lb_forwardinhistory')
|
||||
.buttonNoteIdProvider(() => 'lb_forwardinhistory')
|
||||
.onContextMenu(e => this.showContextMenu(e));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user