diff --git a/packages/editor/src/layouts/sidebar/LayerPanel.vue b/packages/editor/src/layouts/sidebar/LayerPanel.vue index ba5d635d..a6fda6a3 100644 --- a/packages/editor/src/layouts/sidebar/LayerPanel.vue +++ b/packages/editor/src/layouts/sidebar/LayerPanel.vue @@ -61,12 +61,14 @@ import type { ElTree } from 'element-plus'; import { throttle } from 'lodash-es'; import type { MNode, MPage } from '@tmagic/schema'; -import { NodeType } from '@tmagic/schema'; +import { MContainer, NodeType } from '@tmagic/schema'; import StageCore from '@tmagic/stage'; import type { EditorService } from '@editor/services/editor'; import type { Services } from '@editor/type'; +import { Layout } from '@editor/type'; +import LayerMenu from './LayerMenu.vue'; import LayerMenu from './LayerMenu.vue'; const throttleTime = 150; @@ -104,8 +106,16 @@ const useDrop = (tree: Ref | undefined>, editorServi return false; }, - handleDragEnd() { + async handleDragEnd(e: any) { if (!tree.value) return; + const { data: node } = e; + const parent = editorService?.getParentById(node.id, false) as MContainer; + const layout = await editorService?.getLayout(parent); + node.style.position = layout; + if (layout === Layout.RELATIVE) { + node.style.top = 0; + node.style.left = 0; + } const { data } = tree.value; const [page] = data as [MPage]; editorService?.update(page);