Transaction
An editor state transaction, which can be applied to a state to
create an updated state. Use
EditorState.tr
to create an instance.
Transactions track changes to the document (they are a subclass of
Transform
), but also other state changes,
like selection updates and adjustments of the set of stored
marks. In addition, you can store
metadata properties in a transaction, which are extra pieces of
information that client code or plugins can use to describe what a
transaction represents, so that they can update their own
state accordingly.
The editor view uses a few metadata
properties: it will attach a property "pointer"
with the value
true
to selection transactions directly caused by mouse or touch
input, a "composition"
property holding an ID identifying the
composition that caused it to transactions caused by composed DOM
input, and a "uiEvent"
property of that may be "paste"
,
"cut"
, or "drop"
.
§Properties
The transaction's current selection. This defaults to the editor
selection mapped through the steps in the
transaction, but can be overwritten with
setSelection
.
Whether the selection was explicitly updated by this transaction.
Whether the stored marks were explicitly set for this transaction.
Returns true if this transaction doesn't contain any metadata, and can thus safely be extended.
True when this transaction has had scrollIntoView
called on it.
§Methods
Replace the given range, or the selection if no range is given, with a text node containing the given string.
Indicate that the editor should scroll the selection into view when updated to the state produced by this transaction.