Transaction
Defined in: transaction.ts:52
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Transaction(state): Transaction;Defined in: transaction.ts:57
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state | EditorState |
Returns
Section titled “Returns”Transaction
Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
meta | readonly | TransactionMeta | undefined | transaction.ts:54 |
ops | readonly | TransactionOp[] | [] | transaction.ts:53 |
state | readonly | EditorState | undefined | transaction.ts:57 |
Methods
Section titled “Methods”__bindCommitter()
Section titled “__bindCommitter()”__bindCommitter(fn): void;Defined in: transaction.ts:194
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fn | (tx) => void |
Returns
Section titled “Returns”void
addMark()
Section titled “addMark()”Call Signature
Section titled “Call Signature”addMark( name, range, attrs?): this;Defined in: transaction.ts:138
Add a mark over a range unconditionally (unlike toggleMark, which
removes the mark when the range is already fully marked). This is what
range-keyed annotations such as comments want: applying a comment must never
accidentally toggle an existing one off. A character holds at most one mark
of a given type — adding a mark whose attrs differ (e.g. a new comment
thread over already-commented text) replaces the prior one on the overlap.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: { offset: number; path: BlockPath; }; to: { offset: number; path: BlockPath; }; } |
range.from | { offset: number; path: BlockPath; } |
range.from.offset? | number |
range.from.path? | BlockPath |
range.to? | { offset: number; path: BlockPath; } |
range.to.offset? | number |
range.to.path? | BlockPath |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
Call Signature
Section titled “Call Signature”addMark( name, range, attrs?): this;Defined in: transaction.ts:139
Add a mark over a range unconditionally (unlike toggleMark, which
removes the mark when the range is already fully marked). This is what
range-keyed annotations such as comments want: applying a comment must never
accidentally toggle an existing one off. A character holds at most one mark
of a given type — adding a mark whose attrs differ (e.g. a new comment
thread over already-commented text) replaces the prior one on the overlap.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: number; path: BlockPath; to: number; } |
range.from | number |
range.path? | BlockPath |
range.to? | number |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
commit()
Section titled “commit()”commit(): this;Defined in: transaction.ts:197
Returns
Section titled “Returns”this
insertBlock()
Section titled “insertBlock()”insertBlock(path, block): this;Defined in: transaction.ts:107
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
block | BlockNode |
Returns
Section titled “Returns”this
insertText()
Section titled “insertText()”insertText( path, offset, text, marks?): this;Defined in: transaction.ts:75
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
offset | number |
text | string |
marks? | MarkInstance[] |
Returns
Section titled “Returns”this
joinBackward()
Section titled “joinBackward()”joinBackward(path): this;Defined in: transaction.ts:89
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
Returns
Section titled “Returns”this
moveBlock()
Section titled “moveBlock()”moveBlock(from, to): this;Defined in: transaction.ts:117
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
from | BlockPath |
to | BlockPath |
Returns
Section titled “Returns”this
removeBlock()
Section titled “removeBlock()”removeBlock(path): this;Defined in: transaction.ts:112
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
Returns
Section titled “Returns”this
removeMark()
Section titled “removeMark()”Call Signature
Section titled “Call Signature”removeMark( name, range, attrs?): this;Defined in: transaction.ts:151
Remove every mark of type over a range (attrs are ignored — a character
carries at most one mark per type). Pair with a doc walk that targets only
the runs belonging to one annotation to remove a single comment thread.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: { offset: number; path: BlockPath; }; to: { offset: number; path: BlockPath; }; } |
range.from | { offset: number; path: BlockPath; } |
range.from.offset? | number |
range.from.path? | BlockPath |
range.to? | { offset: number; path: BlockPath; } |
range.to.offset? | number |
range.to.path? | BlockPath |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
Call Signature
Section titled “Call Signature”removeMark( name, range, attrs?): this;Defined in: transaction.ts:152
Remove every mark of type over a range (attrs are ignored — a character
carries at most one mark per type). Pair with a doc walk that targets only
the runs belonging to one annotation to remove a single comment thread.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: number; path: BlockPath; to: number; } |
range.from | number |
range.path? | BlockPath |
range.to? | number |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
replaceRange()
Section titled “replaceRange()”replaceRange( path, from, to, insert?): this;Defined in: transaction.ts:70
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
path | BlockPath | undefined |
from | number | undefined |
to | number | undefined |
insert | TextSpan[] | [] |
Returns
Section titled “Returns”this
setBlockAttrs()
Section titled “setBlockAttrs()”setBlockAttrs(path, attrs): this;Defined in: transaction.ts:102
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
attrs | Record<string, unknown> |
Returns
Section titled “Returns”this
setBlockType()
Section titled “setBlockType()”setBlockType( path, type, attrs?): this;Defined in: transaction.ts:94
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
type | string |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
setMeta()
Section titled “setMeta()”setMeta(key, value): this;Defined in: transaction.ts:59
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | string |
value | unknown |
Returns
Section titled “Returns”this
setSelection()
Section titled “setSelection()”setSelection(selection): this;Defined in: transaction.ts:64
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
selection | Selection |
Returns
Section titled “Returns”this
splitBlock()
Section titled “splitBlock()”splitBlock( path, offset, newType?, newAttrs?): this;Defined in: transaction.ts:81
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | BlockPath |
offset | number |
newType? | string |
newAttrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
toggleMark()
Section titled “toggleMark()”Call Signature
Section titled “Call Signature”toggleMark( name, range, attrs?): this;Defined in: transaction.ts:122
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: { offset: number; path: BlockPath; }; to: { offset: number; path: BlockPath; }; } |
range.from | { offset: number; path: BlockPath; } |
range.from.offset? | number |
range.from.path? | BlockPath |
range.to? | { offset: number; path: BlockPath; } |
range.to.offset? | number |
range.to.path? | BlockPath |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this
Call Signature
Section titled “Call Signature”toggleMark( name, range, attrs?): this;Defined in: transaction.ts:123
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
range | { from: number; path: BlockPath; to: number; } |
range.from | number |
range.path? | BlockPath |
range.to? | number |
attrs? | Record<string, unknown> |
Returns
Section titled “Returns”this