@@ -212,7 +212,7 @@ const replaceStyleNodes = (clone, styleSheet, cssTextContent, styleId) => {
212212 cloneTargetNode . remove ( ) ;
213213 }
214214 }
215- } catch ( exp ) { }
215+ } catch ( exp ) { }
216216 }
217217} ;
218218
@@ -224,7 +224,7 @@ const getTextContentFromStyleSheet = (styleSheet) => {
224224 } else if ( styleSheet . rules ) {
225225 cssRules = styleSheet . rules ;
226226 }
227- } catch ( exp ) { }
227+ } catch ( exp ) { }
228228
229229 var cssTextContent = "" ;
230230 if ( cssRules ) {
@@ -236,15 +236,15 @@ const getTextContentFromStyleSheet = (styleSheet) => {
236236 }
237237
238238 return cssTextContent ;
239- }
239+ } ;
240240
241241const downloadAllCSSUrlResources = ( clone , remote ) => {
242242 var promises = [ ] ;
243243 for ( var i = 0 ; i < document . styleSheets . length ; i ++ ) {
244244 const styleSheet = document . styleSheets [ i ] ;
245245
246246 // Skip if the stylesheet is meant for print
247- if ( styleSheet . media && styleSheet . media . mediaText === ' print' ) {
247+ if ( styleSheet . media && styleSheet . media . mediaText === " print" ) {
248248 continue ;
249249 }
250250
@@ -349,34 +349,6 @@ const handleAdoptedStyleSheets = (doc, clone, shadowNodeId) => {
349349 clone . insertBefore ( shadowStyleNode , clone . firstElementChild ) ;
350350 }
351351 }
352- }
353-
354-
355- const resizeCanvas = ( canvas , pct ) => {
356- return new Promise ( ( resolve , reject ) => {
357- const cw = canvas . width ;
358- const ch = canvas . height ;
359-
360- // Create a copy of the original canvas
361- const originalCanvas = document . createElement ( "canvas" ) ;
362- originalCanvas . width = cw ;
363- originalCanvas . height = ch ;
364- const originalCtx = originalCanvas . getContext ( "2d" ) ;
365- originalCtx . drawImage ( canvas , 0 , 0 ) ;
366-
367- // Create an off-screen canvas for resizing
368- const resizedCanvas = document . createElement ( "canvas" ) ;
369- resizedCanvas . width = cw * pct ;
370- resizedCanvas . height = ch * pct ;
371- const rctx = resizedCanvas . getContext ( "2d" ) ;
372-
373- // Draw the image from the original canvas onto the off-screen resized canvas
374- rctx . drawImage ( originalCanvas , 0 , 0 , cw , ch , 0 , 0 , cw * pct , ch * pct ) ;
375-
376- // Get the resized image data
377- const resizedCanvasData = resizedCanvas . toDataURL ( ) ;
378- resolve ( resizedCanvasData ) ;
379- } ) ;
380352} ;
381353
382354const deepClone = ( host ) => {
@@ -399,12 +371,12 @@ const deepClone = (host) => {
399371
400372 if ( node instanceof HTMLCanvasElement ) {
401373 try {
402- const resizedCanvasData = await resizeCanvas ( node , 0.50 ) ; // Scale down by 50%
403-
404- // const resizedImage = await resizeImage(node.toDataURL(), 3500, 3500);
405- // const originalCanvas = resizeTo(node, 0.50 );
406-
407- clone . setAttribute ( "bb-canvas-data " , resizedCanvasData ) ;
374+ const boundingRect = node . getBoundingClientRect ( ) ;
375+ const resizedImage = await resizeImage ( node . toDataURL ( ) , 900 , 900 ) ;
376+
377+ clone . setAttribute ( "bb-canvas-data" , resizedImage ) ;
378+ clone . setAttribute ( "bb-canvas-height" , boundingRect . height ) ;
379+ clone . setAttribute ( "bb-canvas-width " , boundingRect . width ) ;
408380 } catch ( exp ) {
409381 console . warn ( "Gleap: Failed to clone canvas data." , exp ) ;
410382 }
@@ -426,7 +398,7 @@ const deepClone = (host) => {
426398 clone . setAttribute ( "bb-width" , boundingRect . width ) ;
427399 }
428400
429- if ( ( node . scrollTop > 0 || node . scrollLeft > 0 ) ) {
401+ if ( node . scrollTop > 0 || node . scrollLeft > 0 ) {
430402 clone . setAttribute ( "bb-scrollpos" , true ) ;
431403 clone . setAttribute ( "bb-scrolltop" , node . scrollTop ) ;
432404 clone . setAttribute ( "bb-scrollleft" , node . scrollLeft ) ;
@@ -440,7 +412,7 @@ const deepClone = (host) => {
440412 var val = node . value ;
441413 if (
442414 node . getAttribute ( "gleap-ignore" ) === "value" ||
443- node . classList . contains ( ' gl-mask' )
415+ node . classList . contains ( " gl-mask" )
444416 ) {
445417 val = new Array ( val . length + 1 ) . join ( "*" ) ;
446418 }
@@ -527,7 +499,10 @@ const prepareScreenshotData = (remote) => {
527499 }
528500
529501 // Adjust the base node
530- const baseUrl = window . location . href . substring ( 0 , window . location . href . lastIndexOf ( "/" ) ) ;
502+ const baseUrl = window . location . href . substring (
503+ 0 ,
504+ window . location . href . lastIndexOf ( "/" )
505+ ) ;
531506 var newBaseUrl = baseUrl + "/" ;
532507 if ( existingBasePath ) {
533508 if ( existingBasePath . startsWith ( "http" ) ) {
0 commit comments