From 0a545943bab04309760def5beaf5f63a93fe4208 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 6 Sep 2017 15:05:20 +0200 Subject: [PATCH] Convert smilies into their alt-value for manual text quotes Closes #2415 --- wcfsetup/install/files/js/WCF.Message.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 162ed17af3..38d2f93bf6 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -1181,10 +1181,16 @@ if (COMPILER_TARGET_DEFAULT) { var $nodeFilter = function (node) { switch (node.tagName) { case 'BLOCKQUOTE': - case 'IMG': case 'SCRIPT': return NodeFilter.FILTER_REJECT; + case 'IMG': + if (!node.classList.contains('smiley') || node.alt.length === 0) { + return NodeFilter.FILTER_REJECT; + } + // fallthrough + + //noinspection FallthroughInSwitchStatementJS default: return NodeFilter.FILTER_ACCEPT; } @@ -1203,6 +1209,7 @@ if (COMPILER_TARGET_DEFAULT) { var $node = $walker.currentNode; if ($node.nodeType === Node.ELEMENT_NODE) { + console.log($node); switch ($node.tagName) { case 'A': // \u2026 === … @@ -1235,6 +1242,11 @@ if (COMPILER_TARGET_DEFAULT) { case 'P': $text += "\n\n"; break; + + // smilies + case 'IMG': + $text += " " + $node.alt + " "; + break; } } else { -- 2.20.1