AbstractFileCommandHandler
Command handler for abstract file commands.
Handles both single-file and multi-file context menus. Subclasses override canExecuteAbstractFile and executeAbstractFile.
Import:
import { AbstractFileCommandHandler } from 'obsidian-dev-utils/obsidian/command-handlers/abstract-file-command-handler';Signature:
export class AbstractFileCommandHandler extends GlobalCommandHandlerExtends: GlobalCommandHandler
Constructor
new AbstractFileCommandHandler(params: AbstractFileCommandHandlerConstructorParams)Creates a new abstract file command handler.
Methods
| Method | Returns | Description |
|---|---|---|
| buildCommand() | Command | Builds a plain Obsidian Command object with a checkCallback.(Inherited from GlobalCommandHandler) |
| canExecute() | boolean | Checks whether the command can execute from the command palette. Uses the active file as the target. |
| canExecuteAbstractFile(_abstractFile) | boolean | Checks whether the command can execute for a single abstract file. |
| canExecuteAbstractFiles(abstractFiles) | boolean | Checks whether the command can execute for multiple abstract files. Default implementation checks each file individually. |
| execute() | Promisable<void> | Executes the command from the command palette using the active file. |
| executeAbstractFile(abstractFile) | Promisable<void> | Executes the command for a single abstract file. |
| executeAbstractFiles(abstractFiles) | Promisable<void> | Executes the command for multiple abstract files. Default implementation executes sequentially. |
| getActiveFile() | null | TAbstractFile | Gets the active file, if any, to use as the target when executing from the command palette. |
| onRegistered(context) | Promise<void> | Registers file-menu and files-menu event handlers. |
| shouldAddCommandToSubmenu() | boolean | undefined | Gets whether to add the command to a submenu. |
| shouldAddToAbstractFileMenu(params) | boolean | Checks whether the command should appear in the single-file context menu. |
| shouldAddToAbstractFilesMenu(params) | boolean | Checks whether the command should appear in the multi-file context menu. Default implementation checks each file individually. |
| shouldAddToCommandPalette() | boolean | Checks whether the command should appear in the command palette. |
Links to this page: