[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
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user