Skip to content

ToolbarItem

type ToolbarItem = {
activeWhen?: (b) => ValidationRule;
appliesTo?: "selection" | "block";
disabledWhen?: (b) => ValidationRule;
group?: "mark" | "block" | "action" | string;
icon?: string;
label: string;
name: string;
perform: (ctx) => void | Promise<void>;
priority?: number;
shortcut?: string;
visibleWhen?: (b) => ValidationRule;
};

Defined in: blocks.ts:33

PropertyTypeDescriptionDefined in
activeWhen?(b) => ValidationRule-blocks.ts:59
appliesTo?"selection" | "block"Which toolbar mode this item applies to: - 'selection' — shown when the user has a non-collapsed text selection (formatting toolbar). Default for MarkDescriptor.toolbar items. - 'block' — shown only when one or more blocks are block-selected (drag-handle click / multi-block keyboard selection). Default for BlockDescriptor.toolbar items, since those are typically block-type transforms that don’t make sense on a partial text selection. A block can opt into 'selection' to expose a formatting-style action alongside marks; a mark could (rarely) opt into 'block'.blocks.ts:57
disabledWhen?(b) => ValidationRule-blocks.ts:60
group?"mark" | "block" | "action" | stringLogical group; the toolbar renders separators between groups.blocks.ts:42
icon?stringOptional inner HTML for the button (e.g. <b>B</b>). Defaults to label.blocks.ts:38
labelstringShort visible label / tooltip.blocks.ts:36
namestring-blocks.ts:34
perform(ctx) => void | Promise<void>-blocks.ts:61
priority?numberSort within group; lower priority renders first.blocks.ts:44
shortcut?stringOptional shortcut hint shown in the tooltip (“⌘B”). No runtime effect.blocks.ts:40
visibleWhen?(b) => ValidationRule-blocks.ts:58