1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Desktop: Fix issue that was preventing editor context menu from being refreshed (#4303)

This commit is contained in:
Caleb John
2021-01-08 09:35:23 -07:00
committed by GitHub
parent 4a0fb124a7
commit c484c88715
18 changed files with 202 additions and 82 deletions

View File

@ -33,30 +33,6 @@ export default class ToolbarButtonUtils {
return this.service_;
}
// Editor commands will focus the editor after they're executed
private isEditorCommand(commandName: string) {
return (commandName.indexOf('editor.') === 0 ||
// These commands are grandfathered in, but in the future
// all editor commands should start with "editor."
// WARNING: Some commands such as textLink are not defined here
// because they are more complex and handle focus manually
commandName === 'textCopy' ||
commandName === 'textCut' ||
commandName === 'textPaste' ||
commandName === 'textSelectAll' ||
commandName === 'textBold' ||
commandName === 'textItalic' ||
commandName === 'textCode' ||
commandName === 'attachFile' ||
commandName === 'textNumberedList' ||
commandName === 'textBulletedList' ||
commandName === 'textCheckbox' ||
commandName === 'textHeading' ||
commandName === 'textHorizontalRule' ||
commandName === 'insertDateTime'
);
}
private commandToToolbarButton(commandName: string, whenClauseContext: any): ToolbarButtonInfo {
const newEnabled = this.service.isEnabled(commandName, whenClauseContext);
const newTitle = this.service.title(commandName);
@ -78,7 +54,8 @@ export default class ToolbarButtonUtils {
enabled: newEnabled,
onClick: async () => {
void this.service.execute(commandName);
if (this.isEditorCommand(commandName)) {
// WARNING: textLink is a special case because it handles it's own focus
if (CommandService.isEditorCommand(commandName) && commandName !== 'textLink') {
void this.service.execute('editor.focus');
}
},