Skip to main content

Class: StateConfig<K, V>

lexical.StateConfig

The return value of createState, for use with $getState and $setState.

Type parameters

NameType
Kextends string
VV

Constructors

constructor

new StateConfig<K, V>(key, stateValueConfig): StateConfig<K, V>

Type parameters

NameType
Kextends string
VV

Parameters

NameType
keyK
stateValueConfigStateValueConfig<V>

Returns

StateConfig<K, V>

Defined in

packages/lexical/src/LexicalNodeState.ts:261

Properties

defaultValue

Readonly defaultValue: V

The result of stateValueConfig.parse(undefined), which is computed only once and used as the default value. When the current value isEqual to the defaultValue, it will not be serialized to JSON.

Defined in

packages/lexical/src/LexicalNodeState.ts:260


isEqual

Readonly isEqual: (a: V, b: V) => boolean

An equality function from the StateValueConfig, with a default of Object.is.

Type declaration

▸ (a, b): boolean

Parameters
NameType
aV
bV
Returns

boolean

Defined in

packages/lexical/src/LexicalNodeState.ts:254


key

Readonly key: K

The string key used when serializing this state to JSON

Defined in

packages/lexical/src/LexicalNodeState.ts:241


parse

Readonly parse: (value?: unknown) => V

The parse function from the StateValueConfig passed to createState

Type declaration

▸ (value?): V

Parameters
NameType
value?unknown
Returns

V

Defined in

packages/lexical/src/LexicalNodeState.ts:243


unparse

Readonly unparse: (value: V) => unknown

The unparse function from the StateValueConfig passed to createState, with a default that is simply a pass-through that assumes the value is JSON serializable.

Type declaration

▸ (value): unknown

Parameters
NameType
valueV
Returns

unknown

Defined in

packages/lexical/src/LexicalNodeState.ts:249