fix(client/search): search broken due to highlighting

This commit is contained in:
Elian Doran 2025-05-25 23:00:53 +03:00
parent cb8a08d590
commit b4df8f75b9
No known key found for this signature in database

View File

@ -215,8 +215,6 @@ class ListOrGridView extends ViewMode {
const highlightedTokens = this.parentNote.highlightedTokens || [];
if (highlightedTokens.length > 0) {
await import("mark.js");
const regex = highlightedTokens.map((token) => utils.escapeRegExp(token)).join("|");
this.highlightRegex = new RegExp(regex, "gi");
@ -320,11 +318,10 @@ class ListOrGridView extends ViewMode {
$expander.on("click", () => this.toggleContent($card, note, !$card.hasClass("expanded")));
if (this.highlightRegex) {
$card.find(".note-book-title").markRegExp(this.highlightRegex, {
const Mark = new (await import("mark.js")).default($card.find(".note-book-title")[0]);
Mark.markRegExp(this.highlightRegex, {
element: "span",
className: "ck-find-result",
separateWordSearch: false,
caseSensitive: false
className: "ck-find-result"
});
}
@ -362,11 +359,10 @@ class ListOrGridView extends ViewMode {
});
if (this.highlightRegex) {
$renderedContent.markRegExp(this.highlightRegex, {
const Mark = new (await import("mark.js")).default($renderedContent[0]);
Mark.markRegExp(this.highlightRegex, {
element: "span",
className: "ck-find-result",
separateWordSearch: false,
caseSensitive: false
className: "ck-find-result"
});
}