Skip to content
D
Documentation

classes a–r

reference
8 min readUpdated

Import these from @grafloria/engine.

Classes

AddGroupCommand

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

ts
class AddGroupCommand extends Command

Methods

  • constructor(private group: GroupModel)
  • 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

AddLinkCommand

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

ts
class AddLinkCommand extends Command

Methods

  • constructor(private link: LinkModel)
  • 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

AddNodeCommand

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

ts
class AddNodeCommand extends Command

Methods

  • constructor(private node: NodeModel)
  • 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

AddPortCommand

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

ts
class AddPortCommand extends Command

Methods

  • constructor( private nodeId: string, port: PortModel )
  • 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

AddStrokeCommand

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

ts
class AddStrokeCommand extends Command

Methods

  • constructor(private readonly stroke: StrokeModel)
  • 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

AddToGroupCommand

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

Adds a node, link or group to a group, as one undoable step.

A member that joins from outside the frame is taken in: the frame grows (it never shrinks) to contain the member plus the group's padding and header band, and each enclosing group grows to contain the grown frame — GroupModel.addMember does that itself, on every path. On top of it, a group with no frame yet gets one fitted around its members here. Undo removes the member and puts every frame back exactly as it was.

Frames that something else owns are left alone (see GroupModel.ownsItsFrame): a collapsed group, a layout container, a lane or pool, a confining group, and a group drawn without a frame.

ts
class AddToGroupCommand extends Command

Methods

  • constructor( private groupId: string, private entityId: 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

AlignCommand

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

Align the selected nodes to a shared edge or centre line.

ts
class AlignCommand extends MultiNodeArrangeCommand

Methods

  • constructor(nodeIds: string[], private readonly edge: AlignEdge)
  • 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
  • override serialize(): SerializedCommand — Serialize command

BatchCommand

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

ts
class BatchCommand extends Command

Methods

  • constructor( name: string, private commands: Command[] )
  • async execute(context: CommandContext): Promise<void> — Execute the command
  • async undo(context: CommandContext): Promise<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
  • getCommands(): ReadonlyArray<Command> — Get all commands in batch
  • addCommand(command: Command): void — Add command to batch

BringNodeToFrontCommand

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

Lift a node above every other node in the diagram.

ts
class BringNodeToFrontCommand 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

CollapseGroupCommand

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

ts
class CollapseGroupCommand extends Command

Methods

  • constructor( private groupId: string, private options?: CollapseOptions )
  • 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

Command

ts
abstract class Command

Properties

NameTypeDefaultDescription
idstring
namestring
timestampnumber

Methods

  • constructor(name: string)
  • abstract execute(context: CommandContext): void | Promise<void> — Execute the command
  • abstract undo(context: CommandContext): void | Promise<void> — Undo the command
  • redo(context: CommandContext): void | Promise<void> — Redo the command (default: re-execute)
  • canExecute(context: CommandContext): boolean — Check if command can be executed
  • canUndo(context: CommandContext): boolean — Check if command can be undone
  • isUndoable(): boolean — Does this command belong on the undo stack AT ALL?
  • canMergeWith(other: Command): boolean — Check if can merge with another command
  • mergeWith(other: Command): Command — Merge with another command
  • abstract serialize(): SerializedCommand — Serialize command
  • getDescription(): string — Get description for UI

CommandManager

ts
class CommandManager

Methods

  • constructor( private context: CommandContext, private eventBus: EventBus = context.eventBus )
  • async execute(command: Command): Promise<void> — Execute a command
  • async undo(): Promise<void> — Undo last command
  • async redo(): Promise<void> — Redo command
  • beginBatch(): void — Begin batch mode
  • async endBatch(name: string = 'Batch Operation'): Promise<void> — End batch mode: commit the queued commands as ONE BatchCommand through the normal execute() path — one history entry, one undo step (with reverse-order undo), and the same strict-validation gate as any other command.
  • cancelBatch(): void — Cancel batch
  • clear(): void — Clear history
  • canUndo(): boolean — Can undo
  • canRedo(): boolean — Can redo
  • getHistory(): ReadonlyArray<CommandHistoryEntry> — Get history
  • getUndoStack(): ReadonlyArray<Command> — Get undo stack
  • getRedoStack(): ReadonlyArray<Command> — Get redo stack
  • setMaxHistorySize(size: number): void — Set max history size
  • setMergingEnabled(enabled: boolean): void — Enable/disable merging
  • setMergingWindow(milliseconds: number): void — Set merging window
  • updateContext(updates: Partial<CommandContext>): void — Update command context

CopyCommand

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

CopyCommand copies selected entities to clipboard

Features:

  • Copies selected nodes
  • Includes links between selected nodes
  • Optionally includes groups containing selected nodes
  • Non-destructive (doesn't modify diagram)
ts
class CopyCommand extends Command

Methods

  • constructor( private clipboard: ClipboardManager, private options: { includeGroups?: boolean; includeLinks?: boolean; } = {} )
  • 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 isUndoable(): boolean — Does this command belong on the undo stack AT ALL?
  • override serialize(): SerializedCommand — Serialize command
  • override getDescription(): string — Get description for UI

DeleteSelectionCommand

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

DeleteSelectionCommand deletes selected entities from diagram

Features:

  • Deletes selected nodes, links, and groups
  • Recursively deletes child nodes
  • Removes links connected to deleted nodes
  • Removes nodes from groups they belong to
  • Stores all deleted data for undo
  • Supports undo/redo
ts
class DeleteSelectionCommand extends Command

Methods

  • constructor( private options: { deleteChildren?: boolean; deleteLinks?: boolean; } = {} )
  • override execute(context: CommandContext): void — Execute the command
  • override undo(context: CommandContext): void — Undo the command
  • override redo(context: CommandContext): void — Redo re-applies the RECORDED deletion instead of re-running execute().
  • 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

DistributeCommand

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

Space the selected nodes with EQUAL GAPS along an axis; the two extreme nodes stay put and the interior ones are redistributed between them.

ts
class DistributeCommand extends MultiNodeArrangeCommand

Methods

  • constructor(nodeIds: string[], private readonly axis: DistributeAxis)
  • 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
  • override serialize(): SerializedCommand — Serialize command

DuplicateCommand

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

DuplicateCommand duplicates selected entities in the diagram

Features:

  • Generates new IDs for duplicated entities
  • Remaps relationships (links, groups, hierarchy)
  • Applies position offset
  • Preserves all properties (transforms, layout configs, etc.)
  • Supports undo/redo
  • Similar to paste but operates directly on selection
ts
class DuplicateCommand extends Command

Methods

  • constructor( private options: { offset?: Point; selectDuplicated?: boolean; } = {} )
  • 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

ExpandGroupCommand

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

ts
class ExpandGroupCommand extends Command

Methods

  • constructor(private groupId: 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

MacroCommand

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

ts
class MacroCommand extends Command

Methods

  • constructor(name: string)
  • addStep(command: Command, delay?: number): void — Add step to macro
  • addSteps(commands: Command[]): void — Add multiple steps
  • async execute(context: CommandContext): Promise<void> — Execute the command
  • async undo(context: CommandContext): Promise<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
  • getSteps(): ReadonlyArray<MacroStep> — Get all steps in macro
  • clear(): void — Clear all steps

MoveGroupCommand

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

ts
class MoveGroupCommand extends Command

Methods

  • constructor( private readonly nodeMoves: GroupNodeMove[], private readonly frameMoves: GroupFrameMove[] )
  • 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
  • isNoop(): boolean — True when the gesture actually moved something (drop == press is a no-op).
  • override serialize(): SerializedCommand — Serialize command
  • override getDescription(): string — Get description for UI

MoveNodeCommand

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

ts
class MoveNodeCommand extends Command

Methods

  • constructor( private nodeId: string, newPosition: Point, oldPosition?: Point, options: MoveNodeCommandOptions = {} )
  • 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

PasteCommand

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

PasteCommand pastes entities from clipboard into diagram

Features:

  • Generates new IDs for pasted entities
  • Remaps relationships (links, groups, hierarchy)
  • Applies position offset
  • Preserves all properties (transforms, layout configs, etc.)
  • Supports undo/redo
ts
class PasteCommand extends Command

Methods

  • constructor( private clipboard: ClipboardManager, private options: { offset?: Point; selectPasted?: boolean; } = {} )
  • 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

ReconnectLinkCommand

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

ts
class ReconnectLinkCommand extends Command

Methods

  • constructor( private linkId: string, private endpoint: LinkEndpoint, private newPortId: string, private newNodeId: string | undefined, private oldPortId: string, private oldNodeId: string | undefined )
  • override execute(context: CommandContext): void — Execute the command
  • override undo(context: CommandContext): void — Undo the command
  • override serialize(): SerializedCommand — Serialize command

RemoveFromGroupCommand

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

ts
class RemoveFromGroupCommand extends Command

Methods

  • constructor( private groupId: string, private entityId: 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

RemoveGroupCommand

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

ts
class RemoveGroupCommand extends Command

Methods

  • constructor(private groupId: 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

RemoveLinkCommand

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

ts
class RemoveLinkCommand extends Command

Methods

  • constructor(private linkId: 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

RemoveNodeCommand

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

ts
class RemoveNodeCommand extends Command

Methods

  • constructor(private nodeId: 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

RemovePortCommand

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

ts
class RemovePortCommand extends Command

Methods

  • constructor( private nodeId: string, private portId: 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

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

Was this page helpful?

classes a–r — Grafloria