fix: More strict handling of paste board images

This commit is contained in:
Tom Moor
2023-03-06 20:30:29 -05:00
parent 234651448e
commit 28c4854985

View File

@@ -63,12 +63,11 @@ const uploadPlugin = (options: Options) =>
// an image version of the content, check if there is also text and
// use that instead in this scenario.
const html = event.clipboardData.getData("text/html");
const text = event.clipboardData.getData("text/plain");
const isMicrosoftOffice = html.includes(
"urn:schemas-microsoft-com:office"
);
if (text.length && isMicrosoftOffice) {
// Fallback to default paste behavior
// Fallback to default paste behavior if the clipboard contains HTML
// Even if there is an image, it's likely to be a screenshot from eg
// Microsoft Suite / Apple Numbers and not the original content.
if (html.length && !html.includes("<img")) {
return false;
}