obsidian/modals/suggest-modal-command-builder
A builder for a SuggestModal’s instruction bar.
SuggestModalCommandBuilder assembles the instruction bar shown at the bottom of a SuggestModal: keyboard-command hints (SuggestModalCommandBuilder.addKeyboardCommand), interactive checkboxes bound to a modifier+key shortcut (SuggestModalCommandBuilder.addCheckbox), and dropdowns bound to a modifier+key shortcut (SuggestModalCommandBuilder.addDropDown). Chain the add* calls, then apply everything to a modal with SuggestModalCommandBuilder.build:
new SuggestModalCommandBuilder() .addKeyboardCommand({ key: 'Enter', modifiers: ['Mod'], onKey, purpose: 'to create' }) .addCheckbox({ key: '1', modifiers: ['Alt'], onChange, onInit, purpose: 'Fix footnotes' }) .build(modal);SuggestModalCommandBuilder.build always registers the essential navigation/action key handlers, but only renders the instruction UI and registers the option-toggle shortcuts when SuggestModalCommandBuilderBuildOptions.shouldShowInstructions is true (the default).
Classes
Section titled “Classes”| Class | Description |
|---|---|
| SuggestModalCommandBuilder | Builds a SuggestModal’s instruction bar from keyboard commands, interactive checkboxes, and dropdowns, then applies them to a modal via SuggestModalCommandBuilder.build. |
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| CheckboxCommand | A checkbox command shown in a SuggestModal’s instruction bar and bound to a modifier+key shortcut that toggles it. |
| DropDownCommand | A dropdown command shown in a SuggestModal’s instruction bar and bound to a modifier+key shortcut that cycles through its options. |
| KeyboardCommand | A keyboard command shown in a SuggestModal’s instruction bar and optionally bound to a modifier+key handler. |
| SuggestModalCommandBuilderBuildOptions | Options for SuggestModalCommandBuilder.build. |