liwei 1 year ago
parent
commit
58d83d3b97

+ 4 - 0
src/modules/editor/components/TipIcons/index.ts

@@ -80,6 +80,10 @@ export const TipIcons = {
     icons: [IconDelete],
     tips: ["删除"],
   }),
+  Copy: createTipIcon({
+    icons: [IconCamera],
+    tips: ["拷贝"],
+  }),
   FullWidth: createTipIcon({
     icons: [IconCube],
     tips: ["全屏宽度"],

+ 1 - 0
src/modules/editor/controllers/ScreenshotCtrl/index.ts

@@ -23,6 +23,7 @@ export class ScreenshotCtrl {
 
     
     if (options.ratio) {
+
       const result = await domtoimage.toJpeg(dom);
       const img = await new Promise<HTMLImageElement>((resolve) => {
         const image = new Image();

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

@@ -315,7 +315,11 @@ export const editActions = EditorModule.action({
     //  console.log("contrc ", this.store.selected);
      ctrlcselected = this.store.selected.slice(0);
   },
-
+  copyLastSelected() {
+    if (this.store.currCompId && this.store.currCompId != "root") {
+      ctrlcselected = [this.store.currCompId]
+    }
+  },
   toogleGroup() {
      if (this.store.selected.length > 1) {
         this.actions.createGroupComps();

+ 8 - 0
src/modules/editor/objects/Toolbars/layout.ts

@@ -65,4 +65,12 @@ export const LayoutToolbars = createToolbars({
             this.actions.setAlignY(2);
         },
     },
+
+    Copy: {
+        component: TipIcons.Copy,
+        getVisible(comp) { return !!this.store.lastSelected },
+        onClick(comp) {
+            this.actions.copyLastSelected();
+        },
+    },
 });

+ 1 - 0
src/modules/editor/objects/Toolbars/topToolbars.ts

@@ -7,6 +7,7 @@ export const TopToolbarsLeft: ToolbarItem[] = [
 
     
     toolbars.delete,
+    // LayoutToolbars.Copy,
     toolbars.layerUp,
     toolbars.layerDown,
     toolbars.align,