Fixed a few newline issues raised w/ quotes
authorAlexander Ebert <ebert@woltlab.com>
Thu, 12 Feb 2015 22:01:02 +0000 (23:01 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 12 Feb 2015 22:01:02 +0000 (23:01 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index 2ec6061dc432822a2119e99cdef409d9d39d5513..8aaf664184f3df2db49692f5f5403bef531a6630 100644 (file)
@@ -276,8 +276,8 @@ RedactorPlugins.wbbcode = function() {
                        // 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>');
index 345d5910232e6d5d3d0badb80ea6c1f5524252b4..038c9304111c12ba866aec5fb50604ff350cb1f6 100644 (file)
@@ -283,6 +283,22 @@ RedactorPlugins.wutil = function() {
                        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.
                 */
@@ -873,6 +889,7 @@ RedactorPlugins.wutil = function() {
                                $wasInWysiwygMode = true;
                        }
                        
+                       value = this.wutil.addNewlines(value);
                        this.$textarea.val(value);
                        
                        if ($wasInWysiwygMode) {