From: Alexander Ebert Date: Tue, 5 Dec 2017 10:53:57 +0000 (+0100) Subject: Improved handling of empty `
` blocks
X-Git-Tag: 3.1.0_Beta_4~21
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=54944b2d07be03a99e94f12d2630abd43b1a8f04;p=GitHub%2FWoltLab%2FWCF.git

Improved handling of empty `
` blocks
---

diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js
index 044a18d734..2830384941 100644
--- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js
+++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js
@@ -42,6 +42,13 @@ $.Redactor.prototype.WoltLabClean = function() {
 					}
 				});
 				
+				// enforce at least a single whitespace inside certain block elements
+				elBySelAll('pre, woltlab-quote, woltlab-spoiler', div, function (element) {
+					if (element.childElementCount === 0 && (element.textContent.length === 0 || element.textContent.match(/^\r?\n$/))) {
+						element.textContent = '\u200B';
+					}
+				});
+				
 				html = div.innerHTML;
 				
 				return html;
diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js
index bfbe6b51dc..0b38ce076f 100644
--- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js
+++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js
@@ -67,6 +67,7 @@ $.Redactor.prototype.WoltLabSource = function() {
 				// use jQuery to parse, its parser is much more graceful
 				var div = $('
').html(this.source.$textarea.val()); stripIcons(div[0]); + this.source.$textarea.val(div[0].innerHTML); mpHide.call(this); @@ -198,6 +199,9 @@ $.Redactor.prototype.WoltLabSource = function() { html = html.replace('@@@WCF_PRE_BACKUP_' + i + '@@@', backup[i]); } + // remove the trailing newline in front of
+			html = html.replace(/\r?\n<\/pre>/g, '
'); + return html.trim(); } };