Module

engine/model/operation/transform

@ckeditor/ckeditor5-engine/src/model/operation/transform

module

Filtering

Interfaces

Type Definitions

Functions

  • transform( a, b, context ) → Array<Operation>

    Transforms operation a by operation b.

    Parameters

    a : Operation

    Operation to be transformed.

    b : Operation

    Operation to transform by.

    context : TransformationContext

    Transformation context for this transformation.

    Defaults to {}

    Returns

    Array<Operation>

    Transformation result.

  • transformSets( operationsA, operationsB, options = { options.document, [options.forceWeakRemove], [options.padWithNoOps], [options.useRelations] } ) → TransformSetsResult

    Performs a transformation of two sets of operations - operationsA and operationsB. The transformation is two-way - both transformed operationsA and transformed operationsB 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 are 3 operations in operationsA and 5 operations in operationsB. Then:

    • transformed operationsA will start from base version 9 (4 base version + 5 operations B),
    • transformed operationsB will start from base version 7 (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 from 9 and there are 3 of them, so the last will have baseVersion equal to 11,
    • transformed operationsB start from 7 and there are 5 of them, so the last will have baseVersion equal to 11.

    Parameters

    operationsA : Array<Operation>
    operationsB : Array<Operation>
    options : object

    Additional transformation options.

    Properties
    options.document : Document

    Document which the operations change.

    [ options.forceWeakRemove ] : boolean

    If 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 to true, context data will be used.

    [ options.padWithNoOps ] : boolean

    Whether 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 ] : boolean

    Whether during transformation relations should be used (used during undo for better conflict resolution).

    Returns

    TransformSetsResult

    Transformation result.