corpushub-design-system 0.0.10 → 0.0.11
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Best-effort tab screenshot for error reports.
|
|
3
|
-
*
|
|
3
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
4
4
|
*/
|
|
5
5
|
export declare function captureTabScreenshot(): Promise<string | null>;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import html2canvas from 'html2canvas';
|
|
2
2
|
const MAX_WIDTH = 1600;
|
|
3
3
|
const JPEG_QUALITY = 0.85;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const root = modal?.closest('.MuiModal-root') ||
|
|
8
|
-
modal;
|
|
9
|
-
if (root) {
|
|
10
|
-
hidden.push({ el: root, display: root.style.display });
|
|
11
|
-
root.style.display = 'none';
|
|
12
|
-
}
|
|
13
|
-
return hidden;
|
|
14
|
-
}
|
|
15
|
-
function restoreHidden(hidden) {
|
|
16
|
-
hidden.forEach(({ el, display }) => {
|
|
17
|
-
el.style.display = display;
|
|
18
|
-
});
|
|
4
|
+
function shouldIgnoreElement(el) {
|
|
5
|
+
return (el.classList.contains('MuiModal-root') ||
|
|
6
|
+
el.classList.contains('Toastify'));
|
|
19
7
|
}
|
|
20
8
|
function toJpegDataUrl(canvas) {
|
|
21
9
|
let out = canvas;
|
|
@@ -33,24 +21,21 @@ function toJpegDataUrl(canvas) {
|
|
|
33
21
|
}
|
|
34
22
|
/**
|
|
35
23
|
* Best-effort tab screenshot for error reports.
|
|
36
|
-
*
|
|
24
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
37
25
|
*/
|
|
38
26
|
export async function captureTabScreenshot() {
|
|
39
27
|
if (typeof document === 'undefined' || !document.body) {
|
|
40
28
|
return null;
|
|
41
29
|
}
|
|
42
|
-
const hidden = hideReportUi();
|
|
43
30
|
try {
|
|
44
31
|
const canvas = await html2canvas(document.body, {
|
|
45
32
|
logging: false,
|
|
46
33
|
useCORS: true,
|
|
34
|
+
ignoreElements: shouldIgnoreElement,
|
|
47
35
|
});
|
|
48
36
|
return toJpegDataUrl(canvas);
|
|
49
37
|
}
|
|
50
38
|
catch {
|
|
51
39
|
return null;
|
|
52
40
|
}
|
|
53
|
-
finally {
|
|
54
|
-
restoreHidden(hidden);
|
|
55
|
-
}
|
|
56
41
|
}
|