Skip to content

Class: AddNodeCommand\<TRow\>

Defined in: src/tree-editor/commands/add-node.ts:25

Inserts a new node under parentId (or as a root when parentId is null) at index — appended when index is omitted.

Undo removes the node from its parent’s child list and from nodes. Because the command captures the resolved insertion index at execute time, undo restores the exact ordering of siblings.

Type Parameters

TRow

TRow

Implements

Constructors

Constructor

new AddNodeCommand<TRow>(options): AddNodeCommand<TRow>

Defined in: src/tree-editor/commands/add-node.ts:35

Parameters

options

AddNodeOptions<TRow>

Returns

AddNodeCommand<TRow>

Properties

description

readonly description: string

Defined in: src/tree-editor/commands/add-node.ts:27

Human-readable description for undo/redo UI.

Implementation of

Command.description


type

readonly type: "add-node" = 'add-node'

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

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/add-node.ts:46

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/add-node.ts:81

Reverse the mutation. Returns the previous tree state.

Parameters

state

TreeState<TRow>

Returns

TreeState<TRow>

Implementation of

Command.undo