1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00
planka/server/utils/mentions.js

23 lines
585 B
JavaScript
Raw Normal View History

2025-06-06 12:34:09 +02:00
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const MENTION_ID_REGEX = /@\[.*?\]\((.*?)\)/g;
const MENTION_NAME_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');
module.exports = {
MENTION_ID_REGEX,
MENTION_NAME_REGEX,
extractMentionIds,
formatTextWithMentions,
};