mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix matching of "b" in the note autcomplete highlighter
This commit is contained in:
parent
b3aa0ba47c
commit
61e1427b83
@ -38,7 +38,8 @@ async function load() {
|
||||
function highlightResults(results, allTokens) {
|
||||
// we remove < signs because they can cause trouble in matching and overwriting existing highlighted chunks
|
||||
// which would make the resulting HTML string invalid.
|
||||
allTokens = allTokens.map(token => token.replace('/</g', ''));
|
||||
// { and } are used for marking <b> and </b> tag (to avoid matches on single 'b' character)
|
||||
allTokens = allTokens.map(token => token.replace('/[<\{\}]/g', ''));
|
||||
|
||||
// sort by the longest so we first highlight longest matches
|
||||
allTokens.sort((a, b) => a.length > b.length ? -1 : 1);
|
||||
@ -51,9 +52,15 @@ function highlightResults(results, allTokens) {
|
||||
const tokenRegex = new RegExp("(" + utils.escapeRegExp(token) + ")", "gi");
|
||||
|
||||
for (const result of results) {
|
||||
result.highlighted = result.highlighted.replace(tokenRegex, "<b>$1</b>");
|
||||
result.highlighted = result.highlighted.replace(tokenRegex, "{$1}");
|
||||
}
|
||||
}
|
||||
|
||||
for (const result of results) {
|
||||
result.highlighted = result.highlighted
|
||||
.replace(/{/g, "<b>")
|
||||
.replace(/}/g, "</b>");
|
||||
}
|
||||
}
|
||||
|
||||
function findNotes(query) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user