1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Android: Fixes #10152: Fix broken plugin API: editor.execCommand (#10153)

This commit is contained in:
Henry Heino
2024-03-20 03:58:42 -07:00
committed by GitHub
parent 32141d4e23
commit 44e8950f1b
8 changed files with 78 additions and 20 deletions

View File

@ -1,5 +1,5 @@
import CommandService, { CommandContext, CommandDeclaration } from '@joplin/lib/services/CommandService';
import { EditorControl } from '../types';
import { EditorControl } from '@joplin/editor/types';
import { useEffect } from 'react';
import commandDeclarations, { enabledCondition } from '../commandDeclarations';
import Logger from '@joplin/utils/Logger';
@ -12,9 +12,13 @@ const commandRuntime = (declaration: CommandDeclaration, editor: EditorControl)
// Many editor CodeMirror commands are missing the editor. prefix.
let commandName = declaration.name.replace(/^editor\./, '');
if (declaration.name === 'editor.execCommand') {
commandName = args[0];
args = args.slice(1);
if (commandName === 'execCommand') {
commandName = args[0]?.name;
args = args[0]?.args ?? [];
if (!commandName) {
throw new Error('editor.execCommand is missing the name of the command to execute');
}
}
if (!(await editor.supportsCommand(commandName))) {