@@ -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