Highlight hashtags containing search text (#3568)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
006fc6c253
Коммит
7c34ea9b8c
@@ -263,7 +263,8 @@ function autolinkHashtags(text, tokens) {
|
|||||||
|
|
||||||
newTokens.set(newAlias, {
|
newTokens.set(newAlias, {
|
||||||
value: `<a class='mention-link' href='#' data-hashtag='${token.originalText}'>${token.originalText}</a>`,
|
value: `<a class='mention-link' href='#' data-hashtag='${token.originalText}'>${token.originalText}</a>`,
|
||||||
originalText: token.originalText
|
originalText: token.originalText,
|
||||||
|
hashtag: token.originalText.substring(1)
|
||||||
});
|
});
|
||||||
|
|
||||||
output = output.replace(alias, newAlias);
|
output = output.replace(alias, newAlias);
|
||||||
@@ -276,19 +277,19 @@ function autolinkHashtags(text, tokens) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// look for hashtags in the text
|
// look for hashtags in the text
|
||||||
function replaceHashtagWithToken(fullMatch, prefix, hashtag) {
|
function replaceHashtagWithToken(fullMatch, prefix, originalText) {
|
||||||
const index = tokens.size;
|
const index = tokens.size;
|
||||||
const alias = `MM_HASHTAG${index}`;
|
const alias = `MM_HASHTAG${index}`;
|
||||||
|
|
||||||
let value = hashtag;
|
if (text.length < Constants.MIN_HASHTAG_LINK_LENGTH + 1) {
|
||||||
|
// too short to be a hashtag
|
||||||
if (hashtag.length > Constants.MIN_HASHTAG_LINK_LENGTH) {
|
return fullMatch;
|
||||||
value = `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens.set(alias, {
|
tokens.set(alias, {
|
||||||
value,
|
value: `<a class='mention-link' href='#' data-hashtag='${originalText}'>${originalText}</a>`,
|
||||||
originalText: hashtag
|
originalText,
|
||||||
|
hashtag: originalText.substring(1)
|
||||||
});
|
});
|
||||||
|
|
||||||
return prefix + alias;
|
return prefix + alias;
|
||||||
@@ -393,9 +394,11 @@ export function highlightSearchTerms(text, tokens, searchTerm) {
|
|||||||
|
|
||||||
for (const term of terms) {
|
for (const term of terms) {
|
||||||
// highlight existing tokens matching search terms
|
// highlight existing tokens matching search terms
|
||||||
|
const trimmedTerm = term.replace(/\*$/, '').toLowerCase();
|
||||||
var newTokens = new Map();
|
var newTokens = new Map();
|
||||||
for (const [alias, token] of tokens) {
|
for (const [alias, token] of tokens) {
|
||||||
if (token.originalText.toLowerCase() === term.replace(/\*$/, '').toLowerCase()) {
|
if (token.originalText.toLowerCase() === trimmedTerm ||
|
||||||
|
(token.hashtag && token.hashtag.toLowerCase() === trimmedTerm)) {
|
||||||
const index = tokens.size + newTokens.size;
|
const index = tokens.size + newTokens.size;
|
||||||
const newAlias = `MM_SEARCHTERM${index}`;
|
const newAlias = `MM_SEARCHTERM${index}`;
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user