getUnionSchema
getUnionSchema(
schema,containers):Schema
Defined in: get-union-schema.ts:40
Return a Schema that contains every named member declared anywhere
in the editor’s schema graph that is reachable from a position where text
is edited - the root schema merged with the sub-schema of every registered
container whose field accepts text blocks, deduped by name. Containers
registered in another container’s of count at any depth, so a table
cell registered under row under table contributes its members.
When two sources declare the same name, the first one wins: the root
schema, then top-level containers in registration order, then nested
containers one depth level at a time. Nested containers only add names
that no shallower source declares.
Useful for rendering a static toolbar whose buttons stay stable across selection moves while still reflecting everything that could plausibly be edited or inserted somewhere.
Containers whose field does NOT accept text blocks (e.g. a table
container whose rows field only accepts row objects, or a row
container whose cells field only accepts cell objects) are
structural: their immediate of types are organizational, not
insertable user content. Those structural types are excluded from the
union. Their text-block-accepting descendants (e.g. a cell that
contains a content field of {type: 'block'}) still contribute when
they are registered, either at the top level or nested in the structural
container’s of.
Pair with getPathSubSchema (or a path-based intersection across a
range) to determine which of the union’s members are applicable at the
current selection.
Parameters
Section titled “Parameters”schema
Section titled “schema”Schema
containers
Section titled “containers”Containers
Returns
Section titled “Returns”Schema