@@ -107,6 +107,33 @@ function generateHash(imageData) {
107107return CryptoJS . SHA256 ( imageData ) . toString ( CryptoJS . enc . Hex ) ;
108108}
109109
110+ async function blobUrlToDataUrl ( blobUrl ) {
111+ try {
112+ const response = await fetch ( blobUrl ) ;
113+ const blob = await response . blob ( ) ;
114+ return new Promise ( ( resolve , reject ) => {
115+ const reader = new FileReader ( ) ;
116+ reader . onloadend = ( ) => resolve ( reader . result ) ;
117+ reader . onerror = reject ;
118+ reader . readAsDataURL ( blob ) ;
119+ } ) ;
120+ } catch ( e ) {
121+ console . error ( "Failed to convert blob URL:" , blobUrl , e ) ;
122+ return null ;
123+ }
124+ }
125+
126+ async function convertImageMapBlobUrls ( ) {
127+ const entries = Array . from ( imageMap . entries ( ) ) ;
128+ for ( const [ hash , value ] of entries ) {
129+ if ( typeof value === 'string' && value . startsWith ( 'blob:' ) ) {
130+ const dataUrl = await blobUrlToDataUrl ( value ) ;
131+ if ( dataUrl ) {
132+ imageMap . set ( hash , dataUrl ) ;
133+ }
134+ }
135+ }
136+ }
110137
111138function customToJSON ( ) {
112139const json = canvas . toJSON ( commonProperties ) ;
@@ -149,6 +176,9 @@ if (obj.speechBubbleGrid) {
149176obj . speechBubbleGrid = obj . speechBubbleGrid . replace ( 'GUID:' , '' ) ;
150177obj . speechBubbleGrid = imageMap . get ( obj . speechBubbleGrid ) ;
151178}
179+ if ( obj . textBaseline === 'alphabetical' ) {
180+ obj . textBaseline = 'alphabetic' ;
181+ }
152182commonProperties . forEach ( prop => {
153183if ( obj [ prop ] !== undefined ) {
154184obj [ prop ] = obj [ prop ] ;
0 commit comments