Merge pull request #20830 from JoVictorNunes/fix-slide-snapshot-overflowing

fix(presentation): presentation snapshot overflowing the slide
This commit is contained in:
Ramón Souza 2024-08-02 10:24:41 -03:00 committed by GitHub
commit 1f87bfb2a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -304,20 +304,14 @@ const PresentationMenu = (props) => {
try {
// filter shapes that are inside the slide
const backgroundShape = tldrawAPI.getCurrentPageShapes().find((s) => s.id === `shape:BG-${slideNum}`);
const shapes = tldrawAPI.getCurrentPageShapes().filter(
(shape) => shape.x <= backgroundShape.props.w
&& shape.y <= backgroundShape.props.h
&& shape.x >= 0
&& shape.y >= 0,
);
const shapes = tldrawAPI.getCurrentPageShapes();
const svgElem = await tldrawAPI.getSvg(shapes.map((shape) => shape.id));
svgElem.setAttribute('width', backgroundShape.props.w);
svgElem.setAttribute('height', backgroundShape.props.h);
svgElem.setAttribute('viewBox', `1 1 ${backgroundShape.props.w} ${backgroundShape.props.h}`);
// workaround for ios
if (isIos || isSafari) {
svgElem.setAttribute('width', backgroundShape.props.w);
svgElem.setAttribute('height', backgroundShape.props.h);
svgElem.setAttribute('viewBox', `1 1 ${backgroundShape.props.w} ${backgroundShape.props.h}`);
const svgString = new XMLSerializer().serializeToString(svgElem);
const blob = new Blob([svgString], { type: 'image/svg+xml' });