Command โ€บ editorCallback

Command.editorCallback property

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

Signature:

editorCallback?: (editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any;

Example

this.addCommand({
  id: 'example-command',
  name: 'Example command',
  editorCallback: (editor: Editor, view: MarkdownView) => {
    const sel = editor.getSelection();
 
    console.log(`You have selected: ${sel}`);
  }
});