Skip to content

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 CommandSwitches

Implements: CommandSwitches

Constructor

new CommandSwitchesController(params: CommandSwitchesControllerConstructorParams)

Creates the controller.

Properties

PropertyTypeDescription
isCommandShownInMenus(commandId: string) => booleanWhether 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)
shouldAddCommandsToSubmenubooleanWhether the plugin's context-menu commands are grouped under one submenu entry.
(Inherited from CommandSwitches)

Methods

MethodReturnsDescription
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)booleanWhether 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: