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

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".

class Transaction extends Transform {
private curSelection;
private curSelectionFor;
private meta;
private updated;
get selection(): Selection;
get selectionSet(): boolean;
storedMarks: readonly Mark[] | null;
get storedMarksSet(): boolean;
get isGeneric(): boolean;
get scrolledIntoView(): boolean;
time: number;
 
addStoredMark(mark: Mark): this;
deleteSelection(): this;
ensureMarks(marks: readonly Mark[]): this;
getMeta(key: string | Plugin | PluginKey): any;
insertText(
text: string,
from?: number,
to?: number,
): this;
removeStoredMark(mark: Mark | MarkType): this;
replaceSelection(slice: Slice): this;
replaceSelectionWith(node: Node, inheritMarks?: boolean): this;
scrollIntoView(): this;
setMeta(key: string | Plugin | PluginKey, value: any): this;
setSelection(selection: Selection): this;
setStoredMarks(marks: readonly Mark[] | null): this;
setTime(time: number): this;
}

§Extends

§
Transform
[src]

§Properties

§
curSelection
[src]
§
curSelectionFor
[src]
§
updated
[src]
§
selection: Selection readonly
[src]

The transaction's current selection. This defaults to the editor selection mapped through the steps in the transaction, but can be overwritten with setSelection.

§
selectionSet: boolean readonly
[src]

Whether the selection was explicitly updated by this transaction.

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

The stored marks set by this transaction, if any.

§
storedMarksSet: boolean readonly
[src]

Whether the stored marks were explicitly set for this transaction.

§
isGeneric: boolean readonly
[src]

Returns true if this transaction doesn't contain any metadata, and can thus safely be extended.

§
scrolledIntoView: boolean readonly
[src]

True when this transaction has had scrollIntoView called on it.

§
time: number
[src]

The timestamp associated with this transaction, in the same format as Date.now().

§Methods

§
addStoredMark(mark: Mark): this
[src]

Add a mark to the set of stored marks.

§
deleteSelection(): this
[src]

Delete the selection.

§
ensureMarks(marks: readonly Mark[]): this
[src]

Make sure the current stored marks or, if that is null, the marks at the selection, match the given set of marks. Does nothing if this is already the case.

§
getMeta(key: string | Plugin | PluginKey): any
[src]

Retrieve a metadata property for a given name or plugin.

§
insertText(text: string, from?: number, to?: number): this
[src]

Replace the given range, or the selection if no range is given, with a text node containing the given string.

§
removeStoredMark(mark: Mark | MarkType): this
[src]

Remove a mark or mark type from the set of stored marks.

§
replaceSelection(slice: Slice): this
[src]

Replace the current selection with the given slice.

§
replaceSelectionWith(node: Node, inheritMarks?: boolean): this
[src]

Replace the selection with the given node. When inheritMarks is true and the content is inline, it inherits the marks from the place where it is inserted.

§
scrollIntoView(): this
[src]

Indicate that the editor should scroll the selection into view when updated to the state produced by this transaction.

§
setMeta(key: string | Plugin | PluginKey, value: any): this
[src]

Store a metadata property in this transaction, keyed either by name or by plugin.

§
setSelection(selection: Selection): this
[src]

Update the transaction's current selection. Will determine the selection that the editor gets when the transaction is applied.

§
setStoredMarks(marks: readonly Mark[] | null): this
[src]

Set the current stored marks.

§
setTime(time: number): this
[src]

Update the timestamp for the transaction.