releasebird-javascript-sdk 1.0.43 → 1.0.45
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/.claude/settings.local.json +2 -1
- package/build/index.js +1 -1
- package/package.json +3 -2
- package/published/1.0.43/index.js +1 -1
- package/published/1.0.44/index.js +1 -0
- package/published/1.0.45/index.js +1 -0
- package/published/latest/index.js +1 -1
- package/src/RbirdScreenshotManager.js +41 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SVGEditor from "./SVGEditor";
|
|
2
|
-
import
|
|
2
|
+
import * as htmlToImage from 'html-to-image';
|
|
3
3
|
|
|
4
4
|
export default class RbirdScreenshotManager {
|
|
5
5
|
|
|
@@ -92,34 +92,56 @@ export default class RbirdScreenshotManager {
|
|
|
92
92
|
|
|
93
93
|
// Wait a moment for the loader to render, then hide our UI elements and take the screenshot
|
|
94
94
|
setTimeout(() => {
|
|
95
|
-
//
|
|
96
|
-
const originalLoaderVisibility = loader.style.visibility;
|
|
97
|
-
const originalBoundaryVisibility = that.boundary ? that.boundary.style.visibility : null;
|
|
98
|
-
|
|
99
|
-
// Hide only the close button, but keep the boundary (with drawings) visible
|
|
95
|
+
// Hide the close button and toolbar
|
|
100
96
|
const closeButton = document.getElementById('screenshotCloseButton');
|
|
97
|
+
const toolbar = document.querySelector('.menu'); // SVGEditor toolbar
|
|
98
|
+
|
|
101
99
|
const originalCloseButtonVisibility = closeButton ? closeButton.style.visibility : null;
|
|
100
|
+
const originalToolbarVisibility = toolbar ? toolbar.style.visibility : null;
|
|
102
101
|
|
|
103
102
|
// Hide elements using visibility instead of display to maintain layout
|
|
104
103
|
loader.style.visibility = 'hidden';
|
|
105
104
|
if (closeButton) {
|
|
106
105
|
closeButton.style.visibility = 'hidden';
|
|
107
106
|
}
|
|
107
|
+
if (toolbar) {
|
|
108
|
+
toolbar.style.visibility = 'hidden';
|
|
109
|
+
}
|
|
108
110
|
|
|
109
111
|
// Use requestAnimationFrame to ensure the changes are applied before screenshot
|
|
110
112
|
requestAnimationFrame(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
// Use html-to-image's toJpeg method with higher resolution
|
|
114
|
+
// Capture only the visible viewport
|
|
115
|
+
htmlToImage.toJpeg(document.body, {
|
|
116
|
+
quality: 0.95,
|
|
117
|
+
pixelRatio: 2, // Higher resolution (2x)
|
|
118
|
+
cacheBust: true,
|
|
119
|
+
width: window.innerWidth,
|
|
120
|
+
height: window.innerHeight,
|
|
121
|
+
style: {
|
|
122
|
+
margin: '0',
|
|
123
|
+
padding: '0'
|
|
124
|
+
},
|
|
125
|
+
filter: (node) => {
|
|
126
|
+
// Filter out the loader and toolbar elements
|
|
127
|
+
if (node.id === 'rbirdScreenshotLoader') {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
// Also filter by class
|
|
131
|
+
if (node.classList && node.classList.contains('menu')) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}).then(function (dataUrl) {
|
|
118
137
|
// Restore visibility
|
|
119
|
-
loader.style.visibility =
|
|
138
|
+
loader.style.visibility = 'visible';
|
|
120
139
|
if (closeButton) {
|
|
121
140
|
closeButton.style.visibility = originalCloseButtonVisibility;
|
|
122
141
|
}
|
|
142
|
+
if (toolbar) {
|
|
143
|
+
toolbar.style.visibility = originalToolbarVisibility;
|
|
144
|
+
}
|
|
123
145
|
|
|
124
146
|
that.hideLoader();
|
|
125
147
|
|
|
@@ -127,19 +149,21 @@ export default class RbirdScreenshotManager {
|
|
|
127
149
|
if (widgetInstance.iframe) {
|
|
128
150
|
widgetInstance.iframe.contentWindow?.postMessage({
|
|
129
151
|
type: 'screenshot',
|
|
130
|
-
screenshot:
|
|
152
|
+
screenshot: dataUrl
|
|
131
153
|
}, '*');
|
|
132
154
|
}
|
|
133
155
|
|
|
134
156
|
that.deactivateMarker();
|
|
135
157
|
|
|
136
|
-
//document.body.appendChild(canvas);
|
|
137
158
|
}).catch((e) => {
|
|
138
159
|
// Restore visibility on error
|
|
139
|
-
loader.style.visibility =
|
|
160
|
+
loader.style.visibility = 'visible';
|
|
140
161
|
if (closeButton) {
|
|
141
162
|
closeButton.style.visibility = originalCloseButtonVisibility;
|
|
142
163
|
}
|
|
164
|
+
if (toolbar) {
|
|
165
|
+
toolbar.style.visibility = originalToolbarVisibility;
|
|
166
|
+
}
|
|
143
167
|
that.hideLoader();
|
|
144
168
|
console.error('Screenshot error:', e);
|
|
145
169
|
});
|