Fixed expanded formatting in lists
authorAlexander Ebert <ebert@woltlab.com>
Sun, 26 Apr 2015 13:49:23 +0000 (15:49 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 26 Apr 2015 13:49:23 +0000 (15:49 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 6719d5a471555c88e2ec8d12265cdc4b5dea7ab9..2d4263cc48d7ec9debd974c9db9b5c810affa877 100644 (file)
@@ -958,10 +958,20 @@ RedactorPlugins.wbbcode = function() {
                        }
                        
                        // [*]
+                       var $hasListItems = false;
                        data = data.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi, function(match, content) {
+                               $hasListItems = true;
+                               
                                return '<li>' + $.trim(content) + '</li>';
                        });
                        
+                       // fix expanded formatting for lists
+                       if ($hasListItems) {
+                               data = data.replace(/(<p style="[^"]+">)(\[list[^\]]*\])?<li>/g, '$2<li>$1');
+                               data = data.replace(/(<p style="[^"]+">)<\/li><li>/g, '</li><li>$1');
+                               data = data.replace(/(<\/li>\[\/list\])<\/p>/g, '$1');
+                       }
+                       
                        // fix superflous newlines with nested lists
                        data = data.replace(/\n*(\[list\]<\/li>)/g, '$1');