Skip to main content

Command

Properties

id

id: string

Globally unique ID to identify this command.

name

name: string

Human friendly name for searching.

icon

icon: string

Icon ID to be used in the toolbar.

mobileOnly

mobileOnly: boolean

repeatable

repeatable: boolean

Whether holding the hotkey should repeatedly trigger this command. Defaults to false.

callback

callback: () => any

Simple callback, triggered globally.

checkCallback

checkCallback: (checking: boolean) => boolean | void

Complex callback, overrides the simple callback. Used to "check" whether your command can be performed in the current circumstances. For example, if your command requires the active focused pane to be a MarkdownSourceView, then you should only return true if the condition is satisfied. Returning false or undefined causes the command to be hidden from the command palette.

editorCallback

editorCallback: (editor: Editor, view: MarkdownView) => any

A command callback that is only triggered when the user is in an editor. Overrides callback and checkCallback

editorCheckCallback

editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) => boolean | void

A command callback that is only triggered when the user is in an editor. Overrides editorCallback, callback and checkCallback

hotkeys

hotkeys: Hotkey[]

Sets the default hotkey. It is recommended for plugins to avoid setting default hotkeys if possible, to avoid conflicting hotkeys with one that's set by the user, even though customized hotkeys have higher priority.