Skip to content

EditorState

Unofficial

Import:

import type { EditorState } from '@codemirror/state';

Signature:

export interface EditorState

Methods

Method Returns Description
changeByRange(f) ChangeByRangeReturn Create a set of changes and a new selection by running the given function for each range in the active selection.
changes(spec?) ChangeSet Create a change set from the given change description.
charCategorizer(at) (char: string) => CharCategory Return a function that can categorize strings into Word, Space, or Other.
facet(facet) Output Get the value of a state facet.
field(field) T 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.
field(field, require) T | undefined Retrieve the value of a state field, or undefined if not present.
languageDataAt(name, pos, side?) readonly T[] Find the values for a given language data field.
phrase(phrase, insert?) string Look up a translation for the given phrase.
replaceSelection(text) TransactionSpec Create a transaction spec that replaces every selection range with the given content.
sliceDoc(from?, to?) string Return the given range of the document as a string.
toJSON(fields?) unknown Convert this state to a JSON-serializable object.
toText(string) Text Using the state's line separator, create a Text instance from the given string.
update(specs?) Transaction Create a transaction that updates this state.
wordAt(pos) null | SelectionRange Find the word at the given position.

Links to this page: