Closed eyeseast closed 1 month ago
State management is going to be tricky here. We need to render text, then potentially add highlights if there's a query. If the query changes, we need to update it. Maybe that means we just re-render text.
We probably need to handle search highlighting separately in TextPage.svelte
and PDFPage.svelte
, since those handle page text in different ways.
Done (very basic) in #559
Before we can show search highlights (#501) we need to actually search.
The current site hits the single document search endpoint (https://www.documentcloud.org/help/search/#api) and then uses transformHighlights to prepare strings for rendering.
I wonder if we can do this all in the browser. Solr isn't doing much for us on a single document.
The built-in PDF.js viewer has a search utility. As far as I can tell, it's just doing a regex match, but that might actually be enough. My baseline here is
cmd-F
. If I do a plain in-browser text search, I'll see words highlighted. Whatever we build should be at least as good as that, and that's pretty good.