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 CommandHandlerExtends: CommandHandler
Constructor
new EditorCommandHandler(params: EditorCommandHandlerConstructorParams)Creates a new editor command handler.
Properties
| Property | Type | Description |
|---|---|---|
| icon | IconName | The icon for the command. (Inherited from CommandHandler) |
| id | string | The ID of the command. (Inherited from CommandHandler) |
| name | string | The display name of the command. (Inherited from CommandHandler) |
Methods
| Method | Returns | Description |
|---|---|---|
| buildCommand() | Command | Builds a plain Obsidian Command object with an editorCheckCallback. |
| canExecuteEditor(_editor, _ctx) | boolean | Checks 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 | undefined | Gets whether to add the command to a submenu. |
| shouldAddToCommandPalette() | boolean | Checks whether the command should appear in the command palette. |
| shouldAddToEditorMenu(_editor, _ctx) | boolean | Checks whether the command should appear in the editor context menu. |