Command
Interface: Command
Section titled “Interface: Command”Defined in: command.svelte.ts:21
Properties
Section titled “Properties”activationEvent?
Section titled “activationEvent?”
optionalactivationEvent?:string
Defined in: command.svelte.ts:63
Activation event used to wake deferred command implementations.
argumentSchema?
Section titled “argumentSchema?”
optionalargumentSchema?:Record<string,unknown>
Defined in: command.svelte.ts:69
Optional structured argument schema for declarative callers.
callback?
Section titled “callback?”
optionalcallback?: (…args) =>any
Defined in: command.svelte.ts:103
Simple callback, triggered globally.
Parameters
Section titled “Parameters”…any[]
Returns
Section titled “Returns”any
Example
Section titled “Example” this.addCommand({ id: 'print-greeting-to-console', name: 'Print greeting to console', callback: () => { console.log('Hey, you!'); }, }); ```;
***
### category?
> `optional` **category?**: `string`
Defined in: [command.svelte.ts:45](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L45)
Optional command category used by declarative contribution surfaces.
***
### checkCallback?
> `optional` **checkCallback?**: (`checking`) => `boolean` \| `void`
Defined in: [command.svelte.ts:139](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L139)
Complex callback, overrides the simple callback. Used to 'check' whetheryour command can be performed in the current circumstances. For example, ifyour command requires the active focused pane to be a MarkdownView, thenyou should only return true if the condition is satisfied. Returning falseor 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
```ts this.addCommand({ id: 'example-command', name: 'Example command', checkCallback: (checking: boolean) => { const value = getRequiredValue();
if (value) { if (!checking) { doCommand(value); } return true; }
return false; } }); ```;
***
### editorCallback?
> `optional` **editorCallback?**: (`editor`, `ctx`) => `any`
Defined in: [command.svelte.ts:160](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L160)
A command callback that is only triggered when the user is in an editor.Overrides `callback` and `checkCallback`
#### Parameters
##### editor
[`Editor`](../class-docs/Editor.md)
##### ctx
`any`
#### Returns
`any`
#### Example
```ts this.addCommand({ id: 'example-command', name: 'Example command', editorCallback: (editor: Editor, view: MarkdownView) => { const sel = editor.getSelection();
console.log(`You have selected: ${sel}`); } });editorCheckCallback?
Section titled “editorCheckCallback?”
optionaleditorCheckCallback?: (checking,editor,ctx) =>boolean|void
Defined in: command.svelte.ts:189
A command callback that is only triggered when the user is in an editor.
Overrides editorCallback, callback and checkCallback
Parameters
Section titled “Parameters”checking
Section titled “checking”boolean
editor
Section titled “editor”any
Returns
Section titled “Returns”boolean | void
Example
Section titled “Example” this.addCommand({ id: 'example-command', name: 'Example command', editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) => { const value = getRequiredValue();
if (value) { if (!checking) { doCommand(value); }
return true; }
return false; } }); ```;
***
### hotkeys?
> `optional` **hotkeys?**: [`Hotkey`](Hotkey.md)[]
Defined in: [command.svelte.ts:202](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L202)
Sets the default hotkey. It is recommended for plugins to avoid settingdefault hotkeys if possible, to avoid conflicting hotkeys with one that'sset by the user, even though customized hotkeys have higher priority.
***
### icon?
> `optional` **icon?**: `string`
Defined in: [command.svelte.ts:51](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L51)
Icon ID to be used in the toolbar.
***
### id
> **id**: `string`
Defined in: [command.svelte.ts:27](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L27)
Globally unique ID to identify this command.
***
### mobileOnly?
> `optional` **mobileOnly?**: `boolean`
Defined in: [command.svelte.ts:78](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L78)
***
### name
> **name**: `string`
Defined in: [command.svelte.ts:33](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L33)
Human friendly name for searching.
***
### repeatable?
> `optional` **repeatable?**: `boolean`
Defined in: [command.svelte.ts:85](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/command.svelte.ts#L85)
Whether holding the hotkey should repeatedly trigger this command.
#### Default Value
```tsfalse@publicsourcePlugin?
Section titled “sourcePlugin?”
optionalsourcePlugin?:string
Defined in: command.svelte.ts:57
Plugin ID that owns this command.
title?
Section titled “title?”
optionaltitle?:string
Defined in: command.svelte.ts:39
Human-friendly command title without source prefixes.
optionalwhen?:string
Defined in: command.svelte.ts:76
Declarative context expression that must evaluate truthy before the command is visible or executable.