Skip to content

Class: BatchCommand\<TRow\>

Defined in: src/tree-editor/commands/batch.ts:10

Groups several commands so they undo/redo as a single unit.

Execute applies the commands in order. Undo reverses them in reverse order so each command’s undo runs against the state its execute left behind.

Type Parameters

TRow

TRow

Implements

Constructors

Constructor

new BatchCommand<TRow>(commands, description?): BatchCommand<TRow>

Defined in: src/tree-editor/commands/batch.ts:15

Parameters

commands

Command<TRow>[]

description?

string

Returns

BatchCommand<TRow>

Properties

description

readonly description: string

Defined in: src/tree-editor/commands/batch.ts:12

Human-readable description for undo/redo UI.

Implementation of

Command.description


type

readonly type: "batch" = 'batch'

Defined in: src/tree-editor/commands/batch.ts:11

Unique command type identifier (e.g., ‘add-node’, ‘move-node’).

Implementation of

Command.type

Methods

execute()

execute(state): TreeState<TRow>

Defined in: src/tree-editor/commands/batch.ts:20

Apply the mutation. Returns the new tree state.

Parameters

state

TreeState<TRow>

Returns

TreeState<TRow>

Implementation of

Command.execute


undo()

undo(state): TreeState<TRow>

Defined in: src/tree-editor/commands/batch.ts:26

Reverse the mutation. Returns the previous tree state.

Parameters

state

TreeState<TRow>

Returns

TreeState<TRow>

Implementation of

Command.undo