feat(search): show search result snippets with match highlighting (#219) #242

Merged
marcel merged 20 commits from feat/issue-219-search-snippets into main 2026-04-16 09:10:11 +02:00
Showing only changes of commit d14dd795a4 - Show all commits

View File

@@ -56,21 +56,20 @@ onMount(async () => {
await renderer.init();
});
// Wire DOM elements to the renderer after they mount
$effect(() => {
if (canvasEl && textLayerEl) {
renderer.setElements(canvasEl, textLayerEl);
}
});
$effect(() => {
if (renderer.pdfjsReady && url) {
renderer.loadDocument(url);
}
});
// Wire DOM elements to the renderer and trigger rendering.
// canvasEl is read synchronously so Svelte tracks it as a dependency:
// when the canvas reappears after the loading spinner (loading → false),
// this effect re-fires and renders the already-loaded PDF.
$effect(() => {
// Read scale and currentPage synchronously so Svelte tracks them as dependencies.
if (!canvasEl || !textLayerEl) return;
renderer.setElements(canvasEl, textLayerEl);
// Also track currentPage and scale so page-nav / zoom re-renders work.
if (renderer.isLoaded && renderer.currentPage && renderer.scale > 0) {
renderer.renderCurrentPage().then(() => renderer.prerender());
}