Skip to content

Commit

Permalink
Errbit | highlight text fix if mark lib is not loaded yet
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jan 25, 2024
1 parent 959c3f6 commit 37ca8aa
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,18 @@ const getHighlightedTexts = items => {


export const highlightTexts = (items, texts, unmark=false) => {
const markInstance = new Mark(document.querySelectorAll('.searchable'))
const _texts = texts || getHighlightedTexts(items)
const options = {
element: "span",
className: "highlight-search-results",
separateWordSearch: false
try {
const markInstance = new Mark(document.querySelectorAll('.searchable'))
const _texts = texts || getHighlightedTexts(items)
const options = {
element: "span",
className: "highlight-search-results",
separateWordSearch: false
}
if(unmark)
markInstance.unmark(options)
markInstance.mark(_texts, options);
} catch {
//pass
}
if(unmark)
markInstance.unmark(options)
markInstance.mark(_texts, options);
}

0 comments on commit 37ca8aa

Please sign in to comment.