Skip to content

Commit

Permalink
fix: fix issue with interface
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Oct 11, 2024
1 parent 4c2ee35 commit b32f5d8
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 8 deletions.
3 changes: 3 additions & 0 deletions packages/vstory/demo/src/demos/VChartGraphic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/vstory/src/edit/edit-component/base-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
4 changes: 4 additions & 0 deletions packages/vstory/src/edit/edit-component/box-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
4 changes: 4 additions & 0 deletions packages/vstory/src/edit/edit-component/chart-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 5 additions & 0 deletions packages/vstory/src/edit/edit-component/image-selection.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<TransformAttributes>): ITransformControl {
// return new TransformControl(this, attributes);
// }
Expand Down
4 changes: 4 additions & 0 deletions packages/vstory/src/edit/edit-component/rect-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}, []);
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/vstory/src/edit/edit-component/text-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vstory/src/edit/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b32f5d8

Please sign in to comment.