Composer: Fix several pasting bugs on Firefox (#1478)

This commit is contained in:
Alexander Zinchuk 2021-09-30 14:02:57 +03:00
parent 92ff13dd1e
commit 54d6b581da
2 changed files with 7 additions and 4 deletions

View File

@ -29,12 +29,12 @@ export default (
const file = media && media.getAsFile();
const pastedText = e.clipboardData.getData('text').substring(0, MAX_MESSAGE_LENGTH);
e.preventDefault();
if (!file && !pastedText) {
return;
}
e.preventDefault();
if (file && !editedMessage) {
const attachment = await buildAttachment(file.name, file, true);
setAttachments((attachments) => [

View File

@ -44,6 +44,9 @@ async function scale(
try {
const bitmap = await window.createImageBitmap(img,
{ resizeWidth: width, resizeHeight: height, resizeQuality: 'high' });
if (bitmap.height !== height || bitmap.width !== width) {
throw new Error('Image bitmap resize not supported!'); // FF93 added support for options, but not resize
}
return await new Promise((res) => {
const canvas = document.createElement('canvas');
canvas.width = bitmap.width;
@ -58,10 +61,10 @@ async function scale(
});
} catch (e) {
// Fallback. Firefox below 93 does not recognize `createImageBitmap` with 2 parameters
return steppedScale(img, width, height, 0.5, outputType);
return steppedScale(img, width, height, undefined, outputType);
}
} else {
return steppedScale(img, width, height, 0.5, outputType);
return steppedScale(img, width, height, undefined, outputType);
}
}