Skip to content

defineBlockObject

defineBlockObject<TType>(config): BlockObject

Defined in: packages/editor/src/renderers/renderer.types.ts:366

Define a non-editable block-level object renderer for a _type declared in the schema’s blockObjects array.

The render must always render children somewhere inside the outer element. children carries an engine-emitted void spacer the browser uses to anchor the caret next to the element. Dropping children makes the caret unable to land on the element.

TType extends string

BlockObjectRender | null

TType extends "block" ? "Error: defineBlockObject({type: 'block'}) is forbidden -- 'block' is always a text block, use defineTextBlock" : TType extends "span" ? "Error: defineBlockObject({type: 'span'}) is forbidden -- 'span' is always a span, use defineSpan" : TType

BlockObject

defineBlockObject({
type: 'image',
render: ({attributes, children, node}) => (
<div {...attributes}>
{children}
<img src={(node as {src?: string}).src} />
</div>
),
})