feedback-vos 1.0.45 → 1.0.47
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 +67 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -399,62 +399,76 @@ function ScreenshotButton({
|
|
|
399
399
|
const [tempScreenshot, setTempScreenshot] = react$1.useState(null);
|
|
400
400
|
const themeClasses = getThemeClasses(theme);
|
|
401
401
|
async function handleTakeScreenshot() {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
402
|
+
try {
|
|
403
|
+
setIsTakenScreenShot(true);
|
|
404
|
+
const canvas = await html2canvas__default.default(document.body, {
|
|
405
|
+
width: window.innerWidth,
|
|
406
|
+
height: window.innerHeight,
|
|
407
|
+
windowWidth: window.innerWidth,
|
|
408
|
+
windowHeight: window.innerHeight,
|
|
409
|
+
scrollX: -window.scrollX,
|
|
410
|
+
scrollY: -window.scrollY,
|
|
411
|
+
scale: 1,
|
|
412
|
+
// Use scale 1 for consistent sizing
|
|
413
|
+
useCORS: true,
|
|
414
|
+
allowTaint: true,
|
|
415
|
+
// Allow external images for better rendering
|
|
416
|
+
backgroundColor: null,
|
|
417
|
+
// Preserve page background
|
|
418
|
+
removeContainer: false,
|
|
419
|
+
// Maintain proper container rendering
|
|
420
|
+
logging: false,
|
|
421
|
+
ignoreElements: (element) => {
|
|
422
|
+
const isWidget = element.hasAttribute("data-feedback-widget") || element.closest("[data-feedback-widget]") !== null;
|
|
423
|
+
if (isWidget) return true;
|
|
424
|
+
if (element.tagName === "IMG" || element.tagName === "CANVAS" || element.tagName === "VIDEO") {
|
|
425
|
+
const rect = element.getBoundingClientRect();
|
|
426
|
+
if (rect.width === 0 || rect.height === 0) return true;
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
if (canvas.width === 0 || canvas.height === 0) {
|
|
432
|
+
console.warn("Screenshot failed: Captured canvas has 0 width or height");
|
|
433
|
+
return;
|
|
422
434
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
const isMobile = window.innerWidth < 768;
|
|
436
|
+
const targetWidth = isMobile ? 1080 : 1920;
|
|
437
|
+
const targetHeight = isMobile ? 1920 : 1080;
|
|
438
|
+
const normalizedCanvas = document.createElement("canvas");
|
|
439
|
+
normalizedCanvas.width = targetWidth;
|
|
440
|
+
normalizedCanvas.height = targetHeight;
|
|
441
|
+
const ctx = normalizedCanvas.getContext("2d");
|
|
442
|
+
if (!ctx) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
ctx.imageSmoothingEnabled = true;
|
|
446
|
+
ctx.imageSmoothingQuality = "high";
|
|
447
|
+
const sourceAspect = canvas.width / canvas.height;
|
|
448
|
+
const targetAspect = targetWidth / targetHeight;
|
|
449
|
+
let drawWidth = targetWidth;
|
|
450
|
+
let drawHeight = targetHeight;
|
|
451
|
+
let drawX = 0;
|
|
452
|
+
let drawY = 0;
|
|
453
|
+
if (sourceAspect > targetAspect) {
|
|
454
|
+
drawHeight = targetHeight;
|
|
455
|
+
drawWidth = drawHeight * sourceAspect;
|
|
456
|
+
drawX = (targetWidth - drawWidth) / 2;
|
|
457
|
+
} else {
|
|
458
|
+
drawWidth = targetWidth;
|
|
459
|
+
drawHeight = drawWidth / sourceAspect;
|
|
460
|
+
drawY = (targetHeight - drawHeight) / 2;
|
|
461
|
+
}
|
|
462
|
+
ctx.fillStyle = "#ffffff";
|
|
463
|
+
ctx.fillRect(0, 0, targetWidth, targetHeight);
|
|
464
|
+
ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
|
|
465
|
+
const base64image = normalizedCanvas.toDataURL("image/png", 1);
|
|
466
|
+
onScreenshotTook(base64image);
|
|
467
|
+
} catch (error) {
|
|
468
|
+
console.error("Failed to take screenshot:", error);
|
|
469
|
+
} finally {
|
|
432
470
|
setIsTakenScreenShot(false);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
ctx.imageSmoothingEnabled = true;
|
|
436
|
-
ctx.imageSmoothingQuality = "high";
|
|
437
|
-
const sourceAspect = canvas.width / canvas.height;
|
|
438
|
-
const targetAspect = targetWidth / targetHeight;
|
|
439
|
-
let drawWidth = targetWidth;
|
|
440
|
-
let drawHeight = targetHeight;
|
|
441
|
-
let drawX = 0;
|
|
442
|
-
let drawY = 0;
|
|
443
|
-
if (sourceAspect > targetAspect) {
|
|
444
|
-
drawHeight = targetHeight;
|
|
445
|
-
drawWidth = drawHeight * sourceAspect;
|
|
446
|
-
drawX = (targetWidth - drawWidth) / 2;
|
|
447
|
-
} else {
|
|
448
|
-
drawWidth = targetWidth;
|
|
449
|
-
drawHeight = drawWidth / sourceAspect;
|
|
450
|
-
drawY = (targetHeight - drawHeight) / 2;
|
|
451
471
|
}
|
|
452
|
-
ctx.fillStyle = "#ffffff";
|
|
453
|
-
ctx.fillRect(0, 0, targetWidth, targetHeight);
|
|
454
|
-
ctx.drawImage(canvas, drawX, drawY, drawWidth, drawHeight);
|
|
455
|
-
const base64image = normalizedCanvas.toDataURL("image/png", 1);
|
|
456
|
-
onScreenshotTook(base64image);
|
|
457
|
-
setIsTakenScreenShot(false);
|
|
458
472
|
}
|
|
459
473
|
function handleEditorSave(editedScreenshot) {
|
|
460
474
|
onScreenshotTook(editedScreenshot);
|