Skip to content

Commands

Defined in: src/obsidian/internals/Commands/Commands.d.ts:9

Properties

app

app: App

Defined in: src/obsidian/internals/Commands/Commands.d.ts:13

Reference to App


commands

commands: CommandsCommandsRecord

Defined in: src/obsidian/internals/Commands/Commands.d.ts:20

Commands without editor callback, will always be available in the command palette

Example

`app:open-vault` or `app:reload`

editorCommands

editorCommands: CommandsEditorCommandsRecord

Defined in: src/obsidian/internals/Commands/Commands.d.ts:28

Commands with editor callback, will only be available when editor is active and callback returns true

Example

`editor:fold-all` or `command-palette:open`

Methods

addCommand()

addCommand(command): void

Defined in: src/obsidian/internals/Commands/Commands.d.ts:35

Add a command to the command registry

Parameters

command

Command

Command to add

Returns

void


executeCommand()

executeCommand(command): boolean

Defined in: src/obsidian/internals/Commands/Commands.d.ts:41

Execute a command by reference

Parameters

command

Command

Command to execute

Returns

boolean


executeCommandById()

executeCommandById(commandId): boolean

Defined in: src/obsidian/internals/Commands/Commands.d.ts:47

Execute a command by ID

Parameters

commandId

string

ID of command to execute

Returns

boolean


findCommand()

findCommand(commandId): undefined | Command

Defined in: src/obsidian/internals/Commands/Commands.d.ts:53

Find a command by ID

Parameters

commandId

string

ID of command to find

Returns

undefined | Command


listCommands()

listCommands(): Command[]

Defined in: src/obsidian/internals/Commands/Commands.d.ts:57

Lists all commands, both with and without editor callback

Returns

Command[]


removeCommand()

removeCommand(commandId): void

Defined in: src/obsidian/internals/Commands/Commands.d.ts:63

Remove a command from the command registry

Parameters

commandId

string

ID of command to remove

Returns

void