feat: Tag agents in a private note (#1688)

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S 2021-01-27 00:04:11 +05:30 committed by GitHub
parent b894b13e14
commit b93388b330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 424 additions and 93 deletions

View file

@ -10,9 +10,11 @@ const TWITTER_HASH_REGEX = /(^|\s)#(\w+)/g;
const TWITTER_HASH_REPLACEMENT =
'$1<a href="https://twitter.com/hashtag/$2" target="_blank" rel="noreferrer nofollow noopener">#$2</a>';
const USER_MENTIONS_REGEX = /mention:\/\/(user|team)\/(\d+)\/([\w\s]+)/gm;
class MessageFormatter {
constructor(message, isATweet = false) {
this.message = DOMPurify.sanitize(escapeHtml(message) || '');
this.message = DOMPurify.sanitize(escapeHtml(message || ''));
this.isATweet = isATweet;
this.marked = marked;
@ -21,6 +23,10 @@ class MessageFormatter {
return `<strong>${text}</strong>`;
},
link(url, title, text) {
const mentionRegex = new RegExp(USER_MENTIONS_REGEX);
if (url.match(mentionRegex)) {
return `<span class="prosemirror-mention-node">${text}</span>`;
}
return `<a rel="noreferrer noopener nofollow" href="${url}" class="link" title="${title ||
''}" target="_blank">${text}</a>`;
},