From 9bc62586f853f3a634ad7aac995c6968b21c4e75 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 25 May 2020 21:24:09 +0200 Subject: [PATCH] Support for mentions of user groups containing more than one space --- .../files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js index 65ec70a03f..2532473ef9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js @@ -67,7 +67,6 @@ define(['Ajax', 'Environment', 'StringUtil', 'Ui/CloseOverlay'], function(Ajax, default: this._hideDropdown(); return; - break; } event.preventDefault(); @@ -190,7 +189,14 @@ define(['Ajax', 'Environment', 'StringUtil', 'Ui/CloseOverlay'], function(Ajax, range.deleteContents(); range.collapse(true); - var text = document.createTextNode('@' + elData(item, 'username') + '\u00A0'); + // Mentions only allow for one whitespace per match, putting the username in apostrophes + // will allow an arbitrary number of spaces. + var username = elData(item, 'username').trim(); + if (username.split(/\s/g).length > 2) { + username = "'" + username.replace(/'/g, "''") + "'"; + } + + var text = document.createTextNode('@' + username + '\u00A0'); range.insertNode(text); range = document.createRange(); -- 2.20.1