Skip to content

CommandHandlerRegistrationContext

Context provided to command handlers during registration.

Import:

import type { CommandHandlerRegistrationContext } from '@mnaoumov/obsidian-lib/command-handlers/command-handler';

Signature:

export interface CommandHandlerRegistrationContext

Properties

PropertyTypeDescription
activeFileProviderActiveFileProviderProvider for accessing the currently active file.
commandSwitchesProvider?CommandSwitchesProvider | undefinedResolves the user's command switches, read at menu time rather than captured, because they are attached and detached with the settings tab component. Omitted, the handler behaves as if none were attached.
menuEventRegistrarMenuEventRegistrarRegistrar for menu event handlers.
pluginNamestringThe name of the plugin that owns this command.
shouldAddCommandToSubmenu?boolean | undefinedOverrides the handler's own shouldAddCommandToSubmenu, or undefined to leave it alone.

A menu surface that already wraps every contributed item in a plugin-titled parent entry — such as NotebookNavigatorMenuEventRegistrarComponent — sets this to false, because a handler declaring a section submenu of its own would make Menu.sort() nest a second plugin-titled entry inside the first. Only AbstractFileCommandHandler reads it: the surfaces that need it bridge file and folder menus, never the editor menu.