From af865c2e9ea1dc1890ef33add9a6e4bc657068e0 Mon Sep 17 00:00:00 2001
From: Christophe Matthieu
Date: Mon, 7 Nov 2016 12:02:13 +0100
Subject: [PATCH] [FIX] web_editor: widget html preview doesn't match wysiwig
editor (widget html iframe)
The widget html is used for plain text and html content.
Need to check if the content is a valid html code, if is not wrap with p tag every lines.
opw-692158
---
addons/web_editor/static/src/js/backend.js | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index 671e89a2b7f..0cd9abb5596 100644
--- a/addons/web_editor/static/src/js/backend.js
+++ b/addons/web_editor/static/src/js/backend.js
@@ -113,11 +113,16 @@ var FieldTextHtmlSimple = widget.extend({
},
text_to_html: function (text) {
var value = text || "";
- if (value.match(/^\s*$/)) {
- value = '
';
- } else {
- value = ""+value.split(/
/).join("
")+"
";
- value = value.replace(/<\/p>/g, '').replace('
', '
').replace('
', '
');
+ try {
+ $(text)[0].innerHTML;
+ return text;
+ } catch (e) {
+ if (value.match(/^\s*$/)) {
+ value = '
';
+ } else {
+ value = ""+value.split(/
/).join("
")+"
";
+ value = value.replace(/<\/p>/g, '').replace('
', '
').replace('
', '');
+ }
}
return value;
},