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

EditorState

The state of a ProseMirror editor is represented by an object of this type. A state is a persistent data structure—it isn't updated, but rather a new state value is computed from an old one using the apply method.

A state holds a number of built-in fields, and plugins can define additional fields.

class EditorState {
doc: Node;
get schema(): Schema;
get plugins(): readonly Plugin[];
selection: Selection;
storedMarks: readonly Mark[] | null;
get tr(): Transaction;
 
applyTransaction(rootTr: Transaction): {
state: EditorState;
transactions: readonly Transaction[];
}
;
reconfigure(config: {
plugins?: readonly Plugin[];
}
): EditorState;
toJSON(pluginFields?: {
[propName: string]: Plugin;
}
): any;
 
static create(config: EditorStateConfig): EditorState;
static fromJSON(
config: {
schema: Schema;
plugins?: readonly Plugin[];
}
,
json: any,
pluginFields?: {
[propName: string]: Plugin;
}
,
): EditorState;
}

§Properties

§

The current document.

§
schema: Schema readonly
[src]

The schema of the state's document.

§
plugins: readonly Plugin[] readonly
[src]

The plugins that are active in this state.

§
selection: Selection
[src]

The selection.

§
storedMarks: readonly Mark[] | null
[src]

A set of marks to apply to the next input. Will be null when no explicit marks have been set.

§
tr: Transaction readonly
[src]

Start a transaction from this state.

§Methods

§

Apply the given transaction to produce a new state.

§
applyTransaction(rootTr: Transaction): {
state: EditorState;
transactions: readonly Transaction[];
}
[src]

Verbose variant of apply that returns the precise transactions that were applied (which might be influenced by the transaction hooks of plugins) along with the new state.

§
reconfigure(config: {
plugins?: readonly Plugin[];
}
): EditorState
[src]

Create a new state based on this one, but with an adjusted set of active plugins. State fields that exist in both sets of plugins are kept unchanged. Those that no longer exist are dropped, and those that are new are initialized using their init method, passing in the new configuration object..

§
toJSON(pluginFields?: {
[propName: string]: Plugin;
}
): any
[src]

Serialize this state to JSON. If you want to serialize the state of plugins, pass an object mapping property names to use in the resulting JSON object to plugin objects. The argument may also be a string or number, in which case it is ignored, to support the way JSON.stringify calls toString methods.

§Static Methods

§

Create a new state.

§
fromJSON(config: {
schema: Schema;
plugins?: readonly Plugin[];
}
, json: any, pluginFields?: {
[propName: string]: Plugin;
}
): EditorState
[src]

Deserialize a JSON representation of a state. config should have at least a schema field, and should contain array of plugins to initialize the state with. pluginFields can be used to deserialize the state of plugins, by associating plugin instances with the property names they use in the JSON object.