engine/model/operation/transform
@ckeditor/ckeditor5-engine/src/model/operation/transform
Filtering
Type Definitions
-
TransformationContext
module:engine/model/operation/transform~TransformationContext
Holds additional contextual information about a transformed pair of operations (
a
andb
). Those information can be used for better conflict resolving.
Functions
-
_getComplementaryAttributeOperations( insertOperation, key, newValue ) → AttributeOperation | null
module:engine/model/operation/transform~_getComplementaryAttributeOperations
private
Helper function for
AttributeOperation
xInsertOperation
(and reverse) transformation.For given
insertOperation
it checks the inserted node if it has an attributekey
set to a value different thannewValue
. If so, it generates anAttributeOperation
which changes the value ofkey
attribute tonewValue
.Parameters
insertOperation : InsertOperation
key : String
newValue : *
Returns
AttributeOperation | null
-
getTransformation( OperationA, OperationB ) → function
module:engine/model/operation/transform~getTransformation
private
Returns a previously set transformation function for transforming an instance of
OperationA
by an instance ofOperationB
.If no transformation was set for given pair of operations,
noUpdateTransformation
is returned. This means that if no transformation was set, theOperationA
instance will not change when transformed by theOperationB
instance.Parameters
OperationA : function
OperationB : function
Returns
function
Function set to transform an instance of
OperationA
by an instance ofOperationB
.
-
noUpdateTransformation( a ) → Array.<Operation>
module:engine/model/operation/transform~noUpdateTransformation
private
A transformation function that only clones operation to transform, without changing it.
-
padWithNoOps( operations, howMany )
module:engine/model/operation/transform~padWithNoOps
private
Adds
howMany
instances ofNoOperation
tooperations
set.Parameters
operations : Array.<Operation>
howMany : Number
-
setTransformation( OperationA, OperationB, transformationFunction )
module:engine/model/operation/transform~setTransformation
protected
Sets a transformation function to be be used to transform instances of class
OperationA
by instances of classOperationB
.The
transformationFunction
is passed three parameters:a
- operation to be transformed, an instance ofOperationA
,b
- operation to be transformed by, an instance ofOperationB
,context
- object with additional information about transformation context.
The
transformationFunction
should return transformation result, which is an array with one or multiple operation instances.Parameters
OperationA : function
OperationB : function
transformationFunction : function
Function to use for transforming.
-
Transforms operation
a
by operationb
.Parameters
a : Operation
Operation to be transformed.
b : Operation
Operation to transform by.
context : TransformationContext
Transformation context for this transformation.
Returns
Array.<Operation>
Transformation result.
-
transformSets( operationsA, operationsB, options = { options.document, [options.useRelations], [options.padWithNoOps] } ) → Object
module:engine/model/operation/transform~transformSets
Performs a transformation of two sets of operations -
operationsA
andoperationsB
. The transformation is two-way - both transformedoperationsA
and transformedoperationsB
are returned.Note, that the first operation in each set should base on the same document state ( document version).
It is assumed that
operationsA
are "more important" during conflict resolution between two operations.New copies of both passed arrays and operations inside them are returned. Passed arguments are not altered.
Base versions of the transformed operations sets are updated accordingly. For example, assume that base versions are
4
and there are3
operations inoperationsA
and5
operations inoperationsB
. Then:- transformed
operationsA
will start from base version9
(4
base version +5
operations B), - transformed
operationsB
will start from base version7
(4
base version +3
operations A).
If no operation was broken into two during transformation, then both sets will end up with an operation that bases on version
11
:- transformed
operationsA
start from9
and there are3
of them, so the last will havebaseVersion
equal to11
, - transformed
operationsB
start from7
and there are5
of them, so the last will havebaseVersion
equal to11
.
Parameters
operationsA : Array.<Operation>
operationsB : Array.<Operation>
options : Object
Additional transformation options.
Propertiesoptions.document : Document | null
Document which the operations change.
[ options.useRelations ] : Boolean
Whether during transformation relations should be used (used during undo for better conflict resolution).
Defaults to
false
[ options.padWithNoOps ] : Boolean
Whether additional
NoOperation
s should be added to the transformation results to force the same last base version for both transformed sets (in case if some operations got broken into multiple operations during transformation).Defaults to
false
Returns
Object
Transformation result.
Array.<Operation>
return.operationsA Transformed
operationsA
.Array.<Operation>
return.operationsB Transformed
operationsB
.Map
return.originalOperations A map that links transformed operations to original operations. The keys are the transformed operations and the values are the original operations from the input (
operationsA
andoperationsB
).
- transformed
-
updateBaseVersions( operations, baseVersion )
module:engine/model/operation/transform~updateBaseVersions
private
An utility function that updates base versions of passed operations.
The function simply sets
baseVersion
as a base version of the first passed operation and then increments it for each following operation inoperations
.Parameters
operations : Array.<Operation>
Operations to update.
baseVersion : Number
Base version to set for the first operation in
operations
.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.