Skip to content

FolderCommandHandler

Command handler for folder-specific commands.

Filters abstract files to only accept TFolder instances. Subclasses override canExecuteFolder and executeFolder.

Import:

import { FolderCommandHandler } from 'obsidian-dev-utils/obsidian/command-handlers/folder-command-handler';

Signature:

export class FolderCommandHandler extends AbstractFileCommandHandler

Extends: AbstractFileCommandHandler

Constructor

new FolderCommandHandler(params: AbstractFileCommandHandlerConstructorParams)

Creates a new folder command handler.

Methods

MethodReturnsDescription
buildCommand()CommandBuilds a plain Obsidian Command object with a checkCallback.
(Inherited from AbstractFileCommandHandler)
canExecute()booleanChecks whether the command can execute from the command palette. Uses the active file as the target.
(Inherited from AbstractFileCommandHandler)
canExecuteAbstractFile(abstractFile)booleanFilters to only accept TFolder instances, then delegates to canExecuteFolder.
canExecuteAbstractFile(_abstractFile)booleanChecks whether the command can execute for a single abstract file.
(Inherited from AbstractFileCommandHandler)
canExecuteAbstractFiles(abstractFiles)booleanFilters to only accept TFolder arrays, then delegates to canExecuteFolders.
canExecuteFolder(_folder)booleanChecks whether the command can execute for a single folder.
canExecuteFolders(folders)booleanChecks whether the command can execute for multiple folders. Default implementation checks each folder individually.
execute()Promisable<void>Executes the command from the command palette using the active file.
(Inherited from AbstractFileCommandHandler)
executeAbstractFile(abstractFile)Promisable<void>Delegates to executeFolder.
executeAbstractFiles(abstractFiles)Promisable<void>Delegates to executeFolders.
executeFolder(folder)Promisable<void>Executes the command for a single folder.
executeFolders(folders)Promisable<void>Executes the command for multiple folders. Default implementation executes sequentially.
getActiveFile()null | TAbstractFileGets the active folder, 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.
(Inherited from AbstractFileCommandHandler)
shouldAddCommandToSubmenu()boolean | undefinedGets whether to add the command to a submenu.
(Inherited from AbstractFileCommandHandler)
shouldAddToAbstractFileMenu(params)booleanFilters to only show menu for TFolder instances.
shouldAddToAbstractFilesMenu(params)booleanFilters to only show menu for TFolder arrays.
shouldAddToCommandPalette()booleanChecks whether the command should appear in the command palette.
(Inherited from AbstractFileCommandHandler)
shouldAddToFolderMenu(params)booleanChecks whether the command should appear in the single-folder context menu.
shouldAddToFoldersMenu(params)booleanChecks whether the command should appear in the multi-folder context menu.