openreplay/frontend/app/components/Dashboard/components/WidgetForm/renderMap.ts
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

28 lines
971 B
TypeScript

export const renderClickmapThumbnail = () =>
// @ts-ignore
import('@codewonders/html2canvas').then(({ default: html2canvas }) => {
// @ts-ignore
window.html2canvas = html2canvas;
const element = document.querySelector<HTMLIFrameElement>(
'#clickmap-render * iframe',
).contentDocument.body;
if (element) {
const dimensions = element.getBoundingClientRect();
return html2canvas(element, {
allowTaint: false,
logging: true,
scale: 1,
// allowTaint: true,
useCORS: true,
foreignObjectRendering: true,
height: dimensions.height > 900 ? 900 : dimensions.height,
width: dimensions.width > 1200 ? 1200 : dimensions.width,
x: 0,
y: 0,
ignoreElements: (e) => e.id.includes('render-ignore'),
})
.then((canvas) => canvas.toDataURL('img/png'))
.catch(console.log);
}
Promise.reject("can't find clickmap container");
});