Skip to content

API reference / Common / ShapeCommand

Type Alias: ShapeCommand ​

ts
type ShapeCommand = 
  | {
  insertShapes: {
     parent: ShapeNodeId | null;
     index: number;
     nodes: ShapeNode[];
  };
}
  | {
  pasteShapes: {
     parent: ShapeNodeId | null;
     index: number;
     fragment: ShapeFragment;
  };
}
  | {
  setShapeTransform: {
     id: ShapeNodeId;
     transform: ShapeTransform | null;
  };
}
  | {
  editShapeText: {
     id: ShapeNodeId;
     command: TextCommand;
  };
}
  | {
  addShapeText: {
     id: ShapeNodeId;
     story: TextStoryId;
     command: TextCommand;
  };
}
  | {
  editShapeTable: {
     id: ShapeNodeId;
     command: TableCommand;
  };
}
  | {
  updateShape: {
     node: ShapeNode;
  };
}
  | {
  deleteShapes: {
     ids: ShapeNodeId[];
  };
}
  | {
  reorderShapes: {
     ids: ShapeNodeId[];
     order: ShapeZOrder;
  };
}
  | {
  translateShapes: {
     ids: ShapeNodeId[];
     dx: number;
     dy: number;
  };
}
  | {
  rotateShapes: {
     ids: ShapeNodeId[];
     angle: number;
  };
}
  | {
  scaleShapes: {
     ids: ShapeNodeId[];
     sx: number;
     sy: number;
     anchorX: number;
     anchorY: number;
  };
}
  | {
  groupShapes: {
     ids: ShapeNodeId[];
     group: ShapeNodeId;
  };
}
  | {
  ungroupShapes: {
     ids: ShapeNodeId[];
  };
}
  | {
  flipShapes: {
     ids: ShapeNodeId[];
     axis: ShapeAxis;
  };
}
  | {
  alignShapes: {
     ids: ShapeNodeId[];
     edge: ShapeAlignEdge;
     frame?: AlignFrame;
  };
}
  | {
  distributeShapes: {
     ids: ShapeNodeId[];
     axis: ShapeAxis;
  };
}
  | {
  setShapeFill: {
     ids: ShapeNodeId[];
     fill: PaintFill;
  };
}
  | {
  setShapeLine: {
     ids: ShapeNodeId[];
     line: PaintLine;
  };
}
  | {
  setShapeAdjustValues: {
     id: ShapeNodeId;
     values: ShapeGeometryGuide[];
  };
}
  | {
  adjustShapeHandle: {
     id: ShapeNodeId;
     index: number;
     to: Point;
  };
};

An edit intent for a shape tree. The embedding doc type's editor turns one into CRDT writes (via execute) over the tree's root container; it never touches the model directly.

Serialize/Deserialize make a command a stable wire form — externally tagged by variant name — so a host can issue an edit as JSON and the same shape can be logged or replayed. Mirrors portable's PortableCommand, narrowed to the shape tree: there is no page, so an insert names a parent group (or the root) and an index; update / delete address nodes by id.