ReadonlydocThe current document.
ReadonlyselectionThe current selection.
StaticallowA facet that, when enabled, causes the editor to allow multiple
ranges to be selected. Be careful though, because by default the
editor relies on the native DOM selection, which cannot handle
multiple selections. An extension like
drawSelection can be used to make
secondary selections visible to the user.
StaticchangeFacet used to register change filters, which are called for each transaction (unless explicitly disabled), and can suppress part of the transaction's changes.
Such a function can return true to indicate that it doesn't
want to do anything, false to completely stop the changes in
the transaction, or a set of ranges in which changes should be
suppressed. Such ranges are represented as an array of numbers,
with each pair of two numbers indicating the start and end of a
range. So for example [10, 20, 100, 110] suppresses changes
between 10 and 20, and between 100 and 110.
StaticlanguageA facet used to register language data providers.
StaticlineThe line separator to use. By default, any of "\n", "\r\n"
and "\r" is treated as a separator when splitting lines, and
lines are joined with "\n".
When you configure a value here, only that precise separator will be used, allowing you to round-trip documents through the editor without normalizing line separators.
StaticphrasesRegisters translation phrases. The
phrase method will look through
all objects registered with this facet to find translations for
its argument.
StaticreadThis facet controls the value of the
readOnly getter, which is
consulted by commands and extensions that implement editing
functionality to determine whether they should apply. It
defaults to false, but when its highest-precedence value is
true, such functionality disables itself.
Not to be confused with
EditorView.editable, which
controls whether the editor's DOM is set to be editable (and
thus focusable).
StatictabConfigures the tab size to use in this state. The first (highest-precedence) value of the facet is used. If no value is given, this defaults to 4.
StatictransactionThis is a more limited form of
transactionFilter,
which can only add
annotations and
effects. But, this type
of filter runs even if the transaction has disabled regular
filtering, making it suitable
for effects that don't need to touch the changes or selection,
but do want to process every transaction.
Extenders run after filters, when both are present.
StatictransactionFacet used to register a hook that gets a chance to update or
replace transaction specs before they are applied. This will
only be applied for transactions that don't have
filter set to false. You
can either return a single transaction spec (possibly the input
transaction), or an array of specs (which will be combined in
the same way as the arguments to
EditorState.update).
When possible, it is recommended to avoid accessing
Transaction.state in a filter,
since it will force creation of a state that will then be
discarded again, if the transaction is actually filtered.
(This functionality should be used with care. Indiscriminately modifying transaction is likely to break something or degrade the user experience.)
Get the proper line-break string for this state.
Returns true when the editor is configured to be read-only.
The size (in columns) of a tab in the document, determined by
the tabSize facet.
Create a set of changes and a new selection by running the given
function for each range in the active selection. The function
can return an optional set of changes (in the coordinate space
of the start document), plus an updated range (in the coordinate
space of the document produced by the call's own changes). This
method will merge all the changes and ranges into a single
changeset and selection, and return it as a transaction
spec, which can be passed to
update.
Create a change set from the given change description, taking the state's document length and line separator into account.
Optionalspec: ChangeSpecReturn a function that can categorize strings (expected to represent a single grapheme cluster) into one of:
"wordChars"
language data, which should be a string)Get the value of a state facet.
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.
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.
Find the values for a given language data field, provided by the
the languageData facet.
Examples of language data fields are...
"commentTokens" for specifying
comment syntax."autocomplete"
for providing language-specific completion sources."wordChars" for adding
characters that should be considered part of words in this
language."closeBrackets" controls
bracket closing behavior.Optionalside: -1 | 0 | 1Look up a translation for the given phrase (via the
phrases facet), or return the
original string if no translation is found.
If additional arguments are passed, they will be inserted in
place of markers like $1 (for the first value) and $2, etc.
A single $ is equivalent to $1, and $$ will produce a
literal dollar sign.
Create a transaction spec that replaces every selection range with the given content.
Return the given range of the document as a string.
Optionalfrom: numberOptionalto: numberConvert this state to a JSON-serializable object. When custom
fields should be serialized, you can pass them in as an object
mapping property names (in the resulting object, which should
not use doc or selection) to fields.
Optionalfields: { [prop: string]: StateField<any> }Using the state's line
separator, create a
Text instance from the given string.
Create a transaction that updates this
state. Any number of transaction specs
can be passed. Unless
sequential is set, the
changes (if any) of each spec
are assumed to start in the current document (not the document
produced by previous specs), and its
selection and
effects are assumed to refer
to the document created by its own changes. The resulting
transaction contains the combined effect of all the different
specs. For selection, later
specs take precedence over earlier ones.
Find the word at the given position, meaning the range containing all word characters around it. If no word characters are adjacent to the position, this returns null.
StaticcreateCreate a new state. You'll usually only need this when initializing an editor—updated states are created by applying transactions.
Optionalconfig: EditorStateConfigStaticfromDeserialize a state from its JSON representation. When custom
fields should be deserialized, pass the same object you passed
to toJSON when serializing as
third argument.
Optionalconfig: EditorStateConfigOptionalfields: { [prop: string]: StateField<any> }
The editor state class is a persistent (immutable) data structure. To update a state, you create a transaction, which produces a new state instance, without modifying the original object.
As such, never mutate properties of a state directly. That'll just break things.