From: Alexander Ebert Date: Thu, 12 Feb 2015 13:10:48 +0000 (+0100) Subject: Fixed superfluous newlines causing incorrect server-side rendering X-Git-Tag: 2.1.0_RC_1~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3a3e9b47bbfe5fef7f04c1c56b5e88180b12cdcb;p=GitHub%2FWoltLab%2FWCF.git Fixed superfluous newlines causing incorrect server-side rendering --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index efc0066bb3..345d591023 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -232,8 +232,7 @@ RedactorPlugins.wutil = function() { var $text = $.trim(this.$textarea.val()); - // remove linebreak after [/quote] - $text = $text.replace(/\[\/quote\]\n/g, '[/quote]'); + $text = this.wutil._removeSuperfluousNewlines($text); return $text; }, @@ -260,8 +259,7 @@ RedactorPlugins.wutil = function() { var $text = $.trim(this.wbbcode.convertFromHtml(this.$textarea.val())); - // remove linebreak after [/quote] - $text = $text.replace(/\[\/quote\]\n/g, '[/quote]'); + $text = this.wutil._removeSuperfluousNewlines($text); this.$textarea.val($text); } @@ -269,6 +267,22 @@ RedactorPlugins.wutil = function() { this.wutil.autosavePurge(); }, + /** + * Removes newlines after certain elements which have been inserted for + * readability but do not represent an actual newline. + * + * @param string text + * @return string + */ + _removeSuperfluousNewlines: function(text) { + text = text.replace(/(\[\/(?:align|code|quote)\])\n/g, '$1'); + + var $data = { text: text }; + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'wutil_removeSuperfluousNewlines', $data); + + return $data.text; + }, + /** * Resets the editor's contents. */