Support for mentions of user groups containing more than one space
authorAlexander Ebert <ebert@woltlab.com>
Mon, 25 May 2020 19:24:09 +0000 (21:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 25 May 2020 19:24:09 +0000 (21:24 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js

index 65ec70a03fe6489c2e185603bd84de186fc27822..2532473ef992ef9c15530ccbdf7f4493a4f4fb6e 100644 (file)
@@ -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();