From b32f5d8647eb1fd146e574dfcb853105e645b020 Mon Sep 17 00:00:00 2001 From: zhouxinyu Date: Fri, 11 Oct 2024 11:11:01 +0800 Subject: [PATCH] fix: fix issue with interface --- packages/vstory/demo/src/demos/VChartGraphic.tsx | 3 +++ .../src/edit/edit-component/base-selection.ts | 3 ++- .../src/edit/edit-component/box-selection.ts | 4 ++++ .../src/edit/edit-component/chart-selection.ts | 4 ++++ .../src/edit/edit-component/image-selection.ts | 5 +++++ .../src/edit/edit-component/rect-selection.ts | 4 ++++ .../series-mark/series-mark-selection.ts | 16 ++++++++++------ .../src/edit/edit-component/text-selection.ts | 4 ++++ packages/vstory/src/edit/interface.ts | 2 +- 9 files changed, 37 insertions(+), 8 deletions(-) diff --git a/packages/vstory/demo/src/demos/VChartGraphic.tsx b/packages/vstory/demo/src/demos/VChartGraphic.tsx index 423e186a..df9ad4de 100644 --- a/packages/vstory/demo/src/demos/VChartGraphic.tsx +++ b/packages/vstory/demo/src/demos/VChartGraphic.tsx @@ -966,6 +966,9 @@ export const VChartGraphic = () => { edit.emitter.on('startEdit', (...args) => { console.log(args); }); + edit.emitter.on('resize', (...args) => { + console.log('resize', args); + }); // const vchart = story.getCharactersById('vchart')?.graphic.vchart; // window.vchart = vchart; diff --git a/packages/vstory/src/edit/edit-component/base-selection.ts b/packages/vstory/src/edit/edit-component/base-selection.ts index 294c2ee7..d08f6437 100644 --- a/packages/vstory/src/edit/edit-component/base-selection.ts +++ b/packages/vstory/src/edit/edit-component/base-selection.ts @@ -198,7 +198,8 @@ export abstract class BaseSelection implements IEditComponent { protected handlerTransformChange(data: IUpdateParams, event?: VRenderPointerEvent): void { if (this._activeCharacter) { this.edit.emitter.emit('resize', { - position: data + position: data, + character: this._activeCharacter }); this._activeCharacter.setConfig({ position: data }); } diff --git a/packages/vstory/src/edit/edit-component/box-selection.ts b/packages/vstory/src/edit/edit-component/box-selection.ts index 9e91f186..c437e5f4 100644 --- a/packages/vstory/src/edit/edit-component/box-selection.ts +++ b/packages/vstory/src/edit/edit-component/box-selection.ts @@ -13,6 +13,10 @@ export class BoxSelection extends BaseSelection implements IEditComponent { super.endEdit(); return; } + + checkOver(actionInfo: IEditActionInfo): void { + return; + } checkAction(actionInfo: IEditActionInfo): boolean { if (this._isSelection) { if (actionInfo.type === 'pointerup') { diff --git a/packages/vstory/src/edit/edit-component/chart-selection.ts b/packages/vstory/src/edit/edit-component/chart-selection.ts index 77df2967..1c910a6f 100644 --- a/packages/vstory/src/edit/edit-component/chart-selection.ts +++ b/packages/vstory/src/edit/edit-component/chart-selection.ts @@ -13,6 +13,10 @@ export class ChartSelection extends BaseSelection implements IEditComponent { super(edit); } + checkOver(actionInfo: IEditActionInfo): void { + return; + } + updateComponent() { const actionInfo = this._actionInfo as IEditSelectionInfo; if (!(actionInfo && actionInfo.character)) { diff --git a/packages/vstory/src/edit/edit-component/image-selection.ts b/packages/vstory/src/edit/edit-component/image-selection.ts index a501b2c1..9a7915de 100644 --- a/packages/vstory/src/edit/edit-component/image-selection.ts +++ b/packages/vstory/src/edit/edit-component/image-selection.ts @@ -1,4 +1,5 @@ import { StoryComponentType } from '../../constants/character'; +import type { IEditActionInfo } from '../interface'; import { type IEditComponent } from '../interface'; import { BaseSelection } from './base-selection'; import type { ITransformControl, TransformAttributes } from './edit-control/transform-control'; @@ -10,6 +11,10 @@ export class ImageSelection extends RectSelection implements IEditComponent { readonly type: string = 'image'; readonly editCharacterType: string = StoryComponentType.IMAGE; + checkOver(actionInfo: IEditActionInfo): void { + return; + } + // protected _createLayoutComponent(attributes: Partial): ITransformControl { // return new TransformControl(this, attributes); // } diff --git a/packages/vstory/src/edit/edit-component/rect-selection.ts b/packages/vstory/src/edit/edit-component/rect-selection.ts index 071a158a..e7f8e6ba 100644 --- a/packages/vstory/src/edit/edit-component/rect-selection.ts +++ b/packages/vstory/src/edit/edit-component/rect-selection.ts @@ -10,6 +10,10 @@ export class RectSelection extends RichTextSelectionCommon implements IEditCompo readonly type: string = 'rect'; readonly editCharacterType: string = StoryComponentType.RECT; + checkOver(actionInfo: IEditActionInfo): void { + return; + } + startEdit(actionInfo: IEditActionInfo) { super.startEdit(actionInfo); // @ts-ignore; diff --git a/packages/vstory/src/edit/edit-component/series-mark/series-mark-selection.ts b/packages/vstory/src/edit/edit-component/series-mark/series-mark-selection.ts index dd5a8cf3..b66231b5 100644 --- a/packages/vstory/src/edit/edit-component/series-mark/series-mark-selection.ts +++ b/packages/vstory/src/edit/edit-component/series-mark/series-mark-selection.ts @@ -62,7 +62,8 @@ export class SeriesMarkSelection extends BaseSelection implements IEditComponent if (result === false) { if ( actionInfo.type === EditActionEnum.unSelection || - (actionInfo.type === EditActionEnum.singleSelection && actionInfo.detail?.part !== 'seriesMark') + (actionInfo.type === EditActionEnum.singleSelection && + (actionInfo as IEditSelectionInfo).detail?.part !== 'seriesMark') // TODO: 支持标签编辑后 打开注释 // && actionInfo.detail?.part !== 'label' ) { @@ -225,11 +226,14 @@ export class SeriesMarkSelection extends BaseSelection implements IEditComponent this._showOverGraphic(actionInfo); }; - checkOver?(action: IEditActionInfo): void { + checkOver?(action: IEditActionInfo | IEditSelectionInfo): void { // action - if (action.type === EditActionEnum.pointerOverCharacter && action.detail?.part === 'seriesMark') { + if ( + action.type === EditActionEnum.pointerOverCharacter && + (action as IEditSelectionInfo).detail?.part === 'seriesMark' + ) { // 设置绘图变换矩阵 - const matrix = getChartRenderMatrix(action.character.graphic.graphic); + const matrix = getChartRenderMatrix((action as IEditSelectionInfo).character.graphic.graphic); this._overGraphic.setAttributes({ postMatrix: matrix }); // show over graphic this._showOverGraphic(action as IEditOverActionInfo); @@ -266,7 +270,7 @@ export class SeriesMarkSelection extends BaseSelection implements IEditComponent const seriesList = action.character.graphic.graphic.vchart .getChart() .getAllSeries() - .filter(s => s.type === action.detail.modelInfo.model.type); + .filter((s: any) => s.type === action.detail.modelInfo.model.type); const markList = seriesList.reduce((pre: any, cur: any) => { return pre.concat(cur.getMarkInName(action.detail.modelInfo.mark.name)); }, []); @@ -281,7 +285,7 @@ export class SeriesMarkSelection extends BaseSelection implements IEditComponent const result: IGraphic[] = []; const seriesField = action.detail.modelInfo.model.getSeriesField(); const seriesValue = action.detail.modelInfo.datum[0][seriesField]; - action.detail.modelInfo.mark.getProduct().elements.forEach(el => { + action.detail.modelInfo.mark.getProduct().elements.forEach((el: any) => { if (el.data[0]?.[seriesField] === seriesValue) { result.push(el.graphicItem); } diff --git a/packages/vstory/src/edit/edit-component/text-selection.ts b/packages/vstory/src/edit/edit-component/text-selection.ts index a50141b5..b99911fd 100644 --- a/packages/vstory/src/edit/edit-component/text-selection.ts +++ b/packages/vstory/src/edit/edit-component/text-selection.ts @@ -10,6 +10,10 @@ export class TextSelection extends RichTextSelectionCommon implements IEditCompo readonly editCharacterType: string = StoryComponentType.TEXT; protected mode: 'edit' | 'normal' = 'normal'; + checkOver(actionInfo: IEditActionInfo): void { + return; + } + constructor(public readonly edit: Edit) { super(edit); } diff --git a/packages/vstory/src/edit/interface.ts b/packages/vstory/src/edit/interface.ts index ed27bd93..46f08941 100644 --- a/packages/vstory/src/edit/interface.ts +++ b/packages/vstory/src/edit/interface.ts @@ -25,7 +25,7 @@ export type IEditSelectionDetailComponent = ICharacterPickInfo; export interface IEditSelectionInfo extends IEditActionInfoBase { characterId?: string | string[]; character?: ICharacter; - detail: IEditSelectionDetailChart | IEditSelectionDetailComponent; + detail?: IEditSelectionDetailChart | IEditSelectionDetailComponent; } export interface IEditOverActionInfo extends IEditActionInfoBase, IEditSelectionInfo {