@@ -6,7 +6,8 @@ import { type CanvasCoord, type CanvasItem } from '@/utils/canvas.ts'
66import CanvasShape from ' ./CanvasShape.vue'
77import { findComponent } from ' @/views/dashboard/components/component-list.ts'
88import { storeToRefs } from ' pinia'
9- import { useEmittLazy } from ' @/utils/useEmitt.ts'
9+ import { useEmitt , useEmittLazy } from ' @/utils/useEmitt.ts'
10+ import html2canvas from ' html2canvas'
1011
1112const dashboardStore = dashboardStoreWithOut ()
1213const canvasLocked = ref (false ) // Is the canvas movement locked, Default false
@@ -815,7 +816,6 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
815816 infoBox .value .moveItem = item
816817 infoBox .value .moveItemIndex = index
817818 }
818-
819819 infoBox .value .cloneItem = null
820820 infoBox .value .nowItemNode = null
821821 // @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -829,6 +829,15 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
829829 infoBox .value .cloneItem = infoBox .value .nowItemNode .cloneNode (true )
830830 }
831831 infoBox .value .cloneItem .classList .add (' cloneNode' )
832+ const img = new Image ()
833+ img .classList .add (' clone_img' )
834+ const clonedSlot = infoBox .value .nowItemNode .querySelector (' .slot-component' )
835+
836+ html2canvas (clonedSlot ).then ((canvas ) => {
837+ img .src = canvas .toDataURL ()
838+ infoBox .value .cloneItem .appendChild (img )
839+ })
840+
832841 if (containerRef .value ) {
833842 containerRef .value .append (infoBox .value .cloneItem )
834843 }
@@ -1130,6 +1139,11 @@ function tabMoveInCheckSQ() {
11301139 }
11311140}
11321141
1142+ useEmitt ({
1143+ name: ` editor-delete-${props .canvasId } ` ,
1144+ callback: removeItemById ,
1145+ })
1146+
11331147onMounted (() => {
11341148 currentInstance = getCurrentInstance ()
11351149})
@@ -1171,12 +1185,13 @@ defineExpose({
11711185 :move-animate =" moveAnimate"
11721186 :start-move =" startMove"
11731187 :start-resize =" startResize"
1188+ :canvas-id =" canvasId"
11741189 :style =" nowItemStyle(item)"
11751190 >
11761191 <component
11771192 :is =" findComponent(item.component)"
11781193 :ref =" 'shape_component_' + item.id"
1179- class =" sql-component dragHandle"
1194+ class =" sql-component slot-component dragHandle"
11801195 :config-item =" item"
11811196 :view-info =" canvasViewInfo[item.id]"
11821197 @parent-add-item-box =" (subItem: any) => addItemBox(subItem)"
0 commit comments