engine/model/operation/transform
Interfaces
module:engine/model/operation/transform~TransformOperationSetsResult
Type Definitions
module:engine/model/operation/transform~TransformationContext
Functions
module:engine/model/operation/transform~transformTransforms operation
aby operationb.Parameters
a : OperationOperation to be transformed.
b : OperationOperation to transform by.
context : TransformationContextTransformation context for this transformation.
Defaults to
{}
Returns
Array<Operation>Transformation result.
transformOperationSets( operationsA, operationsB, options = { options.document, [options.forceWeakRemove], [options.padWithNoOps], [options.useRelations] } ) → TransformOperationSetsResultmodule:engine/model/operation/transform~transformOperationSetsPerforms a transformation of two sets of operations -
operationsAandoperationsB. The transformation is two-way - both transformedoperationsAand transformedoperationsBare returned.Note, that the first operation in each set should base on the same document state ( document version).
It is assumed that
operationsAare "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
4and there are3operations inoperationsAand5operations inoperationsB. Then:- transformed
operationsAwill start from base version9(4base version +5operations B), - transformed
operationsBwill start from base version7(4base version +3operations 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
operationsAstart from9and there are3of them, so the last will havebaseVersionequal to11, - transformed
operationsBstart from7and there are5of them, so the last will havebaseVersionequal to11.
Parameters
operationsA : Array<Operation>operationsB : Array<Operation>options : objectAdditional transformation options.
Propertiesoptions.document : ModelDocumentDocument which the operations change.
[ options.forceWeakRemove ] : booleanIf set to
false, remove operation will be always stronger than move operation, so the removed nodes won't end up back in the document root. When set totrue, context data will be used.[ options.padWithNoOps ] : booleanWhether additional
NoOperations 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).[ options.useRelations ] : booleanWhether during transformation relations should be used (used during undo for better conflict resolution).
Returns
TransformOperationSetsResultTransformation result.
- transformed