# Classes R–U

Import these from `@grafloria/engine`.

## Classes

### `ResizeNodeCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class ResizeNodeCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, newSize: Size, oldSize?: Size )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override canMergeWith(other: Command): boolean` — Check if can merge with another command
- `override mergeWith(other: Command): Command` — Merge with another command
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `RotateNodeCommand`

Also has every member of `Command`, listed on its own entry.

Rotate a node to an absolute angle (degrees), undoable.

Mirrors {@link ResizeNodeCommand }: `oldRotation` is captured on first execute
when the caller did not supply it, so a command built from a live gesture (the
model already sits at its final angle) still restores the pre-gesture angle.

```ts
class RotateNodeCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, newRotation: number, oldRotation?: number, options: RotateNodeCommandOptions = {} )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override canMergeWith(other: Command): boolean` — Check if can merge with another command
- `override mergeWith(other: Command): Command` — Merge with another command
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SendNodeToBackCommand`

Also has every member of `Command`, listed on its own entry.

Drop a node behind every other node in the diagram.

```ts
class SendNodeToBackCommand extends NodeZOrderCommand
```

**Methods**

- `constructor(nodeId: string)`
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone

### `SetFlexItemCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetFlexItemCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, private flexConfig: FlexItemConfig )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetGridItemCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetGridItemCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, private gridConfig: GridItemConfig )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetLayoutCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetLayoutCommand extends Command
```

**Methods**

- `constructor( private groupId: string, private layoutType: 'flexbox' | 'grid', private layoutConfig: LayoutConfig )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetLinkDisplayLabelCommand`

Also has every member of `Command`, listed on its own entry.

Set a link's display label — the `metadata.label` dialect — undoable.

Links carry TWO label dialects: the POSITIONED `labels[]` collection
({@link SetLinkLabelCommand } edits those) and the canonical display label
every spec input writes (`edges: [{ label: 'in stock' }]` →
`link.setLabel()` → `metadata.label`, painted at the path's midpoint by the
SVG renderer). The second dialect had no command at all, so the label a
demo/e2e/user actually SEES on an edge could not be edited undoably — the
in-place editor only knew `labels[]`, which that edge does not have. The exact twin of {@link SetNodeLabelCommand }, for the same reason.

```ts
class SetLinkDisplayLabelCommand extends Command
```

**Methods**

- `constructor( private linkId: string, newLabel: string, oldLabel?: string )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override canMergeWith(): boolean` — One editor session = one undo step.
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetLinkLabelCommand`

Also has every member of `Command`, listed on its own entry.

Set the text of one of a link's labels, undoable.

The inline label editor commits through this command, so an edge-label edit
is one undo step like every other direct-manipulation edit.

```ts
class SetLinkLabelCommand extends Command
```

**Methods**

- `constructor( private linkId: string, private labelIndex: number, newText: string, oldText?: string )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override canMergeWith(): boolean` — One editor session = one undo step.
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetLinkLabelsCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetLinkLabelsCommand extends Command
```

**Methods**

- `constructor( private readonly linkId: string, private readonly labels: LinkLabel[] )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetLinkPathTypeCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetLinkPathTypeCommand extends Command
```

**Methods**

- `constructor( private readonly linkId: string, private readonly pathType: LinkPathType )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetNodeDataCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetNodeDataCommand extends Command
```

**Methods**

- `constructor( nodeId: string | readonly string[], private readonly data: Readonly<Record<string, unknown>> )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetNodeLabelCommand`

Also has every member of `Command`, listed on its own entry.

Set a node's label text, undoable.

A node's label lives in metadata under `label` (that is what
`SVGRenderer.renderNodeLabel` reads), so this command is the metadata write
plus the dirty flag the renderer needs to repaint. It exists because in-place
text editing must be ONE undo step like every other direct manipulation —
before this, nothing in the command layer could touch a label.

```ts
class SetNodeLabelCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, newLabel: string, oldLabel?: string )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override canMergeWith(): boolean` — Never merge: each committed edit (one editor session) is one undo step.
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetNodeShapeConfigCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetNodeShapeConfigCommand extends Command
```

**Methods**

- `constructor( private readonly nodeId: string, private readonly patch: Readonly<Record<string, unknown>> )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetNodeStyleCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetNodeStyleCommand extends Command
```

**Methods**

- `constructor( nodeId: string | readonly string[], private readonly style: Partial<NodeStyle> )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `SetNodeZIndexCommand`

Also has every member of `Command`, listed on its own entry.

Set a node's stacking index to an explicit value.

```ts
class SetNodeZIndexCommand extends NodeZOrderCommand
```

**Methods**

- `constructor(nodeId: string, private zIndex: number)`
- `override canMergeWith(other: Command): boolean` — Check if can merge with another command
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone

### `SetParentCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class SetParentCommand extends Command
```

**Methods**

- `constructor( private nodeId: string, private newParentId?: string )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI

### `UpdateLinkStyleCommand`

Also has every member of `Command`, listed on its own entry.

```ts
class UpdateLinkStyleCommand extends Command
```

**Methods**

- `constructor( private readonly linkId: string, private readonly style: Partial<LinkStyle> )`
- `override execute(context: CommandContext): void` — Execute the command
- `override undo(context: CommandContext): void` — Undo the command
- `override canExecute(context: CommandContext): boolean` — Check if command can be executed
- `override canUndo(context: CommandContext): boolean` — Check if command can be undone
- `override serialize(): SerializedCommand` — Serialize command
- `override getDescription(): string` — Get description for UI
