# Batch

class

A batch instance groups model changes ([operations](module_engine_model_operation_operation-Operation.md)). All operations grouped in a single batch can be reverted together, so you can also think about a batch as of a single undo step. If you want to extend a given undo step, you can add more changes to the batch using [`enqueueChange`](module_engine_model_model-Model.md#function-enqueueChange:DEFAULT_BATCH):

```typescript
model.enqueueChange( batch, writer => {
	writer.insertText( 'foo', paragraph, 'end' );
} );
```

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

<a id="properties">

## Properties

<a id="member-baseVersion">

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

Returns the base version of this batch, which is equal to the base version of the first operation in the batch. If there are no operations in the batch or neither operation has the base version set, it returns `null`.

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

<a id="member-isLocal">

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

Whether the batch includes operations created locally (`true`) or operations created on other, remote editors (`false`).

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

<a id="member-isTyping">

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

Whether the batch includes operations connected with typing.

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

<a id="member-isUndo">

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

Whether the batch was created by the undo feature and undoes other operations.

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

<a id="member-isUndoable">

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

Whether the batch can be undone through the undo feature.

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

<a id="member-operations">

### `operations: Array<Operation>` _(readonly)_

An array of operations that compose this batch.

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

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( type )`

Creates a batch instance.

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

#### Parameters

* `type: BatchType`

  A set of flags that specify the type of the batch. Batch type can alter how some of the features work when encountering a given `Batch` instance (for example, when a feature listens to applied operations).

  Defaults to `{}`

#### Related:

* [Model#enqueueChange](module_engine_model_model-Model.md#function-enqueueChange:DEFAULT_BATCH)
* [Model#change](module_engine_model_model-Model.md#function-change)

<a id="function-addOperation">

### `addOperation( operation ) → Operation`

Adds an operation to the batch instance.

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

#### Parameters

* `operation: Operation`

  An operation to add.

#### Returns

* `Operation`

  The added operation.

---

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