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 CHANGED
@@ -387,18 +387,52 @@ function ScreenshotButton({
387
387
  const themeClasses = getThemeClasses(theme);
388
388
  async function handleTakeScreenshot() {
389
389
  setIsTakenScreenShot(true);
390
- const canvas = await html2canvas__default.default(document.body, {
390
+ const canvas = await html2canvas__default.default(document.documentElement, {
391
391
  width: window.innerWidth,
392
392
  height: window.innerHeight,
393
- scrollX: -window.scrollX,
394
- scrollY: -window.scrollY,
393
+ x: 0,
394
+ y: 0,
395
395
  windowWidth: window.innerWidth,
396
396
  windowHeight: window.innerHeight,
397
+ scale: 1,
398
+ // Use scale 1 for consistent sizing
399
+ useCORS: true,
400
+ logging: false,
397
401
  ignoreElements: (element) => {
398
402
  return element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
399
403
  }
400
404
  });
401
- const base64image = canvas.toDataURL("image/png");
405
+ const targetWidth = 1920;
406
+ const targetHeight = 1080;
407
+ const normalizedCanvas = document.createElement("canvas");
408
+ normalizedCanvas.width = targetWidth;
409
+ normalizedCanvas.height = targetHeight;
410
+ const ctx = normalizedCanvas.getContext("2d");
411
+ if (!ctx) {
412
+ setIsTakenScreenShot(false);
413
+ return;
414
+ }
415
+ ctx.imageSmoothingEnabled = true;
416
+ ctx.imageSmoothingQuality = "high";
417
+ const sourceAspect = canvas.width / canvas.height;
418
+ const targetAspect = targetWidth / targetHeight;
419
+ let drawWidth = targetWidth;
420
+ let drawHeight = targetHeight;
421
+ let drawX = 0;
422
+ let drawY = 0;
423
+ if (sourceAspect > targetAspect) {
424
+ drawHeight = targetHeight;
425
+ drawWidth = drawHeight * sourceAspect;
426
+ drawX = (targetWidth - drawWidth) / 2;
427
+ } else {
428
+ drawWidth = targetWidth;
429
+ drawHeight = drawWidth / sourceAspect;
430
+ drawY = (targetHeight - drawHeight) / 2;
431
+ }
432
+ ctx.fillStyle = "#ffffff";
433
+ ctx.fillRect(0, 0, targetWidth, targetHeight);
434
+ ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
435
+ const base64image = normalizedCanvas.toDataURL("image/png", 1);
402
436
  onScreenshotTook(base64image);
403
437
  setIsTakenScreenShot(false);
404
438
  }
@@ -748,7 +782,7 @@ async function uploadFileToRepo(token, owner, repo, file, folderPath, defaultBra
748
782
  return rawUrl;
749
783
  }
750
784
  async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshotPath) {
751
- const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.7);
785
+ const compressedScreenshot = await compressScreenshot(screenshot, 1920, 0.85);
752
786
  const base64Content = compressedScreenshot.includes(",") ? compressedScreenshot.split(",")[1] : compressedScreenshot;
753
787
  const repoResponse = await fetch(
754
788
  `https://api.github.com/repos/${owner}/${repo}`,
@@ -850,7 +884,7 @@ async function uploadScreenshotToRepo(token, owner, repo, screenshot, screenshot
850
884
  console.log(`Screenshot uploaded successfully to: ${rawUrl}`);
851
885
  return rawUrl;
852
886
  }
853
- function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
887
+ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.85) {
854
888
  return new Promise((resolve, reject) => {
855
889
  if (typeof window === "undefined" || typeof document === "undefined") {
856
890
  reject(new Error("Screenshot compression only works in browser environments"));
@@ -872,6 +906,8 @@ function compressScreenshot(dataUrl, maxWidth = 1920, quality = 0.7) {
872
906
  reject(new Error("Could not get canvas context"));
873
907
  return;
874
908
  }
909
+ ctx.imageSmoothingEnabled = true;
910
+ ctx.imageSmoothingQuality = "high";
875
911
  ctx.drawImage(img, 0, 0, width, height);
876
912
  const compressedDataUrl = canvas.toDataURL("image/jpeg", quality);
877
913
  resolve(compressedDataUrl);