Skip to content

defineLeaf

defineLeaf<TSchema>(config): Leaf

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

Define a leaf renderer for a span, inline object, or void block object at a given scope.

The render function must always render children somewhere inside the outer element. For spans children carries the styled text. For inline objects and void block objects children carries an engine-emitted void spacer that the browser uses to anchor the caret next to the element. If the consumer drops children, the caret cannot land on the element.

With a schema type parameter, scope is constrained to valid JSONPath leaf scopes:

defineLeaf<typeof schema>({
scope: '$..callout.block.span',
render: ({attributes, children}) => <span {...attributes}>{children}</span>,
})

Without a schema type parameter, accepts any string.

TSchema extends SchemaDefinition

SchemaLeafConfig<TSchema>

Leaf

defineLeaf(config): Leaf

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

Leaf

Leaf