mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
cleanup
This commit is contained in:
parent
b23ead8097
commit
bc854ee149
@ -218,6 +218,10 @@ function highlightSearchResults(searchResults, highlightedTokens) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wrapText(text, start, length, prefix, suffix) {
|
||||||
|
return text.substring(0, start) + prefix + text.substr(start, length) + suffix + text.substring(start + length);
|
||||||
|
}
|
||||||
|
|
||||||
for (const token of highlightedTokens) {
|
for (const token of highlightedTokens) {
|
||||||
for (const result of searchResults) {
|
for (const result of searchResults) {
|
||||||
// Reset token
|
// Reset token
|
||||||
@ -226,8 +230,7 @@ function highlightSearchResults(searchResults, highlightedTokens) {
|
|||||||
|
|
||||||
// Find all matches
|
// Find all matches
|
||||||
while ((match = tokenRegex.exec(normalizeString(result.highlightedNotePathTitle))) !== null) {
|
while ((match = tokenRegex.exec(normalizeString(result.highlightedNotePathTitle))) !== null) {
|
||||||
console.log(match)
|
result.highlightedNotePathTitle = wrapText(result.highlightedNotePathTitle, match.index, token.length, "{", "}");
|
||||||
result.highlightedNotePathTitle = utils.wrapText(result.highlightedNotePathTitle, match.index, token.length, "{", "}");
|
|
||||||
|
|
||||||
// 2 characters are added, so we need to adjust the index
|
// 2 characters are added, so we need to adjust the index
|
||||||
tokenRegex.lastIndex += 2;
|
tokenRegex.lastIndex += 2;
|
||||||
|
@ -302,10 +302,6 @@ function filterAttributeName(name) {
|
|||||||
return name.replace(/[^\p{L}\p{N}_:]/ug, "");
|
return name.replace(/[^\p{L}\p{N}_:]/ug, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapText(text, start, length, prefix, suffix) {
|
|
||||||
return text.substring(0, start) + prefix + text.substr(start, length) + suffix + text.substring(start + length);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
randomSecureToken,
|
randomSecureToken,
|
||||||
randomString,
|
randomString,
|
||||||
@ -340,6 +336,5 @@ module.exports = {
|
|||||||
deferred,
|
deferred,
|
||||||
removeDiacritic,
|
removeDiacritic,
|
||||||
normalize,
|
normalize,
|
||||||
filterAttributeName,
|
filterAttributeName
|
||||||
wrapText
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user