[FIX] web_editor: use iframe instead of direct content for preview
The preview is not equal to the real email rendering because the backend css is present.
This commit is contained in:
@@ -5,8 +5,12 @@
|
|||||||
line-height: initial !important;
|
line-height: initial !important;
|
||||||
color: 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;
|
min-height: 1em;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
}
|
}
|
||||||
.oe_form_field_html_text .note-editable p {
|
.oe_form_field_html_text .note-editable p {
|
||||||
margin: initial;
|
margin: initial;
|
||||||
|
|||||||
@@ -62,9 +62,15 @@ var FieldTextHtmlSimple = widget.extend({
|
|||||||
initialize_content: function() {
|
initialize_content: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$textarea = this.$("textarea").val(this.get('value') || "<p><br/></p>");
|
this.$textarea = this.$("textarea").val(this.get('value') || "<p><br/></p>");
|
||||||
|
this.$content = $();
|
||||||
|
|
||||||
if (this.get("effective_readonly")) {
|
if (this.get("effective_readonly")) {
|
||||||
this.$textarea.hide().after('<div class="note-editable o_readonly"/>');
|
this.$textarea.hide().after('<iframe class="o_readonly"/>');
|
||||||
|
setTimeout(function () {
|
||||||
|
self.$content = $("body", self.$('iframe').contents()[0]);
|
||||||
|
self.$content.html(self.text_to_html(self.get('value')));
|
||||||
|
self.resize();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$textarea.summernote(this._config());
|
this.$textarea.summernote(this._config());
|
||||||
|
|
||||||
@@ -77,8 +83,10 @@ var FieldTextHtmlSimple = widget.extend({
|
|||||||
var reset = _.bind(this.reset_history, this);
|
var reset = _.bind(this.reset_history, this);
|
||||||
this.view.on('load_record', this, reset);
|
this.view.on('load_record', this, reset);
|
||||||
setTimeout(reset, 0);
|
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 () {
|
$(".oe-view-manager-content").on("scroll", function () {
|
||||||
$('.o_table_handler').remove();
|
$('.o_table_handler').remove();
|
||||||
@@ -113,10 +121,18 @@ var FieldTextHtmlSimple = widget.extend({
|
|||||||
return this.$content.focus();
|
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() {
|
render_value: function() {
|
||||||
var value = this.get('value');
|
var value = this.get('value');
|
||||||
this.$textarea.val(value || '');
|
this.$textarea.val(value || '');
|
||||||
this.$content.html(this.text_to_html(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)) {
|
if (this.$content.is(document.activeElement)) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user