You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-06 09:19:22 +02:00
Desktop: Clarifies labels of certain actions, and added shortcut for note list toggle
This commit is contained in:
@@ -13,8 +13,19 @@ export interface CommandRuntime {
|
||||
|
||||
export interface CommandDeclaration {
|
||||
name: string
|
||||
|
||||
// Used for the menu item label, and toolbar button tooltip
|
||||
label?():string,
|
||||
|
||||
// This is a bit of a hack because some labels don't make much sense in isolation. For example,
|
||||
// the commmand to focus the note list is called just "Note list". This makes sense within the menu
|
||||
// but not so much within the keymap config screen, where the parent item is not displayed. Because
|
||||
// of this we have this "parentLabel()" property to clarify the meaning of the certain items.
|
||||
// For example, the focusElementNoteList will have these two properties:
|
||||
// label() => _('Note list'),
|
||||
// parentLabel() => _('Focus'),
|
||||
// Which will be displayed as "Focus: Note list" in the keymap config screen.
|
||||
parentLabel?():string,
|
||||
iconName?: string,
|
||||
// Same as `role` key in Electron MenuItem:
|
||||
// https://www.electronjs.org/docs/api/menu-item#new-menuitemoptions
|
||||
@@ -249,10 +260,13 @@ export default class CommandService extends BaseService {
|
||||
return command.runtime.title(command.runtime.props);
|
||||
}
|
||||
|
||||
label(commandName:string):string {
|
||||
label(commandName:string, fullLabel:boolean = false):string {
|
||||
const command = this.commandByName(commandName);
|
||||
if (!command) throw new Error(`Command: ${commandName} is not declared`);
|
||||
return command.declaration.label();
|
||||
const output = [];
|
||||
if (fullLabel && command.declaration.parentLabel && command.declaration.parentLabel()) output.push(command.declaration.parentLabel());
|
||||
output.push(command.declaration.label());
|
||||
return output.join(': ');
|
||||
}
|
||||
|
||||
exists(commandName:string):boolean {
|
||||
@@ -271,7 +285,7 @@ export default class CommandService extends BaseService {
|
||||
const command = this.commandByName(commandName, { runtimeMustBeRegistered: true });
|
||||
|
||||
return {
|
||||
tooltip: command.declaration.label(),
|
||||
tooltip: this.label(commandName),
|
||||
iconName: command.declaration.iconName,
|
||||
enabled: this.isEnabled(commandName),
|
||||
onClick: () => {
|
||||
@@ -286,7 +300,7 @@ export default class CommandService extends BaseService {
|
||||
|
||||
const item:any = {
|
||||
id: command.declaration.name,
|
||||
label: command.declaration.label(),
|
||||
label: this.label(commandName),
|
||||
click: () => {
|
||||
this.execute(commandName, this.extractExecuteArgs(command, executeArgs));
|
||||
},
|
||||
|
||||
@@ -38,6 +38,7 @@ const defaultKeymapItems = {
|
||||
{ accelerator: 'Shift+Cmd+N', command: 'focusElementNoteTitle' },
|
||||
{ accelerator: 'Shift+Cmd+B', command: 'focusElementNoteBody' },
|
||||
{ accelerator: 'Option+Cmd+S', command: 'toggleSidebar' },
|
||||
{ accelerator: 'Option+Cmd+L', command: 'toggleNoteList' },
|
||||
{ accelerator: 'Cmd+L', command: 'toggleVisiblePanes' },
|
||||
{ accelerator: 'Cmd+0', command: 'zoomActualSize' },
|
||||
{ accelerator: 'Cmd+E', command: 'startExternalEditing' },
|
||||
@@ -68,6 +69,7 @@ const defaultKeymapItems = {
|
||||
{ accelerator: 'Ctrl+Shift+N', command: 'focusElementNoteTitle' },
|
||||
{ accelerator: 'Ctrl+Shift+B', command: 'focusElementNoteBody' },
|
||||
{ accelerator: 'F10', command: 'toggleSidebar' },
|
||||
{ accelerator: 'F11', command: 'toggleNoteList' },
|
||||
{ accelerator: 'Ctrl+L', command: 'toggleVisiblePanes' },
|
||||
{ accelerator: 'Ctrl+0', command: 'zoomActualSize' },
|
||||
{ accelerator: 'Ctrl+E', command: 'startExternalEditing' },
|
||||
|
||||
Reference in New Issue
Block a user