Is there a way to allow users to navigate through highlighted search results using 'next / previous' arrows? Something similar to the feature in Google Docs shown below:
https://i.sstatic.net/44LpL.png
I already have the code to highlight all occurrences using a filter and regular expression :
<p v-html="$options.filters.highlightSearchResults(theText, searchTerms)"></p>
And here's the code snippet:
filters: {
highlightSearchResults(theText, searchTerms) {
const re = new RegExp(searchTerms, "gi")
return theText.replace(re, (match) => `<span style="background-color:#ffff00">${match}</span>`
}
However, I'm stuck on how to implement the navigation functionality for cycling through the found instances. Any guidance would be greatly appreciated.