Skip to content

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.

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

Availability

{ available: true, label?, state? }

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,
});