Browse Source

Export to canvas only selected elements (#323)

Fixes #308
Christopher Chedeau 5 năm trước cách đây
mục cha
commit
157f0eae0c
1 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 6 3
      src/components/SidePanel.tsx

+ 6 - 3
src/components/SidePanel.tsx

@@ -136,9 +136,12 @@ export const SidePanel: React.FC<SidePanelProps> = ({
         syncActionResult={syncActionResult}
         elements={elements}
         appState={appState}
-        onExportCanvas={(type: ExportType) =>
-          exportCanvas(type, elements, canvas, appState)
-        }
+        onExportCanvas={(type: ExportType) => {
+          const exportedElements = elements.some(element => element.isSelected)
+            ? elements.filter(element => element.isSelected)
+            : elements;
+          return exportCanvas(type, exportedElements, canvas, appState);
+        }}
       />
     </div>
   );