From 3a3e9b47bbfe5fef7f04c1c56b5e88180b12cdcb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 12 Feb 2015 14:10:48 +0100 Subject: [PATCH] Fixed superfluous newlines causing incorrect server-side rendering --- .../js/3rdParty/redactor/plugins/wutil.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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. */ -- 2.20.1