Composer: Fix several pasting bugs on Firefox (#1478)
This commit is contained in:
parent
92ff13dd1e
commit
54d6b581da
@ -29,12 +29,12 @@ export default (
|
|||||||
const file = media && media.getAsFile();
|
const file = media && media.getAsFile();
|
||||||
const pastedText = e.clipboardData.getData('text').substring(0, MAX_MESSAGE_LENGTH);
|
const pastedText = e.clipboardData.getData('text').substring(0, MAX_MESSAGE_LENGTH);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
if (!file && !pastedText) {
|
if (!file && !pastedText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (file && !editedMessage) {
|
if (file && !editedMessage) {
|
||||||
const attachment = await buildAttachment(file.name, file, true);
|
const attachment = await buildAttachment(file.name, file, true);
|
||||||
setAttachments((attachments) => [
|
setAttachments((attachments) => [
|
||||||
|
|||||||
@ -44,6 +44,9 @@ async function scale(
|
|||||||
try {
|
try {
|
||||||
const bitmap = await window.createImageBitmap(img,
|
const bitmap = await window.createImageBitmap(img,
|
||||||
{ resizeWidth: width, resizeHeight: height, resizeQuality: 'high' });
|
{ 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) => {
|
return await new Promise((res) => {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = bitmap.width;
|
canvas.width = bitmap.width;
|
||||||
@ -58,10 +61,10 @@ async function scale(
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Fallback. Firefox below 93 does not recognize `createImageBitmap` with 2 parameters
|
// 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 {
|
} else {
|
||||||
return steppedScale(img, width, height, 0.5, outputType);
|
return steppedScale(img, width, height, undefined, outputType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user