diff --git a/addons/web_editor/static/src/css/backend.css b/addons/web_editor/static/src/css/backend.css
index 42871187d12..2462aea3b09 100644
--- a/addons/web_editor/static/src/css/backend.css
+++ b/addons/web_editor/static/src/css/backend.css
@@ -5,8 +5,12 @@
line-height: initial !important;
color: initial !important;
}
-.oe_form_field_html_text .note-editable.o_readonly {
+.oe_form_field_html_text iframe.o_readonly {
min-height: 1em;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ border: 0;
}
.oe_form_field_html_text .note-editable p {
margin: initial;
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index acf603697b8..43f411ef988 100644
--- a/addons/web_editor/static/src/js/backend.js
+++ b/addons/web_editor/static/src/js/backend.js
@@ -62,9 +62,15 @@ var FieldTextHtmlSimple = widget.extend({
initialize_content: function() {
var self = this;
this.$textarea = this.$("textarea").val(this.get('value') || "
");
+ this.$content = $();
if (this.get("effective_readonly")) {
- this.$textarea.hide().after('');
+ this.$textarea.hide().after('');
+ setTimeout(function () {
+ self.$content = $("body", self.$('iframe').contents()[0]);
+ self.$content.html(self.text_to_html(self.get('value')));
+ self.resize();
+ });
} else {
this.$textarea.summernote(this._config());
@@ -77,8 +83,10 @@ var FieldTextHtmlSimple = widget.extend({
var reset = _.bind(this.reset_history, this);
this.view.on('load_record', this, reset);
setTimeout(reset, 0);
+
+ this.$content = this.$('.note-editable:first');
+ transcoder.style_to_class(this.$content);
}
- this.$content = this.$('.note-editable:first');
$(".oe-view-manager-content").on("scroll", function () {
$('.o_table_handler').remove();
@@ -113,10 +121,18 @@ var FieldTextHtmlSimple = widget.extend({
return this.$content.focus();
};
},
+ resize: function() {
+ this.$('iframe').css('height', '0px').css('height', Math.max(180, Math.min(this.$content[0] ? this.$content[0].scrollHeight : 0, 500)) + 'px');
+ },
render_value: function() {
var value = this.get('value');
this.$textarea.val(value || '');
this.$content.html(this.text_to_html(value));
+ if (this.get("effective_readonly")) {
+ this.resize();
+ } else {
+ transcoder.style_to_class(this.$content);
+ }
if (this.$content.is(document.activeElement)) {
this.focus();
}