1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

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

This commit is contained in:
Laurent Cozic 2021-01-07 22:03:13 +00:00
parent df3e6a6219
commit ccf5271584

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;