Skip to content

ModalCommandBuilder

Builds a modal’s control strip from keyboard commands, interactive checkboxes, and dropdowns, then applies them to a modal via ModalCommandBuilder.build.

Import:

import { ModalCommandBuilder } from 'obsidian-dev-utils/obsidian/modals/modal-command-builder';

Signature:

export class ModalCommandBuilder

Methods

MethodReturnsDescription
addCheckbox(command)thisAdds an interactive checkbox to the control strip, bound to a modifier+key shortcut that toggles it.
addDropDown(command)thisAdds a dropdown to the control strip, bound to a modifier+key shortcut that cycles through its options.
addKeyboardCommand(command)thisAdds a keyboard command to the control strip. When KeyboardCommand.onKey is provided, its handler is registered with the modal scope; otherwise the command is a hint only.
build(target, options?)ModalCommandsApplies the accumulated commands to a modal. Always registers the essential navigation/action key handlers; only renders the control strip and registers the option-toggle shortcuts when ModalCommandBuilderBuildOptions.shouldShowInstructions is true.

Links to this page: