Command โ€บ editorCheckCallback

Command.editorCheckCallback property

A command callback that is only triggered when the user is in an editor. Overrides editorCallback, callback and checkCallback

Signature:

editorCheckCallback?: (checking: boolean, editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => boolean | void;

Example

this.addCommand({
  id: 'example-command',
  name: 'Example command',
  editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) => {
    const value = getRequiredValue();
 
    if (value) {
      if (!checking) {
        doCommand(value);
      }
 
      return true;
    }
 
    return false;
  }
});