1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-10-06 22:17:10 +02:00

Desktop: Fixes #4338: Some commands were no longer working (#4343)

This commit is contained in:
Caleb John
2021-01-11 15:17:34 -07:00
committed by GitHub
parent 25341858d5
commit b7313568de
2 changed files with 19 additions and 3 deletions

View File

@@ -33,6 +33,19 @@ export default class ToolbarButtonUtils {
return this.service_;
}
private isEditorCommand(commandName: string) {
return CommandService.isEditorCommand(commandName) && !(
// These commands are attached to the editor runtime,
// but they either handle focus themselves or don't need
// to focus the editor
commandName === 'textLink' ||
commandName === 'insertText' ||
commandName === 'scrollToHash' ||
commandName === 'selectedText' ||
commandName === 'replaceSelection'
);
}
private commandToToolbarButton(commandName: string, whenClauseContext: any): ToolbarButtonInfo {
const newEnabled = this.service.isEnabled(commandName, whenClauseContext);
const newTitle = this.service.title(commandName);
@@ -54,8 +67,7 @@ export default class ToolbarButtonUtils {
enabled: newEnabled,
onClick: async () => {
void this.service.execute(commandName);
// WARNING: textLink is a special case because it handles it's own focus
if (CommandService.isEditorCommand(commandName) && commandName !== 'textLink') {
if (this.isEditorCommand(commandName)) {
void this.service.execute('editor.focus');
}
},