CommandSwitchesController
The user’s command switches, read by command handlers at menu time and written by the settings tab.
Import:
import { CommandSwitchesController } from '@mnaoumov/obsidian-lib/plugin/command-switches-controller';Signature:
export class CommandSwitchesController implements CommandSwitchesImplements: CommandSwitches
Constructor
new CommandSwitchesController(params: CommandSwitchesControllerConstructorParams)Creates the controller.
Properties
| Property | Type | Description |
|---|---|---|
| isCommandShownInMenus | (commandId: string) => boolean | Whether the user's switches let a command into the context menus. A hidden command still runs from the command palette and its hotkeys: the switches govern the menus only. (Inherited from CommandSwitches) |
| shouldAddCommandsToSubmenu | boolean | Whether the plugin's context-menu commands are grouped under one submenu entry. (Inherited from CommandSwitches) |
Methods
| Method | Returns | Description |
|---|---|---|
| getMenuCommands() | readonly MenuCommandInfo[] | The context-menu commands the switches list, in registration order. |
| hideAll() | Promise<void> | Takes every listed command out of the context menus. |
| isCommandShownInMenus(commandId) | boolean | Whether the user's switches let a command into the context menus. |
| reset() | Promise<void> | Puts every switch back on its default: every command shown, and the plugin's submenu default. |
| setCommandShownInMenus(commandId, isShown) | Promise<void> | Shows or hides one command in the context menus. |
| setShouldAddCommandsToSubmenu(shouldAddCommandsToSubmenu) | Promise<void> | Sets whether the plugin's context-menu commands are grouped under one submenu entry. |
Links to this page: