@@ -2,7 +2,7 @@ import React, { useMemo, useState, useRef } from 'react';
22import { X , GitCommitVertical , AlertTriangle , FileText , BarChart2 , Hash , Percent , Download , Activity , Image , MessageSquare , ChevronDown } from 'lucide-react' ;
33import type { ChainInfo , SuperposedStructure } from '../types' ;
44import clsx from 'clsx' ;
5- import html2canvas from 'html2canvas ' ;
5+ import domtoimage from 'dom-to-image-more ' ;
66
77interface SequenceAlignmentModalProps {
88 isOpen : boolean ;
@@ -282,31 +282,25 @@ export const SequenceAlignmentModal: React.FC<SequenceAlignmentModalProps> = ({
282282
283283 try {
284284 console . log ( 'Starting PNG export...' ) ;
285- const canvas = await html2canvas ( modalRef . current , {
286- backgroundColor : '#0D1117' ,
285+ const dataUrl = await domtoimage . toPng ( modalRef . current , {
286+ quality : 1 ,
287+ bgcolor : '#0D1117' ,
287288 scale : 2 ,
288- logging : false ,
289- useCORS : true ,
290- allowTaint : true
289+ style : {
290+ transform : 'scale(1)' ,
291+ transformOrigin : 'top left'
292+ }
291293 } ) ;
292294
293- console . log ( 'Canvas created successfully' ) ;
294-
295- canvas . toBlob ( ( blob ) => {
296- if ( blob ) {
297- const url = URL . createObjectURL ( blob ) ;
298- const a = document . createElement ( 'a' ) ;
299- a . href = url ;
300- a . download = `sequence_alignment_${ Date . now ( ) } .png` ;
301- document . body . appendChild ( a ) ;
302- a . click ( ) ;
303- document . body . removeChild ( a ) ;
304- URL . revokeObjectURL ( url ) ;
305- console . log ( 'PNG exported successfully' ) ;
306- } else {
307- alert ( 'Failed to create image blob' ) ;
308- }
309- } , 'image/png' ) ;
295+ console . log ( 'Image created successfully' ) ;
296+
297+ const link = document . createElement ( 'a' ) ;
298+ link . download = `sequence_alignment_${ Date . now ( ) } .png` ;
299+ link . href = dataUrl ;
300+ document . body . appendChild ( link ) ;
301+ link . click ( ) ;
302+ document . body . removeChild ( link ) ;
303+ console . log ( 'PNG exported successfully' ) ;
310304 } catch ( error ) {
311305 console . error ( 'Failed to export image:' , error ) ;
312306 alert ( `Export failed: ${ error instanceof Error ? error . message : 'Unknown error' } ` ) ;
0 commit comments