summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-11-08 14:20:07 +0100
committerChristophe Simonis <chs@odoo.com>2016-11-08 14:20:07 +0100
commitc19f54650594211e4af7e68214de4f118686b8e1 (patch)
treeae27c8fb401e8159bad45781a8e7b0ab20235b35 /addons/web_editor/static/src
parentd32970830ea938bead60e8368a3389f9d20853df (diff)
parentb7957550010e0cecc1dbefcbc122d9a49f50ae1d (diff)
[MERGE] forward port branch 9.0 up to b795755
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/backend.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index 468fab0c728..17ce8c3c1a1 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 = '<p><br/></p>';
- } else {
- value = "<p>"+value.split(/<br\/?>/).join("<br/></p><p>")+"</p>";
- value = value.replace(/<p><\/p>/g, '').replace('<p><p>', '<p>').replace('<p><p ', '<p ').replace('</p></p>', '</p>');
+ try {
+ $(text)[0].innerHTML;
+ return text;
+ } catch (e) {
+ if (value.match(/^\s*$/)) {
+ value = '<p><br/></p>';
+ } else {
+ value = "<p>"+value.split(/<br\/?>/).join("<br/></p><p>")+"</p>";
+ value = value.replace(/<p><\/p>/g, '').replace('<p><p>', '<p>').replace('<p><p ', '<p ').replace('</p></p>', '</p>');
+ }
}
return value;
},
@@ -213,7 +218,7 @@ var FieldTextHtml = widget.extend({
self.$iframe.css("height", (self.$body.find("#oe_snippets").length ? 500 : 300) + "px");
}
};
- $(window).on('resize', self.resize);
+ $(window).on('resize', this.resize);
var def = this._super.apply(this, arguments);
this.$translate.remove();
@@ -374,7 +379,7 @@ var FieldTextHtml = widget.extend({
}
},
destroy: function () {
- $(window).off('resize', self.resize);
+ $(window).off('resize', this.resize);
delete window.odoo[this.callback+"_editor"];
delete window.odoo[this.callback+"_content"];
delete window.odoo[this.callback+"_updown"];