From 642394ba57f609e653b7bdf7c0ab46d4cd5bf85a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 12 Feb 2015 23:01:02 +0100 Subject: [PATCH] Fixed a few newline issues raised w/ quotes --- .../js/3rdParty/redactor/plugins/wbbcode.js | 4 ++-- .../files/js/3rdParty/redactor/plugins/wutil.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) 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) { -- 2.20.1