Fixed superfluous newlines causing incorrect server-side rendering
authorAlexander Ebert <ebert@woltlab.com>
Thu, 12 Feb 2015 13:10:48 +0000 (14:10 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 12 Feb 2015 13:10:48 +0000 (14:10 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index efc0066bb31dff340f67b94a06e828ae118d1ff0..345d5910232e6d5d3d0badb80ea6c1f5524252b4 100644 (file)
@@ -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.
                 */