FileCommandHandler
Command handler for file-specific commands.
Filters abstract files to only accept TFile instances. Subclasses override canExecuteFile and executeFile.
Import:
import { FileCommandHandler } from 'obsidian-dev-utils/obsidian/command-handlers/file-command-handler';Signature:
export class FileCommandHandler extends AbstractFileCommandHandlerExtends: AbstractFileCommandHandler
Constructor
new FileCommandHandler(params: AbstractFileCommandHandlerConstructorParams)Creates a new file command handler.
Methods
| Method | Returns | Description |
|---|---|---|
| buildCommand() | Command | Builds a plain Obsidian Command object with a checkCallback.(Inherited from AbstractFileCommandHandler) |
| canExecute() | boolean | Checks whether the command can execute from the command palette. Uses the active file as the target. (Inherited from AbstractFileCommandHandler) |
| canExecuteAbstractFile(abstractFile) | boolean | Filters to only accept TFile instances, then delegates to canExecuteFile. |
| canExecuteAbstractFile(_abstractFile) | boolean | Checks whether the command can execute for a single abstract file. (Inherited from AbstractFileCommandHandler) |
| canExecuteAbstractFiles(abstractFiles) | boolean | Filters to only accept TFile arrays, then delegates to canExecuteFiles. |
| canExecuteFile(_file) | boolean | Checks whether the command can execute for a single file. |
| canExecuteFiles(files) | boolean | Checks whether the command can execute for multiple files. Default implementation checks each file individually. |
| execute() | Promisable<void> | Executes the command from the command palette using the active file. (Inherited from AbstractFileCommandHandler) |
| executeAbstractFile(abstractFile) | Promisable<void> | Delegates to executeFile. |
| executeAbstractFiles(abstractFiles) | Promisable<void> | Delegates to executeFiles. |
| executeFile(file) | Promisable<void> | Executes the command for a single file. |
| executeFiles(files) | Promisable<void> | Executes the command for multiple 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. (Inherited from AbstractFileCommandHandler) |
| onRegistered(context) | Promise<void> | Registers file-menu and files-menu event handlers. (Inherited from AbstractFileCommandHandler) |
| shouldAddCommandToSubmenu() | boolean | undefined | Gets whether to add the command to a submenu. (Inherited from AbstractFileCommandHandler) |
| shouldAddToAbstractFileMenu(params) | boolean | Filters to only show menu for TFile instances. |
| shouldAddToAbstractFilesMenu(params) | boolean | Filters to only show menu for TFile arrays. |
| shouldAddToCommandPalette() | boolean | Checks whether the command should appear in the command palette. (Inherited from AbstractFileCommandHandler) |
| shouldAddToFileMenu(params) | boolean | Checks whether the command should appear in the single-file context menu. |
| shouldAddToFilesMenu(params) | boolean | Checks whether the command should appear in the multi-file context menu. |