From a99e267f288e30581023467150c07fef6fca3cc1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 16 Dec 2014 13:38:47 +0100 Subject: [PATCH] Improved handling of newlines in list items --- .../js/3rdParty/redactor/plugins/wbbcode.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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] -- 2.20.1