# SplitOperation

class

Operation to split [an element](module_engine_model_element-ModelElement.md) at given [split position](#member-splitPosition) into two elements, both containing a part of the element's original content.

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

<a id="properties">

## Properties

<a id="member-affectedSelectable">

### `affectedSelectable: ModelSelectable` _(readonly)_

A selectable that will be affected by the operation after it is executed.

The exact returned parameter differs between operation types.

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

<a id="member-baseVersion">

### `baseVersion: number | null` _(inherited)_

[`version`](module_engine_model_document-ModelDocument.md#member-version) on which operation can be applied. If you try to [apply](module_engine_model_model-Model.md#function-applyOperation) operation with different base version than the [document version](module_engine_model_document-ModelDocument.md#member-version) the [model-document-applyOperation-wrong-version](module_utils_ckeditorerror-CKEditorError.md) error is thrown.

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

<a id="member-batch">

### `batch: Batch | null` _(inherited)_

[Batch](module_engine_model_batch-Batch.md) to which the operation is added or `null` if the operation is not added to any batch yet.

Note, that a [non-document operation](#member-isDocumentOperation) has this property always set to `null`, and is never added to any batch.

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

<a id="member-graveyardPosition">

### `graveyardPosition: ModelPosition | null`

Position in the graveyard root before the element which should be used as a parent of the nodes after `position`. If it is not set, a copy of the the `position` parent will be used.

The default behavior is to clone the split element. Element from graveyard is used during undo.

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

<a id="member-howMany">

### `howMany: number`

Total offset size of elements that are in the split element after `position`.

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

<a id="member-insertionPosition">

### `insertionPosition: ModelPosition`

Position at which the clone of split element (or element from graveyard) will be inserted.

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

<a id="member-isDocumentOperation">

### `isDocumentOperation: boolean` _(readonly)_

Defines whether operation is executed on attached or detached [items](module_engine_model_item-ModelItem.md).

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

<a id="member-moveTargetPosition">

### `moveTargetPosition: ModelPosition` _(readonly)_

Position inside the new clone of a split element.

This is a position where nodes that are after the split position will be moved to.

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

<a id="member-movedRange">

### `movedRange: ModelRange` _(readonly)_

Artificial range that contains all the nodes from the split element that will be moved to the new element. The range starts at [`splitPosition`](#member-splitPosition) and ends in the same parent, at `POSITIVE_INFINITY` offset.

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

<a id="member-splitPosition">

### `splitPosition: ModelPosition`

Position at which an element should be split.

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

<a id="member-type">

### `type: 'split'` _(readonly)_

Operation type.

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

#### Static properties

<a id="static-member-className">

### `className: string` _(readonly)_

Name of the operation class used for serialization.

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

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( splitPosition, howMany, insertionPosition, graveyardPosition, baseVersion )`

Creates a split operation.

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

#### Parameters

* `splitPosition: ModelPosition`

  Position at which an element should be split.

* `howMany: number`

  Total offset size of elements that are in the split element after `position`.

* `insertionPosition: ModelPosition`

  Position at which the clone of split element (or element from graveyard) will be inserted.

* `graveyardPosition: ModelPosition | null`

  Position in the graveyard root before the element which should be used as a parent of the nodes after `position`. If it is not set, a copy of the the `position` parent will be used.

* `baseVersion: number | null`

  Document [`version`](module_engine_model_document-ModelDocument.md#member-version) on which operation can be applied or `null` if the operation operates on detached (non-document) tree.

<a id="function-clone">

### `clone() → SplitOperation`

Creates and returns an operation that has the same parameters as this operation.

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

#### Returns

* `SplitOperation`

  Clone of this operation.

<a id="function-getReversed">

### `getReversed() → Operation`

See [`Operation#getReversed()`](module_engine_model_operation_operation-Operation.md#function-getReversed).

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

#### Returns

* `Operation`

<a id="function-toJSON">

### `toJSON() → unknown`

Custom toJSON method to solve child-parent circular dependencies.

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

#### Returns

* `unknown`

  Clone of this object with the operation property replaced with string.

<a id="function-_execute">

### `_execute() → void` _(internal)_

Executes the operation - modifications described by the operation properties will be applied to the model tree.

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

#### Returns

* `void`

<a id="function-_validate">

### `_validate() → void` _(internal)_

Checks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.

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

#### Returns

* `void`

#### Static methods

<a id="static-function-fromJSON">

### `fromJSON( json, document ) → SplitOperation` _(static)_

Creates `SplitOperation` object from deserialized object, i.e. from parsed JSON string.

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

#### Parameters

* `json: any`

  Deserialized JSON object.

* `document: ModelDocument`

  Document on which this operation will be applied.

#### Returns

* `SplitOperation`

<a id="static-function-getInsertionPosition">

### `getInsertionPosition( splitPosition ) → ModelPosition` _(static)_

Helper function that returns a default insertion position basing on given `splitPosition`. The default insertion position is after the split element.

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

#### Parameters

* `splitPosition: ModelPosition`

#### Returns

* `ModelPosition`

---

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