From f15b801a4cd458b6e49a09184c176da70114f1ef Mon Sep 17 00:00:00 2001 From: NeoVand Date: Thu, 27 Aug 2026 02:27:05 -0500 Subject: [PATCH 1/3] feat: select text on an original page, and act on it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page was a picture, so nothing on it could be selected — which left explain and note-taking as reflowed-view-only, since both begin with a selection. There is a layer of invisible words over the paper now, one span per word, positioned in PDF points and scaled with the sheet so a zoom moves it rather than rebuilding it. It is built from the boxes the placement already used rather than from pdf.js's own text layer, which means each word arrives knowing its passage and its position within it — so a selection is read by asking its endpoints what they are, and the reader's existing "play from here", "highlight", "note" and "explain" paths take it exactly as they take a selection made in the reflowed view. Words a passage claimed only as a region — a table row, placed by its cells rather than by the words of its reading — are attributed to it too. Without that the title page of a paper, which is mostly tables, was the one part that could not be selected into anything: 351 of 391 words on it knew their passage, now 389. The selection actions and the explain panel are snippets rendered inside whichever view is showing, so they sit in that view's scroll and travel with it. Co-Authored-By: Claude Opus 5 --- src/lib/components/PdfPageView.svelte | 156 +++++++++++++++- src/lib/domain/pdf-layout.spec.ts | 80 ++++++++ src/lib/domain/pdf-layout.ts | 76 ++++++++ src/routes/read/+page.svelte | 255 ++++++++++++++------------ tests/reader.e2e.ts | 78 ++++++++ 5 files changed, 525 insertions(+), 120 deletions(-) diff --git a/src/lib/components/PdfPageView.svelte b/src/lib/components/PdfPageView.svelte index fa18c82..e652c5b 100644 --- a/src/lib/components/PdfPageView.svelte +++ b/src/lib/components/PdfPageView.svelte @@ -1,8 +1,14 @@