summaryrefslogtreecommitdiffstats
path: root/apps/comments/js
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-10-12 14:26:22 +0200
committerJoas Schilling <coding@schilljs.com>2018-11-07 12:33:44 +0100
commit375589b274ad6da55f1a516c953b807105dfd2a4 (patch)
tree993a8f3924d0455f0b803ff9cc0338e9b19793ce /apps/comments/js
parent10ba0bed8a6a3f43526c36768feea522325d4a80 (diff)
downloadnextcloud-server-375589b274ad6da55f1a516c953b807105dfd2a4.tar.gz
nextcloud-server-375589b274ad6da55f1a516c953b807105dfd2a4.zip
Fix the comments UI and activities for space-mentions
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/comments/js')
-rw-r--r--apps/comments/js/commentstabview.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index 8ea4dbc2ff2..04b0f292299 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -416,15 +416,22 @@
return;
}
var mention = '@' + mentions[i].mentionId;
+ if (mentions[i].mentionId.indexOf(' ') !== -1) {
+ mention = _.escape('@"' + mentions[i].mentionId + '"');
+ }
// escape possible regex characters in the name
mention = mention.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ var regex = new RegExp("(^|\\s)(" + mention + ")\\b", 'g');
+ if (mentions[i].mentionId.indexOf(' ') !== -1) {
+ regex = new RegExp("(^|\\s)(" + mention + ")", 'g');
+ }
var displayName = this._composeHTMLMention(mentions[i].mentionId, mentions[i].mentionDisplayName);
// replace every mention either at the start of the input or after a whitespace
// followed by a non-word character.
- message = message.replace(new RegExp("(^|\\s)(" + mention + ")\\b", 'g'),
+ message = message.replace(regex,
function(match, p1) {
// to get number of whitespaces (0 vs 1) right
return p1+displayName;
@@ -602,9 +609,14 @@
var $comment = $el.clone();
$comment.find('.avatar-name-wrapper').each(function () {
- var $this = $(this);
- var $inserted = $this.parent();
- $inserted.html('@' + $this.find('.avatar').data('username'));
+ var $this = $(this),
+ $inserted = $this.parent(),
+ userId = $this.find('.avatar').data('username');
+ if (userId.indexOf(' ') !== -1) {
+ $inserted.html('@"' + userId + '"');
+ } else {
+ $inserted.html('@' + userId);
+ }
});
$comment.html(OCP.Comments.richToPlain($comment.html()));