Skip to content

Commit bda0dd0

Browse files
committed
Cleanup.
1 parent 55ba13d commit bda0dd0

File tree

6 files changed

+23
-48
lines changed

6 files changed

+23
-48
lines changed

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ <h2 class="sub-headline">
259259
<div class="header-container-image">
260260
<img class="head-image" src="./pexels-niklas-jeromin-12734294.jpg" />
261261
</div>
262-
<canvas id="myCanvas" width="5000" height="5000" style="border:1px solid #000000;"></canvas>
262+
<canvas id="myCanvas" width="1000" height="500" style="border:1px solid #000000;"></canvas>
263263
<canvas id="myCanvas2" width="5000" height="5000" style="border:1px solid #000000;"></canvas>
264-
<canvas id="myCanvas3" width="5000" height="5000" style="border:1px solid #000000;"></canvas>
265-
<canvas id="myCanvas4" width="5000" height="5000" style="border:1px solid #000000;"></canvas>
264+
<canvas id="myCanvas3" width="200" height="200" style="border:1px solid #000000;"></canvas>
265+
<canvas id="myCanvas4" width="400" height="200" style="border:1px solid #000000;"></canvas>
266266
<canvas id="myCanvas5" width="5000" height="5000" style="border:1px solid #000000;"></canvas>
267267

268268

demo/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Gleap.on("tool-execution", (tool) => {
2929

3030
Gleap.setTicketAttribute("notes", "This is a test value.");
3131

32-
Gleap.initialize("KEY");
32+
Gleap.initialize("9pBLU6jUACYzWDkXoCHX157R2nfW8xgw");

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ScreenCapture.js

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

241241
const 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

382354
const 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

Comments
 (0)