Skip to content
D
Documentation

Commands — classes r–u

reference
7 min readUpdated

Classes R–U

Import these from @grafloria/engine.

Classes

RemoveStrokesCommand

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

One eraser SWEEP — however many strokes it crossed — is ONE undo step.

ts
class RemoveStrokesCommand extends Command

Methods

  • constructor(private readonly strokeIds: readonly 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 serialize(): SerializedCommand — Serialize command

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.

This is that seam.

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

SetLinkPointsCommand

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

Replace a link's points (its routed polyline, including any user waypoints), undoable.

Waypoint editing — add / move / remove a vertex — used to mutate link.points directly through {@link WaypointEditor }, which meant NONE of it was undoable: Ctrl+Z after dragging a vertex did nothing (or, worse, rewound some unrelated earlier command). Every vertex gesture now commits exactly one of these at pointer-up.

hasManualWaypoints is part of the state being changed: the renderer only preserves interior points when that metadata flag is set, so undoing back to a 2-point route must also clear it or the old vertices would be resurrected on the next re-route.

ts
class SetLinkPointsCommand extends Command

Methods

  • constructor( private linkId: string, newPoints: Point[], oldPoints?: Point[] )
  • 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 vertex gesture = one undo step; never merge two of them.
  • 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

SetStrokePointsCommand

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

Replace an ink stroke's point list, undoable. The stroke-edit tool's commit: a drag that translates a stroke ends in exactly ONE of these at pointer-up.

Mirrors {@link SetLinkPointsCommand }, minus the hasManualWaypoints bookkeeping — a stroke's points are ALWAYS authored content (nothing re-routes them), so there is no derived/manual flag to keep in step.

One gesture therefore puts ONE op on the wire — never per-pointermove spam, never a class instance.

The FROM snapshot is taken from the model on first execute() when the caller did not supply one — but the stroke-edit tool DOES supply it (the gesture-start geometry), because by commit time a live-feedback path may already have the model sitting at TO, and a FROM read then would make undo a no-op.

ts
class SetStrokePointsCommand extends Command

Methods

  • constructor( private strokeId: string, newPoints: readonly StrokePoint[], oldPoints?: readonly StrokePoint[] )
  • 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 edit gesture = one undo step; never merge two of them.
  • 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

Was this page helpful?

Commands — classes r–u — Grafloria