From: Alexander Ebert Date: Mon, 4 Apr 2016 11:23:36 +0000 (+0200) Subject: Fixed handling of lists inside quotes X-Git-Tag: 2.1.11~42 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dda4c568b06b89938a5f6b823788cddc602cbe7f;p=GitHub%2FWoltLab%2FWCF.git Fixed handling of lists inside quotes --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index fe6091189b..fc68b1fbe3 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -1315,6 +1315,19 @@ RedactorPlugins.wbbcode = function() { var $tmp = ''; if (innerContent.length) { + // remove lists to prevent them being handled by the code above + var $cachedLists = []; + innerContent = innerContent.replace(/(<(ol|ul)[^>]*>[\s\S]+?<\/\2>)/g, function(match) { + var $hash = WCF.getUUID(); + + $cachedLists.push({ + hash: $hash, + content: match + }); + + return '@@' + $hash + '@@'; + }); + var $lines = innerContent.split('\n'); for (var $i = 0; $i < $lines.length; $i++) { var $line = $lines[$i]; @@ -1331,6 +1344,20 @@ RedactorPlugins.wbbcode = function() { $tmp += '
' + $line + '
'; } + + // reinsert lists + if ($cachedLists.length) { + for (var $i = 0, $length = $cachedLists.length; $i < $length; $i++) { + var $content = $cachedLists[$i].content; + + // line-breaks within list items must be a
instead of

+ $content = $content.replace(/(
  • [\s\S]*?<\/li>)/g, function(match) { + return $.trim(match).replace(/\n/g, '
    '); + }); + + $tmp = $tmp.replace(new RegExp('@@' + $cachedLists[$i].hash + '@@'), $content); + } + } } else { $tmp = '
    ' + self.opts.invisibleSpace + '
    '; @@ -1576,7 +1603,6 @@ RedactorPlugins.wbbcode = function() { // some fixes for paste from Microsoft Word / OpenOffice / LibreOffice if (/

    \s])\n([^<\s])/g, '$1 $2');