Skip to content

EditorState

Unofficial

Import:

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

Signature:

export interface EditorState

Methods

MethodReturnsDescription
changeByRange(f)ChangeByRangeReturnCreate a set of changes and a new selection by running the given function for each range in the active selection.
changes(spec?)ChangeSetCreate a change set from the given change description.
charCategorizer(at)(char: string) => CharCategoryReturn a function that can categorize strings into Word, Space, or Other.
facet(facet)OutputGet the value of a state facet.
field(field)TRetrieve 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 | undefinedRetrieve 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?)stringLook up a translation for the given phrase.
replaceSelection(text)TransactionSpecCreate a transaction spec that replaces every selection range with the given content.
sliceDoc(from?, to?)stringReturn the given range of the document as a string.
toJSON(fields?)unknownConvert this state to a JSON-serializable object.
toText(string)TextUsing the state's line separator, create a Text instance from the given string.
update(specs?)TransactionCreate a transaction that updates this state.
wordAt(pos)null | SelectionRangeFind the word at the given position.

Links to this page: