Skip to content

EditorCommandHandler

Command handler for editor commands.

Subclasses override canExecuteEditor and executeEditor to provide behavior. Optionally integrates with the editor context menu via shouldAddToEditorMenu.

Import:

import { EditorCommandHandler } from 'obsidian-dev-utils/obsidian/command-handlers/editor-command-handler';

Signature:

export class EditorCommandHandler extends CommandHandler

Extends: CommandHandler

Constructor

new EditorCommandHandler(params: EditorCommandHandlerConstructorParams)

Creates a new editor command handler.

Properties

PropertyTypeDescription
iconIconNameThe icon for the command.
(Inherited from CommandHandler)
idstringThe ID of the command.
(Inherited from CommandHandler)
namestringThe display name of the command.
(Inherited from CommandHandler)

Methods

MethodReturnsDescription
buildCommand()CommandBuilds a plain Obsidian Command object with an editorCheckCallback.
canExecuteEditor(_editor, _ctx)booleanChecks whether the command can execute for the given editor and context.
executeEditor(editor, ctx)Promisable<void>Executes the command for the given editor and context.
onRegistered(context)Promise<void>Registers the editor-menu event handler.
shouldAddCommandToSubmenu()boolean | undefinedGets whether to add the command to a submenu.
shouldAddToCommandPalette()booleanChecks whether the command should appear in the command palette.
shouldAddToEditorMenu(_editor, _ctx)booleanChecks whether the command should appear in the editor context menu.