Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/component selector #86

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,140 changes: 1,101 additions & 1,039 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions packages/vstory/demo/src/demos/API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const API = () => {

const chartSpec = {
type: 'bar',
animation: false,
data: [
{
id: 'barData',
Expand Down Expand Up @@ -39,7 +40,8 @@ export const API = () => {
top: 40,
left: 50,
width: 250,
height: 100
height: 100,
angle: 0.3
},
options: {
graphic: {
Expand Down Expand Up @@ -83,7 +85,8 @@ export const API = () => {
top: 100,
left: 100,
width: 400,
height: 400
height: 400,
angle: 0.3
},
options: {
spec: chartSpec
Expand All @@ -97,7 +100,8 @@ export const API = () => {
x: 200,
y: 200,
width: 200,
height: 200
height: 200,
angle: 0.3
},
options: {
graphic: {
Expand Down Expand Up @@ -153,7 +157,6 @@ export const API = () => {
// 删除character
document.addEventListener('keydown', e => {
if (e.key === 'Backspace') {
debugger;
const sc = selectedCharacter;
edit.stopEdit();
sc && story.removeCharacter(sc.id);
Expand All @@ -163,6 +166,10 @@ export const API = () => {
});
// 导出DSL
console.log(story.toDSL());

setTimeout(() => {
edit.selectCharacter('test-chart-0');
}, 3000);
// story读取DSL
} catch (e) {
console.error(e);
Expand Down
7 changes: 6 additions & 1 deletion packages/vstory/demo/src/demos/GraphicEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Edit } from '../../../src/edit/edit';
import '../../../src/story/index';
import { loadAllSelection } from '../../../src/edit/edit-component';
import img from '../assets/scene3/chart-3.png';
import { EditActionEnum } from '../../../src/edit/interface';

loadAllSelection();

Expand Down Expand Up @@ -56,7 +57,7 @@ export const GraphicEdit = () => {
options: {
graphic: {
fill: 'red',
visible: false
visible: true
},
text: {
text: 'title2',
Expand Down Expand Up @@ -157,6 +158,10 @@ export const GraphicEdit = () => {
}
});

edit.emitter.on(EditActionEnum.richTextPluginEdit, msg => {
console.log(msg);
});

// let i = 0;
// story.getPlayer().setCurrentChapter(0);
// setInterval(() => {
Expand Down
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
16 changes: 8 additions & 8 deletions packages/vstory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"test-watch": "DEBUG_MODE=1 jest --watch"
},
"dependencies": {
"@visactor/vchart": "1.12.4-alpha.1",
"@visactor/vrender": "0.20.1",
"@visactor/vrender-core": "0.20.1",
"@visactor/vrender-kits": "0.20.1",
"@visactor/vrender-components": "0.20.1",
"@visactor/vutils": "~0.18.4",
"@visactor/vchart": "1.12.7",
"@visactor/vrender": "0.20.8",
"@visactor/vrender-core": "0.20.8",
"@visactor/vrender-kits": "0.20.8",
"@visactor/vrender-components": "0.20.8",
"@visactor/vutils": "~0.18.17",
"@visactor/vchart-extension": "0.0.2",
"@visactor/vdataset": "~0.18.4",
"@visactor/vscale": "~0.18.4"
"@visactor/vdataset": "~0.18.17",
"@visactor/vscale": "~0.18.17"
},
"devDependencies": {
"@internal/bundler": "workspace:*",
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ export class RichTextControl {
this._edit.editAction.emitter.on(EditActionEnum.richTextPluginEdit, this.onRichTextPluginEdit);
}

onRichTextPluginEdit = ({ type, p }: { type: string; p: RichTextEditPlugin }) => {
onRichTextPluginEdit = (msg: { type: string; p: RichTextEditPlugin }) => {
this._edit.emitter.emit(EditActionEnum.richTextPluginEdit, { data: msg, character: this._character });
const { type, p } = msg;
if (p.currRt !== this._richText) {
console.warn('current edit richtext not match in richtext-control.onRichTextPluginEdit');
return;
}
if (msg.type === 'change' && this._character) {
this._character.setConfig({
options: { graphic: { textConfig: this._richText.attribute.textConfig } }
});
}
// do noting 富文本编辑消息的处理
// console.log('onRichTextPluginEdit', type, p);
};
Expand Down
Loading
Loading