PLT-3211 Fixed search highlighting for hashtags starting with "#in", "#from", or "#channel" (#3400)
* Fixed clicking hashtags/@mentions adding a # to the url * Updated punctuation trimming regex for searching to better match the server * Fixed search term splitting to not break up hashtags starting with a search flag (in, from, etc)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
2abc5a4a1a
Коммит
6b22a8e816
@@ -298,8 +298,8 @@ function autolinkHashtags(text, tokens) {
|
|||||||
return output.replace(/(^|\W)(#[a-zA-ZäöüÄÖÜß][a-zA-Z0-9äöüÄÖÜß.\-_]*)\b/g, replaceHashtagWithToken);
|
return output.replace(/(^|\W)(#[a-zA-ZäöüÄÖÜß][a-zA-Z0-9äöüÄÖÜß.\-_]*)\b/g, replaceHashtagWithToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
const puncStart = /^[.,()&$!\[\]{}':;\\]+/;
|
const puncStart = /^[^a-zA-Z0-9#]+/;
|
||||||
const puncEnd = /[.,()&$#!\[\]{}':;\\]+$/;
|
const puncEnd = /[^a-zA-Z0-9]+$/;
|
||||||
|
|
||||||
function parseSearchTerms(searchTerm) {
|
function parseSearchTerms(searchTerm) {
|
||||||
let terms = [];
|
let terms = [];
|
||||||
@@ -334,7 +334,7 @@ function parseSearchTerms(searchTerm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// capture any plain text up until the next quote or search flag
|
// capture any plain text up until the next quote or search flag
|
||||||
captured = (/^.+?(?=\bin|\bfrom|\bchannel|"|$)/).exec(termString);
|
captured = (/^.+?(?=\bin:|\bfrom:|\bchannel:|"|$)/).exec(termString);
|
||||||
if (captured) {
|
if (captured) {
|
||||||
termString = termString.substring(captured[0].length);
|
termString = termString.substring(captured[0].length);
|
||||||
|
|
||||||
@@ -446,8 +446,12 @@ export function handleClick(e) {
|
|||||||
const linkAttribute = e.target.getAttributeNode('data-link');
|
const linkAttribute = e.target.getAttributeNode('data-link');
|
||||||
|
|
||||||
if (mentionAttribute) {
|
if (mentionAttribute) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
Utils.searchForTerm(mentionAttribute.value);
|
Utils.searchForTerm(mentionAttribute.value);
|
||||||
} else if (hashtagAttribute) {
|
} else if (hashtagAttribute) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
Utils.searchForTerm(hashtagAttribute.value);
|
Utils.searchForTerm(hashtagAttribute.value);
|
||||||
} else if (linkAttribute) {
|
} else if (linkAttribute) {
|
||||||
const MIDDLE_MOUSE_BUTTON = 1;
|
const MIDDLE_MOUSE_BUTTON = 1;
|
||||||
@@ -465,4 +469,4 @@ function insertLongLinkWbr(test) {
|
|||||||
return test.replace(/\//g, (match, position, string) => {
|
return test.replace(/\//g, (match, position, string) => {
|
||||||
return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '<wbr />' : '');
|
return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '<wbr />' : '');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user