From: Alexander Ebert Date: Tue, 16 Dec 2014 12:38:47 +0000 (+0100) Subject: Improved handling of newlines in list items X-Git-Tag: 2.1.0_Beta_2~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a99e267f288e30581023467150c07fef6fca3cc1;p=GitHub%2FWoltLab%2FWCF.git Improved handling of newlines in list items --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index aad1352697..2a5e4bf742 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -874,6 +874,20 @@ RedactorPlugins.wbbcode = function() { // drop trailing line breaks data = data.replace(/\n*$/, ''); + // line-breaks within list items must be a
instead of

+ var $listItems = [ ]; + data = data.replace(/(
  • [\s\S]*?<\/li>)/g, function(match) { + match = $.trim(match).replace(/\n/, '
    '); + + var $key = WCF.getUUID(); + $listItems.push({ + key: $key, + content: match + }); + + return $key; + }); + // convert line breaks into

    or empty lines to


    var $tmp = data.split("\n"); @@ -911,6 +925,13 @@ RedactorPlugins.wbbcode = function() { } } + // insert list items + if ($listItems.length) { + for (var $i = $listItems.length - 1; $i >= 0; $i--) { + data = data.replace($listItems[$i].key, $listItems[$i].content); + } + } + // insert quotes if ($cachedQuotes.length) { // [quote]