Skip to content

defineContainer

defineContainer<TType>(config): Container

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

Define a container renderer. The returned registration is mounted via the <ContainerPlugin> wrapper at the top level, or nested inside another container’s of array as a positional override.

type cannot be 'span' (use defineLeaf) nor 'block' (use defineTextBlock). The text block is not a container.

The node argument of render narrows to a portable text object.

TType extends string

string

readonly (Container | Leaf | TextBlock)[]

(props) => ReactElement<unknown, string | JSXElementConstructor<any>> | null

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

Container

defineContainer({
type: 'table',
childField: 'rows',
render: ({children}) => <table>{children}</table>,
of: [
defineContainer({
type: 'row',
childField: 'cells',
render: ({children}) => <tr>{children}</tr>,
}),
],
})