Skip to main content

@lexical/extension/NodeStructureExtension

Interfaces​

NodeStructureConfig​

Defined in: packages/lexical-extension/src/NodeStructureExtension.ts:25

Experimental

node-structure

Configuration of NodeStructureExtension (each key is also a signal in its output).

Properties​

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/NodeStructureExtension.ts:31

Experimental

true stops enforcing the declarations (they are then only read). Turning it back to false normalizes the whole document. Default false.

Variables​

NodeStructureExtension​

const NodeStructureExtension: LexicalExtension<NodeStructureConfig, "@lexical/NodeStructure", NamedSignalsOutput<NodeStructureConfig>, unknown>

Defined in: packages/lexical-extension/src/NodeStructureExtension.ts:73

Experimental

node-structure

Enforces the structure node classes declare in $config():

  • children: a block in a node that holds inline content is lifted out and the node split around it (a plain paragraph becomes lines of the node instead), inline content in a node that holds blocks is wrapped in a paragraph, and a child a list of classes does not allow is wrapped in the first listed class;
  • mergeAdjacent: equal adjacent siblings are merged.

It runs in the same update as the change, after the other transforms of each pass, from the root down along the nodes the update changed, so the result depends on the document only. Repairs only move content; the one thing removed is an inline element left with nothing in it (a link, a mark, an OverflowNode), which Lexical removes anyway.

An update applied with skipTransforms runs no transform, so it is not normalized, and later updates repair only what they change (inline content it leaves at the root is wrapped, as core's own transform wraps it). Code that applies updates with skipTransforms calls the normalization itself.

Opt-in: without it, the declarations change nothing at runtime.

Functions​

registerNodeStructure()​

registerNodeStructure(editor): () => void

Defined in: packages/lexical-extension/src/NodeStructureExtension.ts:45

Experimental

node-structure

Enforces on editor the structure node classes declare in $config(), as NodeStructureExtension does (with the same limits), for code that builds an editor without extensions. The current document is normalized too. Registering more than once is harmless; the normalization stops when every returned function has been called.

Parameters​

editor​

LexicalEditor

Returns​

A function that removes this registration

() => void