Skip to main content

Interface: StaticNodeConfigValue<T, Type>

lexical.StaticNodeConfigValue

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

Example

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

Type parameters

NameType
Textends LexicalNode
Typeextends string

Properties

$transform

Optional Readonly $transform: (node: T) => void

An alternative to the internal static transform() method that provides better DX

Type declaration

▸ (node): void

Parameters
NameType
nodeT
Returns

void

Defined in

packages/lexical/src/LexicalNode.ts:110


extends

Optional Readonly extends: KlassConstructor<typeof LexicalNode>

If specified, this must be the exact superclass of the node. It is not checked at compile time and it is provided automatically at runtime.

You would want to specify this when you are extending a node that has non-trivial configuration in its $config such as required state. If you do not specify this, the inferred types for your node class might be missing some of that.

Defined in

packages/lexical/src/LexicalNode.ts:152


stateConfigs

Optional Readonly stateConfigs: 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.

Example

const flatState = createState("flat", {parse: parseNumber});
const nestedState = createState("nested", {parse: parseNumber});
class MyNode extends TextNode {
$config() {
return this.config(
'my-node',
{
extends: TextNode,
stateConfigs: [
{ stateConfig: flatState, flat: true},
nestedState,
]
},
);
}
}

Defined in

packages/lexical/src/LexicalNode.ts:142


type

Optional Readonly type: 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.

Defined in

packages/lexical/src/LexicalNode.ts:105