Skip to content

MarkDescriptor

type MarkDescriptor = {
name: string;
toComponent?: (payload) => unknown;
toDOM?: (payload) => HTMLElement;
toMarkdown?: (payload) => string;
toolbar?: | ToolbarItem
| ToolbarItem[];
};

Defined in: blocks.ts:212

PropertyTypeDescriptionDefined in
namestring-blocks.ts:213
toComponent?(payload) => unknown-blocks.ts:215
toDOM?(payload) => HTMLElement-blocks.ts:214
toMarkdown?(payload) => stringSerialize a span carrying this mark to inline markdown. Receives the mark payload — payload.text is the inner text produced so far (after marks of lower precedence have been applied), and payload.attrs the mark’s attributes — and returns the replacement markdown string. This is the inline-mark analogue of a block descriptor’s toMarkdown. It lets custom marks round-trip through the clipboard / markdown export instead of being silently dropped (the default for unknown marks). For example a moji mark returns :slug: so copying an inline emoji yields its shortcode. When a same-block text selection containing such a mark is copied, the editor routes the copy through the markdown serializer (rather than the browser’s native text copy) so the hook actually fires. Return the text unchanged (or omit the hook) to keep the default behaviour of preserving the text and dropping the mark.blocks.ts:233
toolbar?| ToolbarItem | ToolbarItem[]Items this mark contributes to the floating selection toolbar. If omitted, the mark has no toolbar presence. The common case is a single toggle item; multiple items are supported for marks with variants (e.g. a future “color” mark with swatch buttons). Defaults applied when an item omits the corresponding rule: - visibleWhen: and([selectionNotEmpty, blockSupportsDecoration]) - activeWhen: markActiveInSelection(mark.name)blocks.ts:244