From 5a1c78986126530ba1720e28fe10111752f0dc52 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 7 May 2018 11:16:20 +0200 Subject: [FIX] web_editor: drag and drop Commit 6494f511718 introduces an access token to read images inside an email. This avoids access errors when accessing the email through a proxy (e.g. Gmail). That implies that all images are added as attachments. When going through the usual media dialog, the form is submitted to action '/web_editor/attachment/add', creating the attachment. However, the copy or the drag and drop of an image completely fails. Indeed, the same method `_onImageUpload` is called, but with a completely different argument type: `attachments` is a `FileList`, not a list of attachments. To solve this, we only call `_onImageUpload` on a the custom `onUpload` callback, which is not triggered during a drag and drop or a copy. Any image included thanks to these methods will be post-processed in the `create` method of `mail.message` (`base64_to_boundary`). Unfortunately, it's not possible to simulate an actual drag and drop or a copy, so we cannot add a test. opw-1840237 opw-1840411 --- addons/web_editor/static/lib/summernote/src/js/EventHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web_editor/static/lib/summernote/src/js/EventHandler.js') diff --git a/addons/web_editor/static/lib/summernote/src/js/EventHandler.js b/addons/web_editor/static/lib/summernote/src/js/EventHandler.js index 9701b8728d2..efa57f8111c 100644 --- a/addons/web_editor/static/lib/summernote/src/js/EventHandler.js +++ b/addons/web_editor/static/lib/summernote/src/js/EventHandler.js @@ -472,7 +472,8 @@ define([ onImageUpload: options.onImageUpload, onImageUploadError: options.onImageUploadError, onMediaDelete: options.onMediaDelete, - onToolbarClick: options.onToolbarClick + onToolbarClick: options.onToolbarClick, + onUpload: options.onUpload, }); var styleInfo = modules.editor.styleFromNode(layoutInfo.editable()); -- cgit v1.2.3