mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 22:13:07 +08:00
display keyboard shortcuts in button widget title
This commit is contained in:
parent
9ca225b40f
commit
7ea72632b8
1 changed files with 16 additions and 1 deletions
|
@ -1,9 +1,14 @@
|
|||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||
import keyboardActionsService from "../../services/keyboard_actions.js";
|
||||
|
||||
const TPL = `<span class="button-widget icon-action bx"
|
||||
data-toggle="tooltip"
|
||||
title=""></span>`;
|
||||
|
||||
let actions;
|
||||
|
||||
keyboardActionsService.getActions().then(as => actions = as);
|
||||
|
||||
export default class ButtonWidget extends NoteContextAwareWidget {
|
||||
isEnabled() {
|
||||
return true;
|
||||
|
@ -30,7 +35,17 @@ export default class ButtonWidget extends NoteContextAwareWidget {
|
|||
|
||||
this.$widget.tooltip({
|
||||
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"
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue