mirror of
https://github.com/plankanban/planka.git
synced 2025-12-24 09:15:01 +03:00
fix: Improve mentions behavior
This commit is contained in:
@@ -4,19 +4,17 @@
|
||||
*/
|
||||
|
||||
const MENTION_ID_REGEX = /@\[.*?\]\((.*?)\)/g;
|
||||
const MENTION_NAME_REGEX = /@\[(.*?)\]\(.*?\)/g;
|
||||
const MENTION_USERNAME_REGEX = /@\[(.*?)\]\(.*?\)/g;
|
||||
|
||||
const extractMentionIds = (text) => {
|
||||
const matches = [...text.matchAll(MENTION_ID_REGEX)];
|
||||
return matches.map((match) => match[1]);
|
||||
};
|
||||
|
||||
const formatTextWithMentions = (text) => text.replace(MENTION_NAME_REGEX, '@$1');
|
||||
const mentionMarkupToText = (markup) =>
|
||||
markup.replace(MENTION_USERNAME_REGEX, (_, username) => `@${username}`);
|
||||
|
||||
module.exports = {
|
||||
MENTION_ID_REGEX,
|
||||
MENTION_NAME_REGEX,
|
||||
|
||||
extractMentionIds,
|
||||
formatTextWithMentions,
|
||||
mentionMarkupToText,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user