Skip to content

Commit

Permalink
fix(drawing): support chart only select one
Browse files Browse the repository at this point in the history
  • Loading branch information
VicKun4937 committed Oct 26, 2024
1 parent 7e08d4b commit d2f4f77
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/engine-render/src/base-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export enum ObjectType {
IMAGE,
RECT,
CIRCLE,
CHART,
}

export abstract class BaseObject extends Disposable {
Expand Down
6 changes: 3 additions & 3 deletions packages/engine-render/src/scene.transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 18 in packages/engine-render/src/scene.transformer.ts

View workflow job for this annotation

GitHub Actions / eslint

Expected "BaseObject" to come before "ObjectType"

Check failure on line 18 in packages/engine-render/src/scene.transformer.ts

View workflow job for this annotation

GitHub Actions / eslint

Member 'BaseObject' of the import declaration should be sorted alphabetically

import type { IMouseEvent, IPointerEvent } from './basics/i-events';
import type { ITransformerConfig } from './basics/transformer-config';
Expand Down Expand Up @@ -1630,14 +1630,14 @@ export class Transformer extends Disposable implements ITransformerConfig {

private _updateActiveObjectList(applyObject: BaseObject, evt: IPointerEvent | IMouseEvent) {
const { isCropper } = this._getConfig(applyObject);

Check failure on line 1633 in packages/engine-render/src/scene.transformer.ts

View workflow job for this annotation

GitHub Actions / eslint

Trailing spaces not allowed
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();
}
Expand Down
4 changes: 4 additions & 0 deletions packages/engine-render/src/shape/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class Rect<T extends IRectProps = IRectProps> extends Shape<T> {
return this._radius;
}

setObjectType(type: ObjectType) {
this.objectType = type;
}

static override drawWith(ctx: UniverRenderingContext, props: IRectProps) {
let { radius, width, height } = props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {

Check failure on line 325 in packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts

View workflow job for this annotation

GitHub Actions / eslint

Expected space(s) after "if"
rect.setObjectType(ObjectType.CHART);
}

Check failure on line 328 in packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts

View workflow job for this annotation

GitHub Actions / eslint

Trailing spaces not allowed

Check failure on line 329 in packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts

View workflow job for this annotation

GitHub Actions / eslint

More than 1 blank line not allowed
scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX);
if (floatDomParam.allowTransform !== false) {
scene.attachTransformerTo(rect);
Expand Down

0 comments on commit d2f4f77

Please sign in to comment.