diff --git a/packages/engine-render/src/base-object.ts b/packages/engine-render/src/base-object.ts index 04ff07eb6a0..afb83b93cef 100644 --- a/packages/engine-render/src/base-object.ts +++ b/packages/engine-render/src/base-object.ts @@ -52,6 +52,7 @@ export enum ObjectType { IMAGE, RECT, CIRCLE, + CHART, } export abstract class BaseObject extends Disposable { diff --git a/packages/engine-render/src/scene.transformer.ts b/packages/engine-render/src/scene.transformer.ts index 185a1ac316f..ebad4ca09ae 100644 --- a/packages/engine-render/src/scene.transformer.ts +++ b/packages/engine-render/src/scene.transformer.ts @@ -15,7 +15,7 @@ */ import type { IAbsoluteTransform, IKeyValue, Nullable } from '@univerjs/core'; -import type { BaseObject } from './base-object'; +import { ObjectType, type BaseObject } from './base-object'; import type { IMouseEvent, IPointerEvent } from './basics/i-events'; import type { ITransformerConfig } from './basics/transformer-config'; @@ -1630,14 +1630,14 @@ export class Transformer extends Disposable implements ITransformerConfig { private _updateActiveObjectList(applyObject: BaseObject, evt: IPointerEvent | IMouseEvent) { const { isCropper } = this._getConfig(applyObject); - + applyObject = this._findGroupObject(applyObject); if (this._selectedObjectMap.has(applyObject.oKey)) { return; } - if (!evt.ctrlKey) { + if (!evt.ctrlKey || applyObject.objectType === ObjectType.CHART) { this._selectedObjectMap.clear(); this._clearControlMap(); } diff --git a/packages/engine-render/src/shape/rect.ts b/packages/engine-render/src/shape/rect.ts index 0729c6107ba..6f40109b3c8 100644 --- a/packages/engine-render/src/shape/rect.ts +++ b/packages/engine-render/src/shape/rect.ts @@ -65,6 +65,10 @@ export class Rect extends Shape { return this._radius; } + setObjectType(type: ObjectType) { + this.objectType = type; + } + static override drawWith(ctx: UniverRenderingContext, props: IRectProps) { let { radius, width, height } = props; diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts index d678bd39954..90b7fe19d99 100644 --- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts +++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts @@ -24,7 +24,7 @@ import type { IInsertDrawingCommandParams } from '../commands/commands/interface import { Disposable, DisposableCollection, fromEventSubject, generateRandomId, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; import { DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univerjs/drawing'; -import { DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Rect, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render'; +import { DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, ObjectType, Rect, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render'; import { getSheetCommandTarget, SetFrozenMutation } from '@univerjs/sheets'; import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing'; import { ISheetSelectionRenderService, SetZoomRatioOperation, SheetSkeletonManagerService, VIEWPORT_KEY } from '@univerjs/sheets-ui'; @@ -313,13 +313,20 @@ export class SheetCanvasFloatDomManagerService extends Disposable { zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1, }; - if (drawingType === DrawingTypeEnum.DRAWING_CHART) { + const isChart = drawingType === DrawingTypeEnum.DRAWING_CHART; + + if (isChart) { imageConfig.fill = 'white'; imageConfig.rotateEnabled = false; } const rect = new Rect(rectShapeKey, imageConfig); + if(isChart) { + rect.setObjectType(ObjectType.CHART); + } + + scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX); if (floatDomParam.allowTransform !== false) { scene.attachTransformerTo(rect);