Desktop: Handle case where a command is sent to an editor that is gone

pull/4306/head
Laurent Cozic 2021-01-07 22:03:13 +00:00
parent df3e6a6219
commit ccf5271584
1 changed files with 5 additions and 0 deletions

View File

@ -25,6 +25,11 @@ interface HookDependencies {
function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, setFormNote: Function): CommandRuntime {
return {
execute: async (_context: CommandContext, ...args: any[]) => {
if (!editorRef.current) {
reg.logger().warn('Received command, but editor is gone', declaration.name);
return;
}
if (!editorRef.current.execCommand) {
reg.logger().warn('Received command, but editor cannot execute commands', declaration.name);
return;