Documentation / joplin-plugin-api / Command
Interface: Command
Defined in: types.ts:7
Properties
enabledCondition?
optional
enabledCondition:string
Defined in: types.ts:58
Defines whether the command should be enabled or disabled, which in turns affects the enabled state of any associated button or menu item.
The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to true
or false
. It supports the following operators:
Operator | Symbol | Example |
---|---|---|
Equality | == | "editorType == markdown" |
Inequality | != | "currentScreen != config" |
Or | || | "noteIsTodo || noteTodoCompleted" |
And | && | "oneNoteSelected && !inConflictFolder" |
Joplin, unlike VSCode, also supports parentheses, which allows creating more complex expressions such as cond1 || (cond2 && cond3)
. Only one level of parentheses is possible (nested ones aren't supported).
Currently the supported context variables aren't documented, but you can find the list below:
Note: Commands are enabled by default unless you use this property.
iconName?
optional
iconName:string
Defined in: types.ts:24
Icon to be used on toolbar buttons for example
label?
optional
label:string
Defined in: types.ts:19
Label to be displayed on menu items or keyboard shortcut editor for example. If it is missing, it's assumed it's a private command, to be called programmatically only. In that case the command will not appear in the shortcut editor or command panel, and logically should not be used as a menu item.
name
name:
string
Defined in: types.ts:11
Name of command - must be globally unique
Methods
execute()
execute(...
args
):Promise
<any
>
Defined in: types.ts:29
Code to be ran when the command is executed. It may return a result.
Parameters
args
...any
[]
Returns
Promise
<any
>