Mention Tooltip: Support unicode names (#1377)

This commit is contained in:
Alexander Zinchuk 2021-08-12 15:36:27 +03:00
parent b1f91c921b
commit 26ed61ac52
2 changed files with 16 additions and 2 deletions

View File

@ -15,7 +15,14 @@ const runThrottled = throttle((cb) => cb(), 500, true);
const RE_BR = /(<br>|<br\s?\/>)/g;
const RE_SPACE = /&nbsp;/g;
const RE_CLEAN_HTML = /(<div>|<\/div>)/gi;
const RE_USERNAME_SEARCH = new RegExp('(^|\\s)@[\\w\\d_-]*$', 'gi');
let RE_USERNAME_SEARCH: RegExp;
try {
RE_USERNAME_SEARCH = new RegExp('(^|\\s)@[-_\\p{L}\\p{M}\\p{N}]*$', 'gui');
} catch (e) {
// Support for older versions of firefox
RE_USERNAME_SEARCH = new RegExp('(^|\\s)@[-_\\d\\wа-яё]*$', 'gi');
}
export default function useMentionTooltip(
canSuggestMembers: boolean | undefined,

View File

@ -1,4 +1,11 @@
const RE_NOT_LETTER = /[^\wа-яё]+/;
let RE_NOT_LETTER: RegExp;
try {
RE_NOT_LETTER = new RegExp('[^\\p{L}\\p{M}]+', 'ui');
} catch (e) {
// Support for older versions of firefox
RE_NOT_LETTER = new RegExp('[^\\wа-яё]+', 'i');
}
export default function searchWords(haystack: string, needle: string) {
if (!haystack || !needle) {