add options arg

pull/3690/head
Taha 2024-05-03 12:30:03 +01:00
rodzic c308cc2edd
commit 9f1fe5dd5a
2 zmienionych plików z 14 dodań i 3 usunięć

Wyświetl plik

@ -811,7 +811,7 @@ export class Editor extends EventEmitter<TLEventMap> {
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<TLRecord>;
inputs: {

Wyświetl plik

@ -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<TLEventMap> {
*
* @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<TLEventMap> {
},
])
this.reparentShapes(sortedShapeIds, groupId)
this.select(groupId)
if (options.selectAfterGrouping) {
this.select(groupId)
}
})
return this