mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
ribbon widgets titles show associated keyboard shortcuts
This commit is contained in:
parent
b68bdc5005
commit
9ca225b40f
@ -16,6 +16,10 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
|
|||||||
return actions;
|
return actions;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function getActions() {
|
||||||
|
return await keyboardActionsLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
async function getActionsForScope(scope) {
|
async function getActionsForScope(scope) {
|
||||||
const actions = await keyboardActionsLoaded;
|
const actions = await keyboardActionsLoaded;
|
||||||
|
|
||||||
@ -115,6 +119,7 @@ export default {
|
|||||||
setElementActionHandler,
|
setElementActionHandler,
|
||||||
updateDisplayedShortcuts,
|
updateDisplayedShortcuts,
|
||||||
setupActionsForElement,
|
setupActionsForElement,
|
||||||
|
getActions,
|
||||||
getActionsForScope,
|
getActionsForScope,
|
||||||
getAction
|
getAction
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
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 = `
|
const TPL = `
|
||||||
<div class="ribbon-container">
|
<div class="ribbon-container">
|
||||||
@ -208,7 +209,8 @@ export default class RibbonContainer extends NoteContextAwareWidget {
|
|||||||
.attr('data-ribbon-component-name', ribbonWidget.name)
|
.attr('data-ribbon-component-name', ribbonWidget.name)
|
||||||
.append($('<span class="ribbon-tab-title-icon">')
|
.append($('<span class="ribbon-tab-title-icon">')
|
||||||
.addClass(ret.icon)
|
.addClass(ret.icon)
|
||||||
.attr("title", ret.title))
|
.attr("data-title", ret.title)
|
||||||
|
.attr('data-toggle-command', ribbonWidget.toggleCommand))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append($('<span class="ribbon-tab-title-label">').text(ret.title));
|
.append($('<span class="ribbon-tab-title-label">').text(ret.title));
|
||||||
|
|
||||||
@ -224,7 +226,22 @@ export default class RibbonContainer extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$tabContainer.find('.ribbon-tab-title-icon').tooltip();
|
keyboardActionsService.getActions().then(actions => {
|
||||||
|
this.$tabContainer.find('.ribbon-tab-title-icon').tooltip({
|
||||||
|
title: function() {
|
||||||
|
const toggleCommandName = $(this).attr("data-toggle-command");
|
||||||
|
const action = actions.find(act => act.actionName === toggleCommandName);
|
||||||
|
const title = $(this).attr("data-title");
|
||||||
|
|
||||||
|
if (action && action.effectiveShortcuts.length > 0) {
|
||||||
|
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (!$ribbonTabToActivate) {
|
if (!$ribbonTabToActivate) {
|
||||||
$ribbonTabToActivate = $lastActiveRibbon;
|
$ribbonTabToActivate = $lastActiveRibbon;
|
||||||
|
@ -50,6 +50,10 @@ export default class BasicPropertiesWidget extends NoteContextAwareWidget {
|
|||||||
return "basicProperties";
|
return "basicProperties";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonBasicProperties";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note && (this.note.type === 'text' || this.note.type === 'code');
|
return this.note && (this.note.type === 'text' || this.note.type === 'code');
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,10 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
|
|||||||
return "bookProperties";
|
return "bookProperties";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabBookProperties";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note && this.note.type === 'book';
|
return this.note && this.note.type === 'book';
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,10 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
return "fileProperties";
|
return "fileProperties";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabFileProperties";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note && this.note.type === 'file';
|
return this.note && this.note.type === 'file';
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,10 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
return "imageProperties";
|
return "imageProperties";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabImageProperties";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note && this.note.type === 'image';
|
return this.note && this.note.type === 'image';
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ export default class InheritedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
return "inheritedAttributes";
|
return "inheritedAttributes";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabInheritedAttributes";
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@ export default class LinkMapWidget extends NoteContextAwareWidget {
|
|||||||
return "linkMap";
|
return "linkMap";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabLinkMap";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note;
|
return this.note;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,10 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
|
|||||||
return "noteInfo";
|
return "noteInfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabNoteInfo";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note;
|
return this.note;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,10 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
|
|||||||
return "notePaths";
|
return "notePaths";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabNotePaths";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.note;
|
return this.note;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget {
|
|||||||
return "ownedAttributes";
|
return "ownedAttributes";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabOwnedAttributes";
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
return "promotedAttributes";
|
return "promotedAttributes";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabPromotedAttributes";
|
||||||
|
}
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.contentSized();
|
this.contentSized();
|
||||||
|
@ -35,6 +35,10 @@ export default class SimilarNotesWidget extends NoteContextAwareWidget {
|
|||||||
return "similarNotes";
|
return "similarNotes";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get toggleCommand() {
|
||||||
|
return "toggleRibbonTabSimilarNotes";
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return super.isEnabled()
|
return super.isEnabled()
|
||||||
&& this.note.type !== 'search'
|
&& this.note.type !== 'search'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user