Fix adding sticker in media editor

This commit is contained in:
Fedor Indutny 2024-09-30 16:59:55 -07:00 committed by GitHub
parent b68e731950
commit 697df7e946
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 10 deletions

View file

@ -17,6 +17,7 @@ import { IMAGE_PNG } from '../types/MIME';
import { strictAssert } from '../util/assert';
import { drop } from '../util/drop';
import { splitText } from '../util/splitText';
import { loadImage } from '../util/loadImage';
import { Button, ButtonVariant } from './Button';
import { Modal } from './Modal';
import { ConfirmationDialog } from './ConfirmationDialog';
@ -373,14 +374,7 @@ export async function _generateImageBlob({
);
const svgURL = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
const img = new Image();
await new Promise((resolve, reject) => {
img.addEventListener('load', resolve);
img.addEventListener('error', () =>
reject(new Error('Failed to load image'))
);
img.src = svgURL;
});
const img = await loadImage(svgURL);
context.drawImage(img, 0, 0, PRINT_WIDTH, PRINT_HEIGHT);