diff --git a/packages/editor/api-report.md b/packages/editor/api-report.md index a11a681c1..633966eac 100644 --- a/packages/editor/api-report.md +++ b/packages/editor/api-report.md @@ -811,7 +811,7 @@ export class Editor extends EventEmitter { getViewportScreenBounds(): Box; getViewportScreenCenter(): Vec; getZoomLevel(): number; - groupShapes(shapes: TLShape[] | TLShapeId[], groupId?: TLShapeId): this; + groupShapes(shapes: TLShape[] | TLShapeId[], groupId?: TLShapeId, options?: TLGroupShapesOptions): this; hasAncestor(shape: TLShape | TLShapeId | undefined, ancestorId: TLShapeId): boolean; readonly history: HistoryManager; inputs: { diff --git a/packages/editor/src/lib/editor/Editor.ts b/packages/editor/src/lib/editor/Editor.ts index e260a8709..fb381d0ff 100644 --- a/packages/editor/src/lib/editor/Editor.ts +++ b/packages/editor/src/lib/editor/Editor.ts @@ -138,6 +138,11 @@ export type TLAnimationOptions = Partial<{ easing: (t: number) => number }> +/** @public */ +export type TLGroupShapesOptions = Partial<{ + selectAfterGrouping: boolean +}> + /** @public */ export type TLResizeShapeOptions = Partial<{ initialBounds: Box @@ -6582,7 +6587,11 @@ export class Editor extends EventEmitter { * * @public */ - groupShapes(shapes: TLShapeId[] | TLShape[], groupId = createShapeId()): this { + groupShapes( + shapes: TLShapeId[] | TLShape[], + groupId = createShapeId(), + options: TLGroupShapesOptions = { selectAfterGrouping: true } + ): this { if (!Array.isArray(shapes)) { throw Error('Editor.groupShapes: must provide an array of shapes or shape ids') } @@ -6632,7 +6641,9 @@ export class Editor extends EventEmitter { }, ]) this.reparentShapes(sortedShapeIds, groupId) - this.select(groupId) + if (options.selectAfterGrouping) { + this.select(groupId) + } }) return this