Skip to content

Transaction

Defined in: transaction.ts:52

new Transaction(state): Transaction;

Defined in: transaction.ts:57

ParameterType
stateEditorState

Transaction

PropertyModifierTypeDefault valueDefined in
metareadonlyTransactionMetaundefinedtransaction.ts:54
opsreadonlyTransactionOp[][]transaction.ts:53
statereadonlyEditorStateundefinedtransaction.ts:57
__bindCommitter(fn): void;

Defined in: transaction.ts:194

ParameterType
fn(tx) => void

void


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.

ParameterType
namestring
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>

this

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.

ParameterType
namestring
range{ from: number; path: BlockPath; to: number; }
range.fromnumber
range.path?BlockPath
range.to?number
attrs?Record<string, unknown>

this


commit(): this;

Defined in: transaction.ts:197

this


insertBlock(path, block): this;

Defined in: transaction.ts:107

ParameterType
pathBlockPath
blockBlockNode

this


insertText(
path,
offset,
text,
marks?): this;

Defined in: transaction.ts:75

ParameterType
pathBlockPath
offsetnumber
textstring
marks?MarkInstance[]

this


joinBackward(path): this;

Defined in: transaction.ts:89

ParameterType
pathBlockPath

this


moveBlock(from, to): this;

Defined in: transaction.ts:117

ParameterType
fromBlockPath
toBlockPath

this


removeBlock(path): this;

Defined in: transaction.ts:112

ParameterType
pathBlockPath

this


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.

ParameterType
namestring
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>

this

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.

ParameterType
namestring
range{ from: number; path: BlockPath; to: number; }
range.fromnumber
range.path?BlockPath
range.to?number
attrs?Record<string, unknown>

this


replaceRange(
path,
from,
to,
insert?): this;

Defined in: transaction.ts:70

ParameterTypeDefault value
pathBlockPathundefined
fromnumberundefined
tonumberundefined
insertTextSpan[][]

this


setBlockAttrs(path, attrs): this;

Defined in: transaction.ts:102

ParameterType
pathBlockPath
attrsRecord<string, unknown>

this


setBlockType(
path,
type,
attrs?): this;

Defined in: transaction.ts:94

ParameterType
pathBlockPath
typestring
attrs?Record<string, unknown>

this


setMeta(key, value): this;

Defined in: transaction.ts:59

ParameterType
keystring
valueunknown

this


setSelection(selection): this;

Defined in: transaction.ts:64

ParameterType
selectionSelection

this


splitBlock(
path,
offset,
newType?,
newAttrs?): this;

Defined in: transaction.ts:81

ParameterType
pathBlockPath
offsetnumber
newType?string
newAttrs?Record<string, unknown>

this


toggleMark(
name,
range,
attrs?): this;

Defined in: transaction.ts:122

ParameterType
namestring
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>

this

toggleMark(
name,
range,
attrs?): this;

Defined in: transaction.ts:123

ParameterType
namestring
range{ from: number; path: BlockPath; to: number; }
range.fromnumber
range.path?BlockPath
range.to?number
attrs?Record<string, unknown>

this