From 919678bed3a5a49ea3571e05b4ef4c1b8fef88ff Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 27 Nov 2015 13:29:09 +0100 Subject: [FIX] web_editor: fallback to plain text when pasting Depending of the location where the "Copying" happened, only text/plain content could be available from the clipboard component. So if no text/html was retrieved, we should fall back to plain text pasting. closes #9787 opw-657137 --- addons/web_editor/static/src/js/summernote.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'addons/web_editor/static/src/js/summernote.js') diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index c5a9b3ebbef..ff509800c50 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -2320,6 +2320,12 @@ function summernote_paste (event) { var html = clipboardData.getData("text/html"); var $node = $('
').html(html); + // if copying source did not provide html, default to plain text + if(!html) { + $node.text(clipboardData.getData("text/plain")).html(function(_, html){ + return html.replace(/\r?\n/g,'
'); + }); + } /* remove undesirable tag -- cgit v1.2.3