Skip to content

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 GlobalCommandHandler

Extends: GlobalCommandHandler

Constructor

new AbstractFileCommandHandler(params: AbstractFileCommandHandlerConstructorParams)

Creates a new abstract file command handler.

Methods

MethodReturnsDescription
buildCommand()CommandBuilds a plain Obsidian Command object with a checkCallback.
(Inherited from GlobalCommandHandler)
canExecute()booleanChecks whether the command can execute from the command palette. Uses the active file as the target.
canExecuteAbstractFile(_abstractFile)booleanChecks whether the command can execute for a single abstract file.
canExecuteAbstractFiles(abstractFiles)booleanChecks 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 | TAbstractFileGets 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 | undefinedGets whether to add the command to a submenu.
shouldAddToAbstractFileMenu(params)booleanChecks whether the command should appear in the single-file context menu.
shouldAddToAbstractFilesMenu(params)booleanChecks whether the command should appear in the multi-file context menu. Default implementation checks each file individually.
shouldAddToCommandPalette()booleanChecks whether the command should appear in the command palette.

Links to this page: