@@ -317,29 +317,31 @@ function buttonEventListeners() {
317317 displayErrorMessage ( `Error with fetch API: ${ error . message } ` , error ) ;
318318 }
319319 } )
320-
321320 document . getElementById ( 'png' ) . addEventListener ( 'click' , async ( ) => {
322321 try {
323322 const plantuml = trimlines ( editor . session . getValue ( ) ) ;
324323 const response = await fetch ( "/renderPNG" , {
325324 method : "POST" ,
326- headers : {
327- 'Content-Type' : 'application/json'
328- } ,
329- body : JSON . stringify ( {
330- 'plantuml' : plantuml
331- } )
325+ headers : { 'Content-Type' : 'application/json' } ,
326+ body : JSON . stringify ( { 'plantuml' : plantuml } )
332327 } ) ;
333328
334329 const blob = await response . blob ( ) ;
335- const imageUrl = URL . createObjectURL ( blob ) ;
336- const newTab = window . open ( '' , '_blank' ) ;
337-
338- const img = newTab . document . createElement ( 'img' ) ;
339- img . src = imageUrl ;
340- newTab . document . body . appendChild ( img ) ;
341- newTab . document . body . style . textAlign = 'center' ;
342- newTab . document . close ( ) ;
330+
331+ // Convert blob → base64 Data URL to make image copiable
332+ const reader = new FileReader ( ) ;
333+ reader . onloadend = ( ) => {
334+ const imageUrl = reader . result ; // data:image/png;base64,...
335+
336+ const newTab = window . open ( '' , '_blank' ) ;
337+ const img = newTab . document . createElement ( 'img' ) ;
338+ img . src = imageUrl ;
339+ newTab . document . body . appendChild ( img ) ;
340+ newTab . document . body . style . textAlign = 'center' ;
341+ newTab . document . close ( ) ;
342+ } ;
343+
344+ reader . readAsDataURL ( blob ) ;
343345
344346 } catch ( error ) {
345347 displayErrorMessage ( `Error with fetch API: ${ error . message } ` , error ) ;
0 commit comments