available
function available(label?, state?): Availability;Says that an action can be used here. This is the answer of the can function of a command.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label? |
string |
the words to show for the action, when they are not the title of the command |
state? |
"on" | "off" | "mixed" |
on, off or mixed, for a control that switches on and off |
Returns
Section titled “Returns”{ available: true, label?, state? }
Example
Section titled “Example”ctx.commands.register({ id: 'com.example.pomodoro/start', title: 'Start a Pomodoro', args: { type: 'object' }, can: (state, focus) => (focus.row ? available() : unavailable('Select a row first')), propose: (state, args, draft) => draft,});