// remove empty links
html = html.replace(/<a[^>]*?><\/a>/g, '');
- // drop empty paragraphs
- html = html.replace(/<p><\/p>/g, '');
+ // handle empty paragraphs not followed by an empty one
+ html = html.replace(/<p><\/p><p>(?!<br>)/g, '<p>@@@wcf_empty_line@@@</p><p>');
// remove <br> right in front of </p> (does not match <p><br></p> since it has been converted already)
html = html.replace(/<br( \/)?><\/p>/g, '</p>');
return $data.text;
},
+ /**
+ * Adds newlines after certain elements, this is actually the reverse of
+ * _removeSuperfluousNewlines() which removes them prior to submitting.
+ *
+ * @param string
+ * @return string
+ */
+ addNewlines: function(text) {
+ text = text.replace(/(\[\/(?:align|code|quote)\])/g, '$1\n');
+
+ var $data = { text: text };
+ WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'wutil_addNewlines', $data);
+
+ return $data.text;
+ },
+
/**
* Resets the editor's contents.
*/
$wasInWysiwygMode = true;
}
+ value = this.wutil.addNewlines(value);
this.$textarea.val(value);
if ($wasInWysiwygMode) {