Skip to content

Class: MoveNodeCommand\<TRow\>

Defined in: src/tree-editor/commands/move-node.ts:50

Reparents a node under newParentId (or moves it to root when newParentId is null) at index — appended when index is omitted.

The entire subtree follows: only parentId of the moved node and the childIds of the old/new parent change.

Validators (built-in cycle/self plus any custom ones) run before mutation; failure throws MoveRejectedError and leaves state untouched.

Undo restores the original parent and sibling index.

Type Parameters

TRow

TRow

Implements

Constructors

Constructor

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

Defined in: src/tree-editor/commands/move-node.ts:65

Parameters

options

MoveNodeOptions<TRow>

Returns

MoveNodeCommand<TRow>

Properties

description

readonly description: string

Defined in: src/tree-editor/commands/move-node.ts:52

Human-readable description for undo/redo UI.

Implementation of

Command.description


type

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

Defined in: src/tree-editor/commands/move-node.ts:51

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/move-node.ts:77

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/move-node.ts:154

Reverse the mutation. Returns the previous tree state.

Parameters

state

TreeState<TRow>

Returns

TreeState<TRow>

Implementation of

Command.undo