[@acaldas/document-model-libs](../README.md) / [Exports](../modules.md) / [Document](Document.md) / actions

# Namespace: actions

[Document](Document.md).actions

## Actions Functions

### loadState

▸ **loadState**(`state`, `operations`): `LoadStateAction`

Replaces the state of the document.

**`Remarks`**

This action shouldn't be used directly. It is dispatched by the [prune](Document.actions.md#prune) action.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `state` | `Pick`<`Document`<`unknown`, `Action`<`string`\>\>, ``"name"`` \| ``"data"``\> | State to be set in the document. |
| `operations` | `number` | Number of operations that were removed from the previous state. |

#### Returns

`LoadStateAction`

#### Defined in

[src/document/actions/creators.ts:63](https://github.com/acaldas/document-model-libs/blob/8be7e70/src/document/actions/creators.ts#L63)

___

### prune

▸ **prune**(`start?`, `end?`): `PruneAction`

Joins multiple operations into a single [LOAD_STATE](Document.actions.md#loadstate) operation.

**`Remarks`**

Useful to keep operations history smaller. Operations to prune are selected by index,
similar to the [slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) method in Arrays.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `start?` | `number` | Index of the first operation to prune |
| `end?` | `number` | Index of the last operation to prune |

#### Returns

`PruneAction`

#### Defined in

[src/document/actions/creators.ts:50](https://github.com/acaldas/document-model-libs/blob/8be7e70/src/document/actions/creators.ts#L50)

___

### redo

▸ **redo**(`count?`): `RedoAction`

Cancels the last `count` [UNDO](Document.actions.md#undo) operations.

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `count` | `number` | `1` | Number of UNDO operations to cancel |

#### Returns

`RedoAction`

#### Defined in

[src/document/actions/creators.ts:36](https://github.com/acaldas/document-model-libs/blob/8be7e70/src/document/actions/creators.ts#L36)

___

### setName

▸ **setName**(`name`): `SetNameAction`

Changes the name of the document.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name to be set in the document. |

#### Returns

`SetNameAction`

#### Defined in

[src/document/actions/creators.ts:18](https://github.com/acaldas/document-model-libs/blob/8be7e70/src/document/actions/creators.ts#L18)

___

### undo

▸ **undo**(`count?`): `UndoAction`

Cancels the last `count` operations.

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `count` | `number` | `1` | Number of operations to cancel |

#### Returns

`UndoAction`

#### Defined in

[src/document/actions/creators.ts:27](https://github.com/acaldas/document-model-libs/blob/8be7e70/src/document/actions/creators.ts#L27)
