fix(editor): 使用画布上的删除按钮删除组件时依赖没有清空

This commit is contained in:
roymondchen 2023-08-02 20:13:05 +08:00
parent 2f28252c64
commit 0d3cd11ade

View File

@ -1,5 +1,6 @@
import { computed } from 'vue';
import type { MNode } from '@tmagic/schema';
import StageCore, { GuidesType, RemoveEventData, SortEventData, UpdateEventData } from '@tmagic/stage';
import editorService from '@editor/services/editor';
@ -74,11 +75,8 @@ export const useStage = (stageOptions: StageOptions) => {
});
stage.on('remove', (ev: RemoveEventData) => {
editorService.remove(
ev.data.map(({ el }) => ({
id: el.id,
})),
);
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
editorService.remove(nodes.filter((node) => Boolean(node)) as MNode[]);
});
stage.on('select-parent', () => {