Classes
- modifiers
- Modifier methods.
- processors
- Processing methods.
Constructor
new ve.dm.TransactionProcessor(doc, transaction, isStaging)
#
DataModel transaction processor.
This class reads operations from a transaction and applies them one by one. It's not intended
to be used directly; use {ve.dm.Document#commit} instead.
NOTE: Instances of this class are not recyclable: you can only call .process() on them once.
Parameters:
| Name | Type | Description |
|---|---|---|
doc |
ve.dm.Document | |
transaction |
ve.dm.Transaction | |
isStaging |
boolean | Transaction is being applied in staging mode |
Properties
largeReplaceFraction :numberstatic
#
Fraction of the attached root that a single replace must remove or insert to use the fast rebuild path instead of the incremental per-node TreeModifier path (T189557).
Type:
- number
Fraction of the attached root that a single replace must remove or insert to use the fast rebuild path instead of the incremental per-node TreeModifier path (T189557).
largeReplaceMinimum :numberstatic
#
Minimum number of linear-model offsets a single replace must remove or insert to use the fast
rebuild path. This limit applies together with
ve.dm.TransactionProcessor.largeReplaceFraction.
The fraction becomes small when the document is small. In a nearly empty document, a few characters are more than half of it. The rebuild replaces the ContentEditable node that holds the cursor. This stops an IME composition, because the composition belongs to that text node (T435688).
Type:
- number
Minimum number of linear-model offsets a single replace must remove or insert to use the fast rebuild path.
Methods
advanceCursor(increment)private
#
Advance the main data cursor.
Parameters:
| Name | Type | Description |
|---|---|---|
increment |
number | Number of positions to increment the cursor by |
applyLargeReplace(largeReplace)private
#
Apply a large replace as a single linear splice plus a one-pass tree rebuild, instead of
TreeModifier's per-node application. See #getLargeReplaceOp.
Parameters:
| Name | Type | Description |
|---|---|---|
largeReplace |
Object |
|
Apply a large replace as a single linear splice plus a one-pass tree rebuild, instead of TreeModifier's per-node application.
applyModifications()private
#
Apply all modifications queued through #queueModification, and add their rollback functions to this.rollbackQueue.
Apply all modifications queued through #queueModification, and add their rollback functions to this.rollbackQueue.
emitQueuedEvents()private
#
Emit all events queued through #queueEvent.
executeOperation(op)private
#
getLargeReplaceOp() → {Object|null}private
#
null}private
#
Detect a single large replace that can take the fast rebuild path. The transaction must hold
retains plus exactly one replace, and no attribute ops. The replace must remove or insert at
least ve.dm.TransactionProcessor.largeReplaceFraction of the attached root, and at
least ve.dm.TransactionProcessor.largeReplaceMinimum offsets. It must also span more
than one paragraph.
Returns:
{ op, offset } for the qualifying replace (offset is its
linear-model offset), else null to use the incremental TreeModifier path
- Type
-
Object
|
null
process()private
#
Process all operations.
When all operations are done being processed, the document will be synchronized.
queueEvent(node, name, […args])private
#
Queue an event to be emitted on a node.
Duplicate events will be ignored only if all arguments match exactly (i.e. are reference-equal).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
node |
ve.dm.Node | ||
name |
string | Event name |
|
args |
any |
optional repeatable |
Additional arguments to be passed to the event when fired |
queueModification(modification)private
#
queueUndoFunction(func)
#
Queue an undo function. If an exception is thrown while modifying, #rollbackModifications will invoke these functions in reverse order.
Parameters:
| Name | Type | Description |
|---|---|---|
func |
function | Undo function to add to the queue |
rollbackModifications()private
#
Roll back all modifications that have been applied so far. This invokes the callbacks returned by the modifier functions.
spansMultipleParagraphs(data) → {boolean}privatestatic
#
Check if linear data spans more than one paragraph.
A source-mode document is flat, so each open element starts a paragraph. Data that does not start with an open element continues the paragraph before it.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array | Linear data from a replace operation |
Returns:
The data spans more than one paragraph
- Type
- boolean