Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

StateField

A plugin spec may provide a state field (under its state property) of this type, which describes the state it wants to keep. Functions provided here are always called with the plugin instance as their this binding.

interface StateField <T> {
apply: (
value: T,
oldState: EditorState,
newState: EditorState,
) => T
;
fromJSON?: (
value: any,
state: EditorState,
) => T
;
init: (config: EditorStateConfig, instance: EditorState) => T;
toJSON?: (value: T) => any;
}

§Type Parameters

§Properties

§
apply: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) => T
[src]

Apply the given transaction to this state field, producing a new field value. Note that the newState argument is again a partially constructed state does not yet contain the state from plugins coming after this one.

§
fromJSON?: (config: EditorStateConfig, value: any, state: EditorState) => T
[src]

Deserialize the JSON representation of this field. Note that the state argument is again a half-initialized state.

§
init: (config: EditorStateConfig, instance: EditorState) => T
[src]

Initialize the value of the field. config will be the object passed to EditorState.create. Note that instance is a half-initialized state instance, and will not have values for plugin fields initialized after this one.

§
toJSON?: (value: T) => any
[src]

Convert this field to JSON. Optional, can be left off to disable JSON serialization for the field.