From: Alexander Ebert Date: Thu, 12 Feb 2015 22:01:02 +0000 (+0100) Subject: Fixed a few newline issues raised w/ quotes X-Git-Tag: 2.1.0_RC_1~25 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=642394ba57f609e653b7bdf7c0ab46d4cd5bf85a;p=GitHub%2FWoltLab%2FWCF.git Fixed a few newline issues raised w/ quotes --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 2ec6061dc4..8aaf664184 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -276,8 +276,8 @@ RedactorPlugins.wbbcode = function() { // remove empty links html = html.replace(/]*?><\/a>/g, ''); - // drop empty paragraphs - html = html.replace(/

<\/p>/g, ''); + // handle empty paragraphs not followed by an empty one + html = html.replace(/

<\/p>

(?!
)/g, '

@@@wcf_empty_line@@@

'); // remove
right in front of

(does not match


since it has been converted already) html = html.replace(/<\/p>/g, '

'); diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 345d591023..038c930411 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -283,6 +283,22 @@ RedactorPlugins.wutil = function() { return $data.text; }, + /** + * Adds newlines after certain elements, this is actually the reverse of + * _removeSuperfluousNewlines() which removes them prior to submitting. + * + * @param string + * @return string + */ + addNewlines: function(text) { + text = text.replace(/(\[\/(?:align|code|quote)\])/g, '$1\n'); + + var $data = { text: text }; + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'wutil_addNewlines', $data); + + return $data.text; + }, + /** * Resets the editor's contents. */ @@ -873,6 +889,7 @@ RedactorPlugins.wutil = function() { $wasInWysiwygMode = true; } + value = this.wutil.addNewlines(value); this.$textarea.val(value); if ($wasInWysiwygMode) {