# engine/model/operation/transform

module

<a id="interfaces">

## Interfaces

<a id="interface-TransformOperationSetsResult">

### `TransformOperationSetsResult`

<a id="type-definitions">

## Type Definitions

<a id="typedef-TransformationContext">

### `TransformationContext`

<a id="functions">

## Functions

<a id="function-transform">

### `transform( a, b, context ) → Array<Operation>` _(internal)_

Transforms operation `a` by operation `b`.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/operation/transform.ts#L101)

#### 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.

<a id="function-transformOperationSets">

### `transformOperationSets( operationsA, operationsB, options = { options.document, options.forceWeakRemove?, options.padWithNoOps?, options.useRelations? } ) → TransformOperationSetsResult`

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](module_engine_model_document-ModelDocument.md#member-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`.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/operation/transform.ts#L158)

#### Parameters

* `operationsA: Array<Operation>`

* `operationsB: Array<Operation>`

* `options: object`

  Additional transformation options.

  Properties

  * `options.document: ModelDocument`

    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 [`NoOperation`](module_engine_model_operation_nooperation-NoOperation.md)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).

  * `options.useRelations?: boolean`

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

#### Returns

* `TransformOperationSetsResult`

  Transformation result.

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
