From 0c8ed211401d8d07b57b68c3abbb0df4dfba9358 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 9 Apr 2021 18:48:41 +0200 Subject: [PATCH] Detection of pasted blob uris in iOS --- .../redactor2/plugins/WoltLabPaste.js | 24 +++++++++++++++---- .../files/js/WoltLabSuite/Core/FileUtil.js | 8 ++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index beebe1dec7..d97b619f26 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -351,7 +351,7 @@ $.Redactor.prototype.WoltLabPaste = function() { if (!data.pre && !data.text) { elBySelAll('img', div, (function(img) { var src = img.src; - if (src.indexOf('data:image') === 0 && src !== transparentGif) { + if ((src.indexOf('data:image') === 0 | src.indexOf("blob:") === 0) && src !== transparentGif) { img.src = transparentGif; var uuid = WCF.getUUID(); @@ -397,10 +397,24 @@ $.Redactor.prototype.WoltLabPaste = function() { img.parentNode.removeChild(img); } else { - WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'pasteFromClipboard_' + this.$element[0].id, { - blob: this.utils.dataURItoBlob(imgData.src), - replace: img - }); + if (imgData.src.indexOf("blob:") === 0) { + window.fetch(imgData.src) + .then(function (response) { + return response.blob(); + }) + .then((function (blob) { + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'pasteFromClipboard_' + this.$element[0].id, { + blob: blob, + replace: img + }); + }).bind(this)); + } + else { + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'pasteFromClipboard_' + this.$element[0].id, { + blob: this.utils.dataURItoBlob(imgData.src), + replace: img + }); + } } } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/FileUtil.js b/wcfsetup/install/files/js/WoltLabSuite/Core/FileUtil.js index a7390b3ced..d356f98914 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/FileUtil.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/FileUtil.js @@ -122,7 +122,13 @@ define(['Dictionary', 'StringUtil'], function(Dictionary, StringUtil) { // word 'application/msword': 'doc', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx', - 'application/vnd.oasis.opendocument.text': 'odt' + 'application/vnd.oasis.opendocument.text': 'odt', + + // iOS + 'public.jpeg': 'jpeg', + 'public.png': 'png', + 'com.compuserve.gif': 'gif', + 'org.webmproject.webp': 'webp' }); return { -- 2.20.1