Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(drawing): fix drawing group error (#6635)

VicKun73930971a535
diff --git a/packages/core/src/shared/shape.ts b/packages/core/src/shared/shape.ts
index 6212308efb..2c9d01b966 100644
--- a/packages/core/src/shared/shape.ts
+++ b/packages/core/src/shared/shape.ts
@@ -34,6 +34,13 @@ export interface ISrcRect extends IOffset {
bottom?: number;
}
+export interface IGroupBaseBound {
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+}
+
export interface IAbsoluteTransform extends ISize, IOffset, IScale {}
export interface IRectXYWH {
diff --git a/packages/core/src/types/interfaces/i-drawing.ts b/packages/core/src/types/interfaces/i-drawing.ts
index 5cc3453dd5..af09fa04ec 100644
--- a/packages/core/src/types/interfaces/i-drawing.ts
+++ b/packages/core/src/types/interfaces/i-drawing.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IAbsoluteTransform } from '../../shared/shape';
+import type { IAbsoluteTransform, IGroupBaseBound } from '../../shared/shape';
import type { Nullable } from '../../shared/types';
import type { BooleanNumber } from '../enum/text-style';
@@ -124,6 +124,11 @@ export interface IDrawingParam extends IDrawingSearch {
isMultiTransform?: BooleanNumber;
groupId?: string;
allowTransform?: boolean;
+ /**
+ * The base bound of the group, used to calculate the relative position of children in the group.
+ * It is only used when drawingType is DRAWING_GROUP.
+ */
+ groupBaseBound?: Nullable<IGroupBaseBound>;
}
// #endregion
diff --git a/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts b/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
index 4e25d83ad9..d48a01698a 100644
--- a/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/group-doc-drawing.command.ts
@@ -15,9 +15,9 @@
*/
import type { IAccessor, ICommand } from '@univerjs/core';
-import type { IDrawingGroupUpdateParam, IDrawingJsonUndo1 } from '@univerjs/drawing';
+import type { IDrawingGroupUpdateParam } from '@univerjs/drawing';
import { CommandType } from '@univerjs/core';
-import { IDocDrawingService } from '@univerjs/docs-drawing';
+// import { IDocDrawingService } from '@univerjs/docs-drawing';
/**
* The command to insert new defined name
@@ -26,22 +26,24 @@ export const GroupDocDrawingCommand: ICommand = {
id: 'doc.command.group-doc-image',
type: CommandType.COMMAND,
handler: (accessor: IAccessor, params?: IDrawingGroupUpdateParam[]) => {
- const docDrawingService = accessor.get(IDocDrawingService);
+ // const docDrawingService = accessor.get(IDocDrawingService);
- if (!params) return false;
+ // if (!params) return false;
- const unitIds: string[] = [];
- params.forEach(({ parent, children }) => {
- unitIds.push(parent.unitId);
- children.forEach((child) => {
- unitIds.push(child.unitId);
- });
- });
+ // // if the subunit is not a doc type, return false
+
+ // const unitIds: string[] = [];
+ // params.forEach(({ parent, children }) => {
+ // unitIds.push(parent.unitId);
+ // children.forEach((child) => {
+ // unitIds.push(child.unitId);
+ // });
+ // });
// execute do mutations and add undo mutations to undo stack if completed
- const jsonOp = docDrawingService.getGroupDrawingOp(params) as IDrawingJsonUndo1;
+ // const jsonOp = docDrawingService.getGroupDrawingOp(params) as IDrawingJsonUndo1;
- const { unitId, subUnitId, undo, redo, objects } = jsonOp;
+ // const { unitId, subUnitId, undo, redo, objects } = jsonOp;
// const result = commandService.syncExecuteCommand(SetDocDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DocDrawingApplyType.GROUP });
diff --git a/packages/docs-drawing-ui/src/commands/commands/utils.ts b/packages/docs-drawing-ui/src/commands/commands/utils.ts
index 6b5cebcdbe..a649d1a4ee 100644
--- a/packages/docs-drawing-ui/src/commands/commands/utils.ts
+++ b/packages/docs-drawing-ui/src/commands/commands/utils.ts
@@ -36,8 +36,8 @@ export function ungroupToGroup(ungroupParams: IDrawingGroupUpdateParam[]) {
drawingId,
transform: {
...transform,
- left: transform.left! - groupTransform.left,
- top: transform.top! - groupTransform.top,
+ // left: transform.left! - groupTransform.left,
+ // top: transform.top! - groupTransform.top,
},
groupId,
};
@@ -49,6 +49,12 @@ export function ungroupToGroup(ungroupParams: IDrawingGroupUpdateParam[]) {
drawingId: groupId,
drawingType: DrawingTypeEnum.DRAWING_GROUP,
transform: groupTransform,
+ groupBaseBound: {
+ left: groupTransform.left,
+ top: groupTransform.top,
+ width: groupTransform.width,
+ height: groupTransform.height,
+ },
} as IDrawingParam;
newGroupParams.push({
@@ -72,7 +78,7 @@ export function groupToUngroup(groupParams: IDrawingGroupUpdateParam[]) {
const newChildren = children.map((object) => {
const { transform } = object;
const { unitId, subUnitId, drawingId } = object;
- const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
+ const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0, parent.groupBaseBound);
return {
unitId,
subUnitId,
diff --git a/packages/drawing-ui/src/controllers/drawing-update.controller.ts b/packages/drawing-ui/src/controllers/drawing-update.controller.ts
index 632c4470da..440b60d444 100644
--- a/packages/drawing-ui/src/controllers/drawing-update.controller.ts
+++ b/packages/drawing-ui/src/controllers/drawing-update.controller.ts
@@ -26,7 +26,7 @@ import {
toDisposable,
} from '@univerjs/core';
import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService, SetDrawingSelectedOperation } from '@univerjs/drawing';
-import { DRAWING_OBJECT_LAYER_INDEX, Group, IRenderManagerService, RENDER_CLASS_TYPE } from '@univerjs/engine-render';
+import { DRAWING_OBJECT_LAYER_INDEX, DrawingGroupObject, Group, IRenderManagerService, RENDER_CLASS_TYPE } from '@univerjs/engine-render';
import { AlignType, SetDrawingAlignOperation } from '../commands/operations/drawing-align.operation';
import { CloseImageCropOperation } from '../commands/operations/image-crop.operation';
import { getUpdateParams } from '../utils/get-update-params';
@@ -229,13 +229,16 @@ export class DrawingUpdateController extends Disposable {
}
const groupKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId });
- const group = new Group(groupKey);
+ const group = new DrawingGroupObject(groupKey);
scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group);
group.addObjects(...objects);
+ if (parent.groupBaseBound) {
+ group.setBaseBound(parent.groupBaseBound);
+ }
// group.reCalculateObjects();
- parent.transform && group.transformByState({ left: parent.transform.left, top: parent.transform.top });
+ parent.transform && group.transformByState({ left: parent.transform.left, top: parent.transform.top, width: parent.transform.width, height: parent.transform.height, angle: parent.transform.angle });
transformer.clearSelectedObjects();
transformer.setSelectedControl(group);
diff --git a/packages/drawing-ui/src/controllers/utils.ts b/packages/drawing-ui/src/controllers/utils.ts
index 2d8f8f3e43..5a90c2ae05 100644
--- a/packages/drawing-ui/src/controllers/utils.ts
+++ b/packages/drawing-ui/src/controllers/utils.ts
@@ -19,7 +19,7 @@ import type { IDrawingManagerService } from '@univerjs/drawing';
import type { BaseObject, Scene } from '@univerjs/engine-render';
import { UniverInstanceType } from '@univerjs/core';
import { getDrawingShapeKeyByDrawingSearch } from '@univerjs/drawing';
-import { DRAWING_OBJECT_LAYER_INDEX, Group } from '@univerjs/engine-render';
+import { DRAWING_OBJECT_LAYER_INDEX, DrawingGroupObject, Group } from '@univerjs/engine-render';
export function insertGroupObject(objectParam: IDrawingSearch, object: BaseObject, scene: Scene, drawingManagerService: IDrawingManagerService) {
const groupParam = drawingManagerService.getDrawingByParam(objectParam);
@@ -35,23 +35,35 @@ export function insertGroupObject(objectParam: IDrawingSearch, object: BaseObjec
}
if (groupObject != null) {
+ const objects = groupObject.getObjects();
+ for (const obj of objects) {
+ if (obj.oKey === object.oKey) {
+ return;
+ }
+ }
groupObject.addObject(object);
return;
}
- const group = new Group(groupKey);
+ const group = new DrawingGroupObject(groupKey);
scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group);
group.addObject(object);
- const { transform } = groupParam;
+ const { transform, groupBaseBound } = groupParam;
+
+ if (groupBaseBound) {
+ group.setBaseBound(groupBaseBound);
+ }
transform && group.transformByState(
{
left: transform.left,
top: transform.top,
angle: transform.angle,
+ width: transform.width,
+ height: transform.height,
}
);
}
diff --git a/packages/drawing-ui/src/views/panel/DrawingGroup.tsx b/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
index da8b789d50..e220d68989 100644
--- a/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
+++ b/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
@@ -53,6 +53,12 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
drawingId: groupId,
drawingType: DrawingTypeEnum.DRAWING_GROUP,
transform: groupTransform,
+ groupBaseBound: {
+ left: groupTransform.left,
+ top: groupTransform.top,
+ width: groupTransform.width,
+ height: groupTransform.height,
+ },
} as IDrawingParam;
const children = focusDrawings.map((drawing) => {
@@ -64,8 +70,8 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
drawingId,
transform: {
...transform,
- left: transform.left! - groupTransform.left,
- top: transform.top! - groupTransform.top,
+ // left: transform.left! - groupTransform.left,
+ // top: transform.top! - groupTransform.top,
},
groupId,
};
@@ -82,7 +88,7 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
return;
}
- const { unitId, subUnitId, drawingId, transform: groupTransform = { width: 0, height: 0 } } = param;
+ const { unitId, subUnitId, drawingId, transform: groupTransform = { width: 0, height: 0 }, groupBaseBound } = param;
if (groupTransform == null) {
return;
@@ -97,7 +103,7 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
const children = objects.map((object) => {
const { transform } = object;
const { unitId, subUnitId, drawingId } = object;
- const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
+ const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0, groupBaseBound);
return {
unitId,
subUnitId,
diff --git a/packages/engine-render/src/base-object.ts b/packages/engine-render/src/base-object.ts
index fbf3ccecc0..ffa7ed6a1e 100644
--- a/packages/engine-render/src/base-object.ts
+++ b/packages/engine-render/src/base-object.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IKeyValue, ITransformState, Nullable } from '@univerjs/core';
+import type { IGroupBaseBound, IKeyValue, ITransformState, Nullable } from '@univerjs/core';
import type { IDragEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
import type { IObjectFullState, ITransformChangeState } from './basics/interfaces';
@@ -25,6 +25,7 @@ import type { Engine } from './engine';
import type { Layer } from './layer';
import type { Scene } from './scene';
import { Disposable, EventSubject } from '@univerjs/core';
+import { getRenderTransformBaseOnParentBound } from './basics';
import { CURSOR_TYPE, RENDER_CLASS_TYPE } from './basics/const';
import { TRANSFORM_CHANGE_OBSERVABLE_TYPE } from './basics/interfaces';
import { generateRandomKey, toPx } from './basics/tools';
@@ -58,6 +59,7 @@ export enum ObjectType {
export abstract class BaseObject extends Disposable {
groupKey?: string;
isInGroup: boolean = false;
+ isDrawingObject: boolean = false;
objectType: ObjectType = ObjectType.UNKNOWN;
@@ -603,6 +605,46 @@ export abstract class BaseObject extends Disposable {
};
}
+ getRealBound(): IGroupBaseBound {
+ let { width: realWidth, height: realHeight, left: realLeft, top: realTop } = this;
+ let baseBound;
+ if (this.isInGroup && this.parent?.classType === RENDER_CLASS_TYPE.GROUP && this.parent?.getBaseBound) {
+ baseBound = this.parent.getBaseBound();
+ }
+ if (baseBound) {
+ const parentState = this.getParent();
+ const parentBound = {
+ top: parentState.top || 0,
+ left: parentState.left,
+ width: parentState.width || 0,
+ height: parentState.height || 0,
+ };
+ const realBound = getRenderTransformBaseOnParentBound(baseBound, parentBound, { width: realWidth, height: realHeight, left: realLeft, top: realTop });
+
+ realWidth = realBound.width;
+ realHeight = realBound.height;
+ realLeft = realBound.left - parentBound.left - parentBound.width / 2;
+ realTop = realBound.top - parentBound.top - parentBound.height / 2;
+
+ // const isParentFlipX = this.parent?.flipX;
+ // const isParentFlipY = this.parent?.flipY;
+ // const parentCenterX = parentBound.left + parentBound.width / 2;
+ // const parentCenterY = parentBound.top + parentBound.height / 2;
+ // if (isParentFlipX) {
+ // realLeft = 2 * parentCenterX - realLeft;
+ // }
+ // if (isParentFlipY) {
+ // realTop = 2 * parentCenterY - realTop;
+ // }
+ }
+ return {
+ left: realLeft,
+ top: realTop,
+ width: realWidth,
+ height: realHeight,
+ };
+ }
+
hide() {
this._visible = false;
this._makeDirtyMix();
diff --git a/packages/engine-render/src/basics/group-transform.ts b/packages/engine-render/src/basics/group-transform.ts
index 48b37924b6..9ec8680b5f 100644
--- a/packages/engine-render/src/basics/group-transform.ts
+++ b/packages/engine-render/src/basics/group-transform.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ITransformState } from '@univerjs/core';
+import type { IGroupBaseBound, ITransformState, Nullable } from '@univerjs/core';
import { offsetRotationAxis } from './offset-rotation-axis';
import { Vector2 } from './vector2';
@@ -46,24 +46,203 @@ export function getGroupState(parentLeft: number, parentTop: number, objectState
};
}
-export function transformObjectOutOfGroup(child: ITransformState, parent: ITransformState, groupOriginWidth: number, groupOriginHeight: number) {
+export function getDrawingGroupState(parentLeft: number, parentTop: number, objectStates: ITransformState[]) {
+ let groupLeft = Number.MAX_SAFE_INTEGER;
+ let groupTop = Number.MAX_SAFE_INTEGER;
+ let groupRight = Number.MIN_SAFE_INTEGER;
+ let groupBottom = Number.MIN_SAFE_INTEGER;
+
+ objectStates.forEach((o) => {
+ const { left = 0, top = 0, width = 0, height = 0 } = o;
+ groupLeft = Math.min(groupLeft, left);
+ groupTop = Math.min(groupTop, top);
+ groupRight = Math.max(groupRight, left + width);
+ groupBottom = Math.max(groupBottom, top + height);
+ });
+
+ const groupWidth = groupRight - groupLeft;
+ const groupHeight = groupBottom - groupTop;
+
+ return {
+ left: groupLeft,
+ top: groupTop,
+ width: groupWidth,
+ height: groupHeight,
+ angle: 0,
+ scaleX: 1,
+ scaleY: 1,
+ };
+}
+
+/**
+ * Transform a child object out of a group, computing its absolute position, angle, and flip state.
+ *
+ * When a DrawingGroup has a baseBound (chOff/chExt in OOXML), children store their positions
+ * in the baseBound coordinate space. This method first maps the child's position from baseBound
+ * space to the actual parent bound space, then applies group flip mirroring and rotation.
+ *
+ * @param child - The child's transform state (position in baseBound space if baseBound is provided)
+ * @param parent - The parent group's transform state (absolute position, angle, flip)
+ * @param groupOriginWidth - The original width of the group (used to compute group center)
+ * @param groupOriginHeight - The original height of the group (used to compute group center)
+ * @param baseBound - Optional. The group's baseBound (chOff/chExt). If provided, child coordinates
+ * are mapped from this space to the parent's actual bound space before transforming.
+ *
+ * @example
+ * // in excel, the group off & ext is the real position and size of the group, and the child position is relative to the group chOff/chExt. For example:
+ * ```xml
+ * <a:xfrm>
+ * <a:off x="1212850" y="889000"/>
+ * <a:ext cx="6813550" cy="4883150"/>
+ * <a:chOff x="1212850" y="889000"/>
+ * <a:chExt cx="6813550" cy="4883150"/>
+ * </a:xfrm>
+ * ```
+ */
+export function transformObjectOutOfGroup(
+ child: ITransformState,
+ parent: ITransformState,
+ groupOriginWidth: number,
+ groupOriginHeight: number,
+ baseBound: Nullable<IGroupBaseBound>
+) {
const { left = 0, top = 0, width = 0, height = 0, angle = 0 } = child;
- const { left: groupLeft = 0, top: groupTop = 0, angle: groupAngle = 0 } = parent;
+ const { left: groupLeft = 0, top: groupTop = 0, angle: groupAngle = 0, flipX: groupFlipX = false, flipY: groupFlipY = false } = parent;
+
+ // Map child position from baseBound space to actual parent bound space
+ let mappedLeft = left;
+ let mappedTop = top;
+ let mappedWidth = width;
+ let mappedHeight = height;
+
+ if (baseBound && baseBound.width > 0 && baseBound.height > 0) {
+ const parentBound: IGroupBaseBound = {
+ left: groupLeft,
+ top: groupTop,
+ width: groupOriginWidth,
+ height: groupOriginHeight,
+ };
+ const objectBound: IGroupBaseBound = { left, top, width, height };
+ const mapped = getRenderTransformBaseOnParentBound(baseBound, parentBound, objectBound);
+ mappedLeft = mapped.left;
+ mappedTop = mapped.top;
+ mappedWidth = mapped.width;
+ mappedHeight = mapped.height;
+ }
const groupCenterX = groupLeft + groupOriginWidth / 2;
const groupCenterY = groupTop + groupOriginHeight / 2;
- const objectX = left + groupLeft;
- const objectY = top + groupTop;
+ let flipX = child.flipX || false;
+ let flipY = child.flipY || false;
+
+ let objectX = mappedLeft;
+ let objectY = mappedTop;
+
+ if (groupFlipX) {
+ const objectCenterX = objectX + mappedWidth / 2;
+ const mirroredCenterX = 2 * groupCenterX - objectCenterX;
+ objectX = mirroredCenterX - mappedWidth / 2;
+ flipX = !flipX;
+ }
+
+ if (groupFlipY) {
+ const objectCenterY = objectY + mappedHeight / 2;
+ const mirroredCenterY = 2 * groupCenterY - objectCenterY;
+ objectY = mirroredCenterY - mappedHeight / 2;
+ flipY = !flipY;
+ }
- const objectCenterX = objectX + width / 2;
- const objectCenterY = objectY + height / 2;
+ const objectCenterX = objectX + mappedWidth / 2;
+ const objectCenterY = objectY + mappedHeight / 2;
- const finalPoint = offsetRotationAxis(new Vector2(groupCenterX, groupCenterY), groupAngle, new Vector2(objectX, objectY), new Vector2(objectCenterX, objectCenterY));
+ const finalPoint = offsetRotationAxis(
+ new Vector2(groupCenterX, groupCenterY),
+ groupAngle,
+ new Vector2(objectX, objectY),
+ new Vector2(objectCenterX, objectCenterY)
+ );
return {
left: finalPoint.x,
top: finalPoint.y,
+ width: mappedWidth,
+ height: mappedHeight,
angle: groupAngle + angle,
+ flipX,
+ flipY,
+ };
+}
+
+/**
+ * Get the rendered position and size of an object based on the group's baseBound and the parent's bound.
+ * @param baseBound The group's baseBound defining the coordinate space for its children,In Excel, this corresponds to chOff (child offset) and chExt (child extent) in OOXML.
+ * @param parentBound The bounding box of the parent context (e.g., the group or canvas) within which the object is rendered.
+ * @param objectBound The original bounding box of the object in the group's coordinate space.
+ * @returns {IGroupBaseBound} The transformed bound for rendering the object within the group context
+ */
+export function getRenderTransformBaseOnParentBound(baseBound: IGroupBaseBound, parentBound: IGroupBaseBound, objectBound: IGroupBaseBound): IGroupBaseBound {
+ if (!baseBound) {
+ return {
+ left: objectBound.left,
+ top: objectBound.top,
+ width: objectBound.width,
+ height: objectBound.height,
+ };
+ }
+ const { left, top, width, height } = baseBound;
+ const { left: parentLeft, top: parentTop, width: parentWidth, height: parentHeight } = parentBound;
+
+ const objectRelativeLeft = parentLeft + (objectBound.left - left) / width * parentWidth;
+ const objectRelativeTop = parentTop + (objectBound.top - top) / height * parentHeight;
+ const objectRelativeWidth = objectBound.width / width * parentWidth;
+ const objectRelativeHeight = objectBound.height / height * parentHeight;
+ return {
+ left: objectRelativeLeft,
+ top: objectRelativeTop,
+ width: objectRelativeWidth,
+ height: objectRelativeHeight,
+ };
+}
+
+/**
+ * In Excel, a rotated shape's bounding box for group calculations uses major axis switching.
+ * The axis-aligned bound depends on which 90° increment the rotation angle is closest to:
+ *
+ * [-45°, 45°) → 0° horizontal (original width/height)
+ * [45°, 135°) → 90° vertical (width/height swapped)
+ * [135°, 225°) → 180° horizontal (original width/height)
+ * [225°, 315°) → 270° vertical (width/height swapped)
+ *
+ * @param bound - The original axis-aligned bound { left, top, width, height }
+ * @param angle - The rotation angle in degrees
+ */
+export function getRotatedBoundInGroup(bound: IGroupBaseBound, angle: number): IGroupBaseBound {
+ const normalizedAngle = ((angle % 360) + 360) % 360;
+
+ const cx = bound.left + bound.width / 2;
+ const cy = bound.top + bound.height / 2;
+
+ const isHorizontalLike =
+ (normalizedAngle >= 315 || normalizedAngle < 45) ||
+ (normalizedAngle >= 135 && normalizedAngle < 225);
+
+ let width: number;
+ let height: number;
+
+ if (isHorizontalLike) {
+ width = bound.width;
+ height = bound.height;
+ } else {
+ // Major axis switch: swap width/height
+ width = bound.height;
+ height = bound.width;
+ }
+
+ return {
+ left: cx - width / 2,
+ top: cy - height / 2,
+ width,
+ height,
};
}
diff --git a/packages/engine-render/src/drawing-group.ts b/packages/engine-render/src/drawing-group.ts
new file mode 100644
index 0000000000..9e60f4300c
--- /dev/null
+++ b/packages/engine-render/src/drawing-group.ts
@@ -0,0 +1,154 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IGroupBaseBound } from '@univerjs/core';
+import type { BaseObject } from './base-object';
+import type { IViewportInfo, Vector2 } from './basics';
+import type { UniverRenderingContext } from './context';
+import { RENDER_CLASS_TYPE, Transform } from './basics';
+import { Group } from './group';
+
+export class DrawingGroupObject extends Group {
+ protected override _selfSizeMode: boolean = true;
+ /**
+ * Corresponds to chOff (child offset) and chExt (child extent) in OOXML.
+ * Describes the coordinate space of children within this group.
+ * Children store their absolute positions in this coordinate space.
+ * When rendering, positions are mapped from baseBound space to the group's current transform.
+ */
+ private _baseBound: IGroupBaseBound = {
+ left: 0,
+ top: 0,
+ width: 0,
+ height: 0,
+ };
+
+ /**
+ * Set the baseBound (chOff/chExt in OOXML) for this group.
+ * This defines the coordinate space of children within the group.
+ * When set, the group automatically enters selfSizeMode so its dimensions
+ * are tracked independently of children.
+ */
+ setBaseBound(bound: IGroupBaseBound) {
+ this._baseBound = { ...bound };
+ // When baseBound is set, the group manages its own dimensions
+ // this._selfSizeMode = true;
+ }
+
+ /**
+ * Get the baseBound (chOff/chExt in OOXML) for this group.
+ */
+ getBaseBound(): IGroupBaseBound {
+ return { ...this._baseBound };
+ }
+
+ /**
+ * Override ancestorTransform to use the same render transform as render(),
+ * which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
+ * instead of the standard transform translation.
+ * This ensures children (e.g., Image.isHit) that compose with
+ * parent.ancestorTransform get the correct coordinate space.
+ */
+ override get ancestorTransform(): Transform {
+ const realBound = this.getRealBound();
+ const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = realBound;
+ const m = this.transform.getMatrix();
+ const centerX = realLeft + realWidth / 2;
+ const centerY = realTop + realHeight / 2;
+ const renderTransform = new Transform([m[0], m[1], m[2], m[3], centerX, centerY]);
+
+ const parent = this.getParent();
+ if (this.isInGroup && parent?.classType === RENDER_CLASS_TYPE.GROUP) {
+ return parent.ancestorTransform.multiply(renderTransform);
+ }
+ return renderTransform;
+ }
+
+ // override getState() {
+ // return getDrawingGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
+ // }
+
+ override render(ctx: UniverRenderingContext, bounds: IViewportInfo): void {
+ const realBound = this.getRealBound();
+ const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = realBound;
+ ctx.save();
+ const m = this.transform.getMatrix();
+ const centerX = realLeft + realWidth / 2;
+ const centerY = realTop + realHeight / 2;
+ ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
+ const objects = this.getObjectsByOrder();
+
+ // ctx.rect(0, 0, this.width, this.height);
+ // ctx.strokeStyle = 'blue';
+ // ctx.stroke();
+
+ for (let i = 0; i < objects.length; i++) {
+ const object = objects[i];
+ object.render(ctx, bounds);
+ }
+
+ ctx.restore();
+ }
+
+ override addObjects(...objects: BaseObject[]) {
+ for (const object of objects) {
+ this.addObject(object);
+ }
+ }
+
+ override isHit(coord: Vector2): boolean {
+ // Build the same render transform used in render():
+ // [m[0], m[1], m[2], m[3], centerX, centerY]
+ const realBound = this.getRealBound();
+ const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = realBound;
+ const m = this.transform.getMatrix();
+ const centerX = realLeft + realWidth / 2;
+ const centerY = realTop + realHeight / 2;
+ const renderTransform = new Transform([m[0], m[1], m[2], m[3], centerX, centerY]);
+
+ // Account for parent group transforms if applicable
+ const parent = this.getParent();
+ const effectiveTransform = this.isInGroup && parent?.classType === RENDER_CLASS_TYPE.GROUP
+ ? parent.ancestorTransform.multiply(renderTransform)
+ : renderTransform;
+
+ // Transform world coord to group's local space (center-based)
+ const oCoord = effectiveTransform.invert().applyPoint(coord);
+ const halfWidth = realWidth / 2;
+ const halfHeight = realHeight / 2;
+
+ // Check group bounding box first
+ if (
+ oCoord.x < -halfWidth ||
+ oCoord.x > halfWidth ||
+ oCoord.y < -halfHeight ||
+ oCoord.y > halfHeight
+ ) {
+ return false;
+ }
+
+ // Check children - pass world coord since children compose with parent.ancestorTransform
+ const objects = this.getObjectsByOrder();
+ for (let i = 0; i < objects.length; i++) {
+ const object = objects[i];
+ if (object.isHit(coord)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/packages/engine-render/src/group.ts b/packages/engine-render/src/group.ts
index 70e7d53184..e837a5448a 100644
--- a/packages/engine-render/src/group.ts
+++ b/packages/engine-render/src/group.ts
@@ -26,8 +26,8 @@ import { getGroupState, transformObjectOutOfGroup } from './basics/group-transfo
import { isString } from './basics/tools';
export class Group extends BaseObject {
- private _objects: BaseObject[] = [];
- private _selfSizeMode = false;
+ protected _objects: BaseObject[] = [];
+ protected _selfSizeMode = false;
constructor(key?: string, ...objects: BaseObject[]) {
super(key);
@@ -233,6 +233,7 @@ export class Group extends BaseObject {
override render(ctx: UniverRenderingContext, bounds: IViewportInfo) {
ctx.save();
const m = this.transform.getMatrix();
+
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
const objects = this.getObjectsByOrder();
diff --git a/packages/engine-render/src/index.ts b/packages/engine-render/src/index.ts
index 6b9b214f46..65e412ca3c 100644
--- a/packages/engine-render/src/index.ts
+++ b/packages/engine-render/src/index.ts
@@ -38,6 +38,7 @@ export { DEFAULT_PADDING_DATA } from './components/sheets/sheet.render-skeleton'
export type { IUniverEngineRenderConfig } from './config/config';
export * from './context';
export * from './custom';
+export { DrawingGroupObject } from './drawing-group';
export * from './engine';
export * from './group';
export * from './layer';
diff --git a/packages/engine-render/src/layer.ts b/packages/engine-render/src/layer.ts
index 31051905dc..085fa5c680 100644
--- a/packages/engine-render/src/layer.ts
+++ b/packages/engine-render/src/layer.ts
@@ -94,7 +94,7 @@ export class Layer extends Disposable {
const objects: BaseObject[] = [];
this._objects.sort(sortRules);
for (const o of this._objects) {
- if (!(o.classType === RENDER_CLASS_TYPE.GROUP) && o.visible && o.evented) {
+ if (o.visible && o.evented) {
objects.push(o);
}
}
diff --git a/packages/engine-render/src/scene.transformer.ts b/packages/engine-render/src/scene.transformer.ts
index 9eb8341af1..15a59e5b25 100644
--- a/packages/engine-render/src/scene.transformer.ts
+++ b/packages/engine-render/src/scene.transformer.ts
@@ -1609,6 +1609,7 @@ export class Transformer extends Disposable implements ITransformerConfig {
this._transformerControlMap.clear();
}
+ // eslint-disable-next-line max-lines-per-function, complexity
private _createControl(applyObject: BaseObject, isSkipOnCropper = true) {
const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState();
const angle = applyObject.angle;
@@ -1650,13 +1651,13 @@ export class Transformer extends Disposable implements ITransformerConfig {
stroke: borderStroke,
});
- const { left, top } = this._getRotateAnchorPosition(TransformerManagerType.ROTATE, height, width, applyObject);
+ const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition(TransformerManagerType.ROTATE, height, width, applyObject);
const cursor = this._getRotateAnchorCursor(TransformerManagerType.ROTATE);
const rotate = new Rect(`${TransformerManagerType.ROTATE}_${zIndex}`, {
zIndex: zIndex - 1,
- left,
- top,
+ left: rotateLeft,
+ top: rotateTop,
height: rotateSize,
width: rotateSize,
radius: rotateCornerRadius,
@@ -1690,7 +1691,13 @@ export class Transformer extends Disposable implements ITransformerConfig {
transformerControl.zIndex = zIndex;
transformerControl.evented = false;
transformerControl.openSelfSizeMode();
- transformerControl.transformByState({ left, top, angle, width, height });
+ transformerControl.transformByState({
+ left: applyObject.left || left,
+ top: applyObject.top || top,
+ angle: applyObject.angle || angle,
+ width: applyObject.width || width,
+ height: applyObject.height || height,
+ });
const scene = this.getScene();
scene.addObject(transformerControl, layerIndex);
diff --git a/packages/engine-render/src/scene.ts b/packages/engine-render/src/scene.ts
index e57b1a6755..adb2d32474 100644
--- a/packages/engine-render/src/scene.ts
+++ b/packages/engine-render/src/scene.ts
@@ -999,8 +999,8 @@ export class Scene extends Disposable {
const objectLength = objectOrder.length;
for (let i = 0; i < objectLength; i++) {
- const o = objectOrder[i];
- if (!o.visible || !o.evented || o.classType === RENDER_CLASS_TYPE.GROUP) {
+ const testObject = objectOrder[i];
+ if (!testObject.visible || !testObject.evented || (testObject.isInGroup && testObject.parent?.classType === RENDER_CLASS_TYPE.GROUP && testObject.isDrawingObject)) {
continue;
}
const svCoord = vecFromSheetContent;
@@ -1009,23 +1009,23 @@ export class Scene extends Disposable {
// svCoord = svCoord.clone().add(Vector2.FromArray([-cumLeft, -cumTop]));
// }
- if (o.isHit(svCoord)) {
- if (o.classType === RENDER_CLASS_TYPE.SCENE_VIEWER) {
- const pickedObject = (o as SceneViewer).pick(svCoord);
+ if (testObject.isHit(svCoord)) {
+ if (testObject.classType === RENDER_CLASS_TYPE.SCENE_VIEWER) {
+ const pickedObject = (testObject as SceneViewer).pick(svCoord);
if (pickedObject) {
isPickedObject = pickedObject;
} else {
- isPickedObject = (o as SceneViewer).getActiveSubScene();
+ isPickedObject = (testObject as SceneViewer).getActiveSubScene();
}
} else {
- isPickedObject = o;
+ isPickedObject = testObject;
}
break;
} else if (
- o.classType === RENDER_CLASS_TYPE.SCENE_VIEWER &&
- (o as SceneViewer).allowSelectedClipElement()
+ testObject.classType === RENDER_CLASS_TYPE.SCENE_VIEWER &&
+ (testObject as SceneViewer).allowSelectedClipElement()
) {
- const pickedObject = (o as SceneViewer).pick(svCoord);
+ const pickedObject = (testObject as SceneViewer).pick(svCoord);
if (pickedObject) {
isPickedObject = pickedObject;
break;
@@ -1042,16 +1042,16 @@ export class Scene extends Disposable {
// triggerKeyDown(evt: IKeyboardEvent) {
// this.onKeyDown$.emitEvent(evt);
- // if (this._parent instanceof SceneViewer) {
- // this._parent?.triggerKeyDown(evt);
- // }
+ // if (this._parent instanceof SceneViewer) {
+ // this._parent?.triggerKeyDown(evt);
+ // }
// }
// triggerKeyUp(evt: IKeyboardEvent) {
// this.onKeyUp$.emitEvent(evt);
- // if (this._parent instanceof SceneViewer) {
- // this._parent?.triggerKeyUp(evt);
- // }
+ // if (this._parent instanceof SceneViewer) {
+ // this._parent?.triggerKeyUp(evt);
+ // }
// }
triggerPointerUp(evt: IPointerEvent | IMouseEvent) {
diff --git a/packages/engine-render/src/shape/image.ts b/packages/engine-render/src/shape/image.ts
index 79f77f6997..a9221ac829 100644
--- a/packages/engine-render/src/shape/image.ts
+++ b/packages/engine-render/src/shape/image.ts
@@ -54,6 +54,8 @@ export class Image extends Shape<IImageProps> {
override objectType = ObjectType.IMAGE;
+ override isDrawingObject: boolean = true;
+
constructor(id: string, config: IImageProps) {
super(id, config);
this._props = {
@@ -270,15 +272,22 @@ export class Image extends Shape<IImageProps> {
return this;
}
+ let { width: realWidth, height: realHeight, left: realLeft, top: realTop } = this;
+
+ const realBound = this.getRealBound();
+ realWidth = realBound.width;
+ realHeight = realBound.height;
+ realLeft = realBound.left;
+ realTop = realBound.top;
// Temporarily ignore the on-demand display of elements within a group:this.isInGroup
if (this.isRender(bounds)) {
const { top, left, bottom, right } = bounds!.viewBound;
if (
- this.width + this.strokeWidth + this.left < left ||
- right < this.left ||
- this.height + this.strokeWidth + this.top < top ||
- bottom < this.top
+ realWidth + this.strokeWidth + realLeft < left ||
+ right < realLeft ||
+ realHeight + this.strokeWidth + realTop < top ||
+ bottom < realTop
) {
return this;
}
@@ -294,30 +303,32 @@ export class Image extends Shape<IImageProps> {
// mainCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
// }
- const centerX = this.left + this.width / 2;
- const centerY = this.top + this.height / 2;
+ const centerX = realLeft + realWidth / 2;
+ const centerY = realTop + realHeight / 2;
mainCtx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
if (this.opacity !== 1) {
mainCtx.globalAlpha = this.opacity;
}
- this._draw(mainCtx);
+ this._draw(mainCtx, undefined, realWidth, realHeight);
mainCtx.restore();
this.makeDirty(false);
return this;
}
- protected override _draw(ctx: UniverRenderingContext) {
+ protected override _draw(ctx: UniverRenderingContext, _bounds?: IViewportInfo, renderWidth?: number, renderHeight?: number) {
if (this._native == null) {
return;
}
+ const w = renderWidth ?? this.width;
+ const h = renderHeight ?? this.height;
if (!this._renderByCropper && this.srcRect) {
const { left = 0, top = 0, right = 0, bottom = 0 } = this.srcRect;
ctx.beginPath();
- ctx.rect(-this.width / 2, -this.height / 2, this.width, this.height);
+ ctx.rect(-w / 2, -h / 2, w, h);
ctx.clip();
- ctx.drawImage(this._native, -left - this.width / 2, -top - this.height / 2, this.width + right + left, this.height + bottom + top);
+ ctx.drawImage(this._native, -left - w / 2, -top - h / 2, w + right + left, h + bottom + top);
} else {
- ctx.drawImage(this._native, -this.width / 2, -this.height / 2, this.width, this.height);
+ ctx.drawImage(this._native, -w / 2, -h / 2, w, h);
}
}
@@ -374,21 +385,26 @@ export class Image extends Shape<IImageProps> {
override isHit(coord: Vector2) {
// Build the same effective transform used in render():
+ // Must use realBound to match render() method's coordinate system
// [m[0], m[1], m[2], m[3], centerX, centerY]
+
+ const realBound = this.getRealBound();
+ const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = realBound;
+ const centerX = realLeft + realWidth / 2;
+ const centerY = realTop + realHeight / 2;
const m = this.transform.getMatrix();
- const centerX = this.left + this.width / 2;
- const centerY = this.top + this.height / 2;
const renderTransform = new Transform([m[0], m[1], m[2], m[3], centerX, centerY]);
// Account for parent group transforms if applicable
+ // This handles multi-level nesting and parent flipX/flipY transformations
const parent = this.getParent();
const effectiveTransform = this.isInGroup && parent?.classType === RENDER_CLASS_TYPE.GROUP
? parent.ancestorTransform.multiply(renderTransform)
: renderTransform;
const oCoord = effectiveTransform.invert().applyPoint(coord);
- const halfWidth = this.width / 2;
- const halfHeight = this.height / 2;
+ const halfWidth = realWidth / 2;
+ const halfHeight = realHeight / 2;
if (
oCoord.x >= -halfWidth - this.strokeWidth / 2 &&
oCoord.x <= halfWidth + this.strokeWidth / 2 &&
diff --git a/packages/sheets-drawing-ui/src/commands/commands/utils.ts b/packages/sheets-drawing-ui/src/commands/commands/utils.ts
index 6b5cebcdbe..6d1c7db842 100644
--- a/packages/sheets-drawing-ui/src/commands/commands/utils.ts
+++ b/packages/sheets-drawing-ui/src/commands/commands/utils.ts
@@ -36,8 +36,8 @@ export function ungroupToGroup(ungroupParams: IDrawingGroupUpdateParam[]) {
drawingId,
transform: {
...transform,
- left: transform.left! - groupTransform.left,
- top: transform.top! - groupTransform.top,
+ left: transform.left!,
+ top: transform.top!,
},
groupId,
};
@@ -48,6 +48,7 @@ export function ungroupToGroup(ungroupParams: IDrawingGroupUpdateParam[]) {
subUnitId,
drawingId: groupId,
drawingType: DrawingTypeEnum.DRAWING_GROUP,
+ groupBaseBound: { ...parent.groupBaseBound },
transform: groupTransform,
} as IDrawingParam;
@@ -72,7 +73,7 @@ export function groupToUngroup(groupParams: IDrawingGroupUpdateParam[]) {
const newChildren = children.map((object) => {
const { transform } = object;
const { unitId, subUnitId, drawingId } = object;
- const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
+ const newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0, parent.groupBaseBound);
return {
unitId,
subUnitId,
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
index f14911b1f8..ad47abc3af 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-transform-affected.controller.ts
@@ -1228,7 +1228,9 @@ export class SheetDrawingTransformAffectedController extends Disposable implemen
Object.keys(drawingData).forEach((drawingId) => {
if (unitId === showUnitId && subUnitId === showSubunitId) {
const drawing = drawingData[drawingId] as ISheetDrawing;
- drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService);
+ if (drawing.sheetTransform) {
+ drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService);
+ }
insertDrawings.push(drawingData[drawingId]);
} else {
removeDrawings.push(drawingData[drawingId]);
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
index 27d7d4ac5b..86200c0623 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
@@ -115,7 +115,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
this._workbookSelections = selectionManagerService.getWorkbookSelections(this._context.unitId);
- this._updateImageListener();
+ this._updateDrawingListener();
this._updateOrderListener();
this._groupDrawingListener();
this._focusDrawingListener();
@@ -553,10 +553,12 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
}));
}
- private _updateImageListener() {
+ private _updateDrawingListener() {
this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
const drawings: Partial<ISheetDrawing>[] = [];
+ const groupChildParams: IDrawingParam[] = [];
+
if (params.length === 0) {
return;
}
@@ -593,6 +595,10 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
axisAlignSheetTransform: { ...axisAlignSheetTransform },
};
+ // if (newDrawing.drawingType === DrawingTypeEnum.DRAWING_GROUP) {
+
+ // }
+
drawings.push(newDrawing);
});
@@ -605,7 +611,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
}));
}
- private _getSheetTransformByParam(param: IDrawingParam): Nullable<{
+ private _getSheetTransformByParam(param: IDrawingParam, isCreate: boolean): Nullable<{
sheetTransform: ISheetDrawingPosition;
axisAlignSheetTransform: ISheetDrawingPosition;
}> {
@@ -615,12 +621,17 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
}
const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });
- if (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId) {
+ let sheetDrawingTransform = sheetDrawing?.transform;
+ if (isCreate) {
+ sheetDrawingTransform = {};
+ }
+
+ if (!isCreate && (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId)) {
return null;
}
- const sheetTransform = transformToDrawingPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
+ const sheetTransform = transformToDrawingPosition({ ...sheetDrawingTransform, ...transform }, this._selectionRenderService);
- const axisAlignSheetTransform = transformToAxisAlignPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
+ const axisAlignSheetTransform = transformToAxisAlignPosition({ ...sheetDrawingTransform, ...transform }, this._selectionRenderService);
if (sheetTransform == null || axisAlignSheetTransform == null) {
return null;
@@ -632,11 +643,11 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
const grpParams = [];
for (const param of params) {
- const sheetTransform = this._getSheetTransformByParam(param.parent);
+ const grpSheetTransform = this._getSheetTransformByParam(param.parent, true);
const children = [];
for (const child of param.children) {
- const childSheetTransformInfo = this._getSheetTransformByParam(child);
+ const childSheetTransformInfo = this._getSheetTransformByParam(child, false);
if (childSheetTransformInfo != null) {
children.push({
...child,
@@ -647,7 +658,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
}
const grpParam = {
- parent: { ...param.parent, sheetTransform },
+ parent: { ...param.parent, sheetTransform: grpSheetTransform?.sheetTransform, axisAlignSheetTransform: grpSheetTransform?.axisAlignSheetTransform },
children,
};
@@ -666,11 +677,12 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
const { children } = param;
const childParams = [];
for (const child of children) {
- const childSheetTransform = this._getSheetTransformByParam(child);
+ const childSheetTransform = this._getSheetTransformByParam(child, false);
if (childSheetTransform != null) {
childParams.push({
...child,
- sheetTransform: childSheetTransform,
+ sheetTransform: childSheetTransform.sheetTransform,
+ axisAlignSheetTransform: childSheetTransform.axisAlignSheetTransform,
});
}
}