PLT-7474 Stopped requiring confirmation for mentions in code blocks (#7375)
* PLT-7474 Stopped requiring confirmation for mentions in code blocks * Stopped mentioning people from code blocks using ~~~
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
daed8ffbf6
Коммит
575864c917
@@ -113,5 +113,15 @@ export function containsAtMention(text, key) {
|
||||
}
|
||||
|
||||
// This doesn't work for at mentions containing periods or hyphens
|
||||
return new RegExp(`\\B${key}\\b`, 'i').test(text);
|
||||
return new RegExp(`\\B${key}\\b`, 'i').test(removeCode(text));
|
||||
}
|
||||
|
||||
// Returns a given text string with all Markdown code replaced with whitespace.
|
||||
export function removeCode(text) {
|
||||
// These patterns should match the ones in app/notification.go, except JavaScript doesn't
|
||||
// support \z for the end of the text in multiline mode, so we use $(?![\r\n])
|
||||
const codeBlockPattern = /^[^\S\n]*[`~]{3}.*$[\s\S]+?(^[^\S\n]*[`~]{3}$|$(?![\r\n]))/m;
|
||||
const inlineCodePattern = /`+(?:.+?|.*?\n(.*?\S.*?\n)*.*?)`+/m;
|
||||
|
||||
return text.replace(codeBlockPattern, '').replace(inlineCodePattern, ' ');
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user