Command
Properties
callback()?
optional
callback: () =>any
Simple callback, triggered globally.
Returns
any
Example
checkCallback()?
optional
checkCallback: (checking
) =>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 MarkdownView, 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.
Parameters
• checking: boolean
Whether the command palette is just ‘checking’ if your command should show right now. If checking is true, then this function should not perform any action. If checking is false, then this function should perform the action.
Returns
boolean
| void
Whether this command can be executed at the moment.
Example
editorCallback()?
optional
editorCallback: (editor
,ctx
) =>any
A command callback that is only triggered when the user is in an editor.
Overrides callback
and checkCallback
Parameters
• editor: Editor
• ctx: MarkdownView
| MarkdownFileInfo
Returns
any
Example
editorCheckCallback()?
optional
editorCheckCallback: (checking
,editor
,ctx
) =>boolean
|void
A command callback that is only triggered when the user is in an editor.
Overrides editorCallback
, callback
and checkCallback
Parameters
• checking: boolean
• editor: Editor
• ctx: MarkdownView
| MarkdownFileInfo
Returns
boolean
| void
Example
hotkeys?
optional
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.
icon?
optional
icon:string
Icon ID to be used in the toolbar. See https://docs.obsidian.md/Plugins/User+interface/Icons for available icons and how to add your own.
id
id:
string
Globally unique ID to identify this command.
mobileOnly?
optional
mobileOnly:boolean
name
name:
string
Human friendly name for searching.
repeatable?
optional
repeatable:boolean
Whether holding the hotkey should repeatedly trigger this command.