Skip to content

Commit 55a8126

Browse files
committed
refactor: remove redundant handleExport function
1 parent 3e7e4b3 commit 55a8126

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

client/src/components/Canvas.jsx

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ export const Canvas = () => {
551551
setSelectedShapeId(null);
552552
toast.success('Canvas cleared! 🧹');
553553
};
554+
554555
const handleExport = (format) => {
555556
const canvas = canvasRef.current;
556557
if (!canvas) return;
@@ -592,47 +593,6 @@ export const Canvas = () => {
592593
}
593594
};
594595

595-
const handleExport = (format) => {
596-
const canvas = canvasRef.current;
597-
if (!canvas) return;
598-
599-
switch (format) {
600-
case "png": {
601-
const link = document.createElement("a");
602-
link.download = "canvas.png";
603-
link.href = canvas.toDataURL("image/png");
604-
link.click();
605-
break;
606-
}
607-
608-
case "pdf": {
609-
const pdf = new jsPDF({
610-
orientation: "landscape",
611-
unit: "px",
612-
format: [canvas.width, canvas.height],
613-
});
614-
const imgData = canvas.toDataURL("image/png");
615-
pdf.addImage(imgData, "PNG", 0, 0, canvas.width, canvas.height);
616-
pdf.save("canvas.pdf");
617-
break;
618-
}
619-
620-
case "svg": {
621-
const svgCtx = new C2S(canvas.width, canvas.height);
622-
const svgData = svgCtx.getSerializedSvg();
623-
const blob = new Blob([svgData], { type: "image/svg+xml" });
624-
const link = document.createElement("a");
625-
link.download = "canvas.svg";
626-
link.href = URL.createObjectURL(blob);
627-
link.click();
628-
break;
629-
}
630-
631-
default:
632-
console.warn("Unsupported format:", format);
633-
}
634-
};
635-
636596

637597
return (
638598
<div className="relative w-full h-screen overflow-hidden bg-canvas">

0 commit comments

Comments
 (0)