Add support to characters in smartAnnotation [SCI-8656] (#5617)

Co-authored-by: Sboursen <dev.sboursen@gmail.com>
This commit is contained in:
Soufiane 2023-06-22 15:40:39 +02:00 committed by GitHub
parent b4d4043271
commit c71d8df470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,10 +26,12 @@ var SmartAnnotation = (function() {
var $html = $(html);
var $liText = $html.find('.item-text, .sa-type');
if ($liText.length === 0 || !query) return html;
const highlightRegex = new RegExp(query.replace(/[()]/g, '\\$&')
.split(' ')
.join('|'), 'gi');
$.each($liText, function(i, item) {
$(item).html($(item).text().replace(new RegExp(query.split(' ').join('|'), 'gi'),
'<span class="atwho-highlight">$&</span>'));
$.each($liText, function(_i, item) {
$(item).html($(item).text().replace(highlightRegex, '<span class="atwho-highlight">$&</span>'));
});
return $html;
@ -111,10 +113,12 @@ var SmartAnnotation = (function() {
}
a = decodeURI('%C3%80');
y = decodeURI('%C3%BF');
regexp = new RegExp(`${cleanedFlag}$|${cleanedFlag}(\\S[A-Za-z${a}-${y}0-9_/:\\s+-]*)$|${cleanedFlag}(\\S[^\\x00-\\xff]*)$`, 'gi');
regexp = new RegExp(`${cleanedFlag}$|` +
`${cleanedFlag}(\\S[A-Za-z${a}-${y}0-9_/:\\s\\)\\(.+-]*)$|` +
`${cleanedFlag}(\\S[^\\x00-\\xff]*)$`, 'gi');
match = regexp.exec(subtext);
if (match) {
return match[1] || '';
return (match[1] || '').trim();
}
return null;
}