Skip to content

EditorState.field method

EditorState › field

Official

Retrieve the value of a state field. Throws an error when the state doesn't have that field, unless you pass false as second parameter.

Signature:

field(field: StateField<T>): T

Parameters:

Parameter Type Description
field StateField<T> The state field.

Returns: TThe field value.


Official

Retrieve the value of a state field, or undefined if not present.

Signature:

field(field: StateField<T>, require: false): T | undefined

Parameters:

Parameter Type Description
field StateField<T> The state field.
require false Whether to throw if not present.

Returns: T | undefinedThe field value or undefined.