Fixed handling of empty list items / code-bbcode
authorAlexander Ebert <ebert@woltlab.com>
Tue, 10 Mar 2015 16:53:19 +0000 (17:53 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 10 Mar 2015 16:53:19 +0000 (17:53 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index adfee4506dc2d0919bd86b5e3a85ef41d14bddad..ce12a6248307be02b9cd473d2e344627a78baf47 100644 (file)
@@ -1301,7 +1301,7 @@ RedactorPlugins.wbbcode = function() {
                                        //$value = $value.replace(/^\[tt\](.*)\[\/tt\]/, '<span class="inlineCode">$1</span>');
                                        
                                        // [code]
-                                       $value = $value.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/, function(matches, parameters, content) {
+                                       $value = $value.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/, (function(matches, parameters, content) {
                                                var $highlighter = 'plain';
                                                var $lineNumber = 0;
                                                var $filename = '';
@@ -1359,7 +1359,12 @@ RedactorPlugins.wbbcode = function() {
                                                content = content.replace(/^\n+/, '').replace(/\n+$/, '').split(/\n/);
                                                var $lines = '';
                                                for (var $i = 0; $i < content.length; $i++) {
-                                                       $lines += '<li>' + content[$i] + '</li>';
+                                                       var $line = content[$i];
+                                                       if (!$line.length) {
+                                                               $line = this.opts.invisibleSpace;
+                                                       }
+                                                       
+                                                       $lines += '<li>' + $line + '</li>';
                                                }
                                                
                                                return '<div class="codeBox container" contenteditable="false" data-highlighter="' + $highlighter + '"' + ($filename ? ' data-filename="' + WCF.String.escapeHTML($filename) + '"' : '' ) + '>'
@@ -1372,7 +1377,7 @@ RedactorPlugins.wbbcode = function() {
                                                                + '</ol>'
                                                        + '</div>'
                                                + '</div>';
-                                       });
+                                       }).bind(this));
                                        
                                        data = data.replace($regex, $value);
                                }
index e80a5e1e46ccddb7804f0e4dbe08adf0bb296cb5..7a9b9dc92f782a297e9dcdf3747405e206c71d52 100644 (file)
@@ -996,6 +996,10 @@ RedactorPlugins.wutil = function() {
                                        var $parent = $listItem.parentElement;
                                        if ($parent.children.length > 1) {
                                                $listItem.parentElement.removeChild($listItem);
+                                               
+                                               // node list is live
+                                               $i--;
+                                               $length--;
                                        }
                                }
                        }