feat: Tag agents in a private note (#1688)
Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
parent
b894b13e14
commit
b93388b330
20 changed files with 424 additions and 93 deletions
|
@ -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>`;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue