Skip to main content

StaticNodeConfigValue

interface

EXPERIMENTAL The configuration of a node returned by LexicalNode.$config()

interface StaticNodeConfigValue<T extends LexicalNode, Type extends string | symbol>

Import

import { StaticNodeConfigValue } from '@modular/sdk/editor';

Members8

$transformoptional
(node: T) => void

An alternative to the internal static transform() method that provides better type inference. If implemented this transform will be registered for this class and any subclass.

extendsoptional
Klass<LexicalNode>

The exact superclass of the node. Always name it. The runtime fills it in from the prototype chain when it is left out, but the type system cannot: `extends` is what the composed serialization types follow from one config to the next. A node that omits it still contributes its own declarations — `LexicalSchemaInput` reads the config in hand — but the walk stops there, so every property the node inherits is missing from the type while the runtime keeps applying it. Where the superclass itself declares a `$config()` — which `TextNode`, `ElementNode` and `LineBreakNode` all do — omitting it is a compile error on the override rather than a silent loss. It must be the *exact* superclass. Nothing checks that: naming a class further up the chain silently skips everything in between, which drops those classes' schema fields, `$transform`, `slots` and `stateConfigs` from every walk.

importDOMoptional
DOMConversionMap

An alternative to the static importDOM() method

jsonoptional
NodeSerializationSchema<T>

EXPERIMENTAL A SerializationSchema describing this node's serialized JSON (the node-specific properties it adds over its parent's, not including `type`/`version`/`children` or node state). When provided it is the single source of truth for parsing those properties — a node's `updateFromJSON` can apply it — and, because the schema is introspectable, tooling such as `@lexical/fast-check` can use it to generate example serializations. It is named `json` rather than `schema` to avoid ambiguity with other kinds of node schema (e.g. a schema of allowed children).

slotsoptional
readonly string[]
stateConfigsoptional
readonly RequiredNodeStateConfig[]

EXPERIMENTAL An array of RequiredNodeStateConfig to initialize your node with its state requirements. This may be used to configure serialization of that state. This function will be called (at most) once per editor initialization, directly on your node's prototype. It must not depend on any state initialized in the constructor.

typeoptional
Type

The exact type of T.getType(), e.g. 'text' - the method itself must have a more generic 'string' type to be compatible wtih subclassing. For a concrete node this is its string `type`. An abstract base class is keyed in BaseStaticNodeConfig by a symbol (it has no concrete node `type`), so `Type` is widened to `string | symbol`; the `type` field is never populated for a symbol-keyed config.

$importJSON()optional
(serializedNode: SerializedPartial<SerializedLexicalNode>) => T

An alternative to the static importJSON() method that provides better type inference. A method signature rather than a function-typed property, so that the parameter is checked bivariantly: the JSON handed in may be the compact form, so a callback may take `SerializedPartial<SerializedLexicalNode>`, while one written before that form existed takes `SerializedLexicalNode` (`version` required) and has to stay assignable. A property's parameter is compared contravariantly and would refuse it.

Notes

example
```ts class CustomText extends TextNode { $config() { return this.config('custom-text', {extends: TextNode}}; } } ```