mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix highlighting search results with regexp characters in fulltext string, closes #4665
This commit is contained in:
parent
2d19f073d9
commit
a115b14136
@ -4,6 +4,7 @@ import froca from "./froca.js";
|
||||
import attributeRenderer from "./attribute_renderer.js";
|
||||
import libraryLoader from "./library_loader.js";
|
||||
import treeService from "./tree.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-list">
|
||||
@ -215,7 +216,11 @@ class NoteListRenderer {
|
||||
if (highlightedTokens.length > 0) {
|
||||
await libraryLoader.requireLibrary(libraryLoader.MARKJS);
|
||||
|
||||
this.highlightRegex = new RegExp(highlightedTokens.join("|"), 'gi');
|
||||
const regex = highlightedTokens
|
||||
.map(token => utils.escapeRegExp(token))
|
||||
.join("|");
|
||||
|
||||
this.highlightRegex = new RegExp(regex, 'gi');
|
||||
} else {
|
||||
this.highlightRegex = null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user