liwei 1 year ago
parent
commit
61dafcf878

+ 16 - 2
src/modules/editor/controllers/ScreenshotCtrl/index.ts

@@ -1,4 +1,5 @@
 import domtoimage from "dom-to-image";
+import { Matrix } from "../SelectCtrl/matrix";
 
 export class ScreenshotCtrl {
   async snap(options: { element: HTMLElement; ratio?: number }): Promise<Blob> {
@@ -10,7 +11,17 @@ export class ScreenshotCtrl {
     // if (transferEl) {
     //   transferEl.style.display = "none";
     // }
+    
+    //清除dom上的
+    const transform =  dom.style.transform
+    if (transform) {
+       const m =  Matrix.createFromMatrixStr(transform);
+        m.tx = 0;
+        m.ty = 0;
+        dom.style.transform = m.getMatrixStr();
+    }
 
+    
     if (options.ratio) {
       const result = await domtoimage.toJpeg(dom);
       const img = await new Promise<HTMLImageElement>((resolve) => {
@@ -52,9 +63,12 @@ export class ScreenshotCtrl {
         });
       });
     } else {
-
       console.log( "xxxxxxxxxxxxxxxxxx" ,  dom );
-      return domtoimage.toBlob(dom);
+      const w = await domtoimage.toBlob(dom);
+      if (transform) {
+        dom.style.transform = transform;
+      }
+      return w;
     }
   }
 }

+ 6 - 1
src/modules/editor/module/actions/edit.tsx

@@ -317,12 +317,17 @@ export const editActions = EditorModule.action({
 
   // 删除组件
   removeComp(compId: string) {
+
+    const paths = this.helper.getCompTrees(compId);
+    if (!paths[2]) return;
+    compId = paths[2].id;
+
     if (this.helper.isCompCanDelete(compId)) {
       if (this.helper.isStreamCard(compId)) {
         this.actions.removeStreamCard(compId);
         return;
       }
-
+      
       const cardid = this.store.currStreamCardId;
       if (compId === this.store.currCompId) {
         this.store.setCurrComp(this.store.currStreamCardId);