Skip to content

ToolbarItemContext

type ToolbarItemContext = {
anchor: HTMLElement;
blockSelection: ReadonlySet<string>;
editor: {
createTransaction: Transaction;
dispatch: void;
};
state: EditorState;
close: void;
};

Defined in: blocks.ts:20

Contributed by blocks/marks (and one day extensions) to the floating selection toolbar. Items are evaluated against the current state on every selection change; visibleWhen controls whether the button is shown at all, activeWhen toggles the highlighted “on” appearance, disabledWhen greys the button out without hiding it.

perform receives a thin context: the live state, an editor with createTransaction/dispatch, and an anchor element so popover- shaped items (link URL input) can position themselves relative to their button. close() dismisses any open popover the toolbar owns.

PropertyTypeDescriptionDefined in
anchorHTMLElement-blocks.ts:23
blockSelectionReadonlySet<string>Block-selection ids when the toolbar is in 'block' mode. Empty Set in selection mode. perform for block-mode items should iterate this set rather than relying on state.selection.head.path.blocks.ts:30
editor{ createTransaction: Transaction; dispatch: void; }-blocks.ts:22
editor.createTransactionTransaction-blocks.ts:22
editor.dispatchvoid-blocks.ts:22
stateEditorState-blocks.ts:21
close(): void;

Defined in: blocks.ts:24

void