mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
display keyboard shortcuts in button widget title
This commit is contained in:
parent
9ca225b40f
commit
7ea72632b8
@ -1,9 +1,14 @@
|
|||||||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||||
|
import keyboardActionsService from "../../services/keyboard_actions.js";
|
||||||
|
|
||||||
const TPL = `<span class="button-widget icon-action bx"
|
const TPL = `<span class="button-widget icon-action bx"
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
title=""></span>`;
|
title=""></span>`;
|
||||||
|
|
||||||
|
let actions;
|
||||||
|
|
||||||
|
keyboardActionsService.getActions().then(as => actions = as);
|
||||||
|
|
||||||
export default class ButtonWidget extends NoteContextAwareWidget {
|
export default class ButtonWidget extends NoteContextAwareWidget {
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return true;
|
return true;
|
||||||
@ -30,7 +35,17 @@ export default class ButtonWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
this.$widget.tooltip({
|
this.$widget.tooltip({
|
||||||
html: true,
|
html: true,
|
||||||
title: () => this.settings.title,
|
title: () => {
|
||||||
|
const title = this.settings.title;
|
||||||
|
const action = actions.find(act => act.actionName === this.settings.command);
|
||||||
|
|
||||||
|
if (action && action.effectiveShortcuts.length > 0) {
|
||||||
|
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
},
|
||||||
trigger: "hover"
|
trigger: "hover"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user