summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2015-11-27 13:29:09 +0100
committerNicolas Lempereur <nle@odoo.com>2015-11-30 10:35:35 +0100
commit919678bed3a5a49ea3571e05b4ef4c1b8fef88ff (patch)
treed8314ffe3ac68016f78aa9d23496883be6099e03 /addons/web_editor/static/src
parentf77e44f2ddddabd71e443278ca00193215bf9954 (diff)
[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
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/summernote.js6
1 files changed, 6 insertions, 0 deletions
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 = $('<div/>').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,'<br>');
+ });
+ }
/*
remove undesirable tag