feedback-vos 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -381,18 +381,52 @@ function ScreenshotButton({
|
|
|
381
381
|
const themeClasses = getThemeClasses(theme);
|
|
382
382
|
async function handleTakeScreenshot() {
|
|
383
383
|
setIsTakenScreenShot(true);
|
|
384
|
-
const canvas = await html2canvas(document.
|
|
384
|
+
const canvas = await html2canvas(document.documentElement, {
|
|
385
385
|
width: window.innerWidth,
|
|
386
386
|
height: window.innerHeight,
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
x: 0,
|
|
388
|
+
y: 0,
|
|
389
389
|
windowWidth: window.innerWidth,
|
|
390
390
|
windowHeight: window.innerHeight,
|
|
391
|
+
scale: 1,
|
|
392
|
+
// Use scale 1 for consistent sizing
|
|
393
|
+
useCORS: true,
|
|
394
|
+
logging: false,
|
|
391
395
|
ignoreElements: (element) => {
|
|
392
396
|
return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
|
|
393
397
|
}
|
|
394
398
|
});
|
|
395
|
-
const
|
|
399
|
+
const targetWidth = 1920;
|
|
400
|
+
const targetHeight = 1080;
|
|
401
|
+
const normalizedCanvas = document.createElement("canvas");
|
|
402
|
+
normalizedCanvas.width = targetWidth;
|
|
403
|
+
normalizedCanvas.height = targetHeight;
|
|
404
|
+
const ctx = normalizedCanvas.getContext("2d");
|
|
405
|
+
if (!ctx) {
|
|
406
|
+
setIsTakenScreenShot(false);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
ctx.imageSmoothingEnabled = true;
|
|
410
|
+
ctx.imageSmoothingQuality = "high";
|
|
411
|
+
const sourceAspect = canvas.width / canvas.height;
|
|
412
|
+
const targetAspect = targetWidth / targetHeight;
|
|
413
|
+
let drawWidth = targetWidth;
|
|
414
|
+
let drawHeight = targetHeight;
|
|
415
|
+
let drawX = 0;
|
|
416
|
+
let drawY = 0;
|
|
417
|
+
if (sourceAspect > targetAspect) {
|
|
418
|
+
drawHeight = targetHeight;
|
|
419
|
+
drawWidth = drawHeight * sourceAspect;
|
|
420
|
+
drawX = (targetWidth - drawWidth) / 2;
|
|
421
|
+
} else {
|
|
422
|
+
drawWidth = targetWidth;
|
|
423
|
+
drawHeight = drawWidth / sourceAspect;
|
|
424
|
+
drawY = (targetHeight - drawHeight) / 2;
|
|
425
|
+
}
|
|
426
|
+
ctx.fillStyle = "#ffffff";
|
|
427
|
+
ctx.fillRect(0, 0, targetWidth, targetHeight);
|
|
428
|
+
ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
|
|
429
|
+
const base64image = normalizedCanvas.toDataURL("image/png", 1);
|
|
396
430
|
onScreenshotTook(base64image);
|
|
397
431
|
setIsTakenScreenShot(false);
|
|
398
432
|
}
|
|
@@ -742,7 +776,7 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
|
|
|
742
776
|
return rawUrl;
|
|
743
777
|
}
|
|
744
778
|
async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
|
|
745
|
-
const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.
|
|
779
|
+
const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.85);
|
|
746
780
|
const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
|
|
747
781
|
const repoResponse = await fetch(
|
|
748
782
|
`https://api.github.com/repos/${owner}/${repo}`,
|
|
@@ -844,7 +878,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
|
|
|
844
878
|
console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
|
|
845
879
|
return rawUrl;
|
|
846
880
|
}
|
|
847
|
-
function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.
|
|
881
|
+
function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.85) {
|
|
848
882
|
return new Promise((resolve, reject) => {
|
|
849
883
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
850
884
|
reject(new Error("Screenshot compression only works in browser environments"));
|
|
@@ -866,6 +900,8 @@ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
|
|
|
866
900
|
reject(new Error("Could not get canvas context"));
|
|
867
901
|
return;
|
|
868
902
|
}
|
|
903
|
+
ctx.imageSmoothingEnabled = true;
|
|
904
|
+
ctx.imageSmoothingQuality = "high";
|
|
869
905
|
ctx.drawImage(img, 0, 0, width, height);
|
|
870
906
|
const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
|
|
871
907
|
resolve(compressedDataUrl);
|