Command
Official
A command that can be executed from the command palette or toolbar buttons.
Import:
import type { Command } from 'obsidian';Signature:
export interface CommandProperties
| Property | Type | Description | |
|---|---|---|---|
| allowPreview? | boolean | Whether the editor command can be executed when the note is in preview mode. | |
| allowProperties? | boolean | Whether the editor command can be executed when the properties panel is shown. | |
| callback? | () => any | Simple callback, triggered globally. | |
| 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 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. | |
| editorCallback? | (editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any | A command callback that is only triggered when the user is in an editor. Overrides callback and checkCallback | |
| editorCheckCallback? | (checking: boolean, editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => boolean | void | A command callback that is only triggered when the user is in an editor. Overrides editorCallback, callback and checkCallback | |
| 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? | IconName | 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 | string | Globally unique ID to identify this command. | |
| mobileOnly? | boolean | Whether the command is only available on mobile. | |
| name | string | Human friendly name for searching. | |
| repeatable? | boolean | Whether holding the hotkey should repeatedly trigger this command. | |
| showOnMobileToolbar? | boolean | Whether the non-editor command button can be shown on the mobile toolbar. |
Links to this page:
- AudioRecorderPlugin
- BacklinkPlugin
- BasesPlugin
- BookmarksPlugin
- CanvasPlugin
- CommandPaletteModal
- CommandPalettePlugin
- CommandPalettePluginInstance
- Commands
- CommandsCommandsRecord
- CommandsEditorCommandsRecord
- DailyNotesPlugin
- EditorStatusPlugin
- FileExplorerPlugin
- FileRecoveryPlugin
- FootnotesPlugin
- GlobalSearchPlugin
- GraphPlugin
- InternalPlugin
- MarkdownImporterPlugin
- NoteComposerPlugin
- OutgoingLinkPlugin
- OutlinePlugin
- PagePreviewPlugin
- Plugin
- PropertiesPlugin
- PublishPlugin
- RandomNotePlugin
- SlashCommandPlugin
- SlidesPlugin
- SwitcherPlugin
- SyncPlugin
- TagPanePlugin
- TemplatesPlugin
- WebviewerPlugin
- WordCountPlugin
- WorkspacesPlugin
- ZkPrefixerPlugin