From c8e85817aad94aec62361e717bc8b9eb6017bd15 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 5 Oct 2026 16:50:27 -0400 Subject: [PATCH] =?UTF-8?q?feat(web):=20highlight=20extent=20adjustment=20?= =?UTF-8?q?=E2=80=94=20draggable=20handles=20with=20word/punctuation=20sna?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Objective 9 (web half). The selection popover's edit mode gains an Adjust button: the overlay's show-annotation event stashes the live DOM range, start/end teardrop handles render over it (host layer above the iframe), and pointer drags map into the iframe's caretRangeFromPoint. Snapping: land next to punctuation → the boundary sits exactly there; land inside a word → the word's edge in the drag direction; whitespace trims toward the adjacent word. A live preview repaints through the overlayer under a scratch key; relocation (page turn) cancels safely. Release recomputes the range CFI + collapsed-end CFI (view.getCFI) and saves through the popover's own saveHighlightChanges path (PUT + remove-old/add-new overlay dance), keeping selection_text and the anchors in lockstep. Verified live E2E in Brave: extent extended by one word with the comma/space snap behavior, saved to the server row, handles cleaned; all snap paths unit-exercised in-page (word end/start, punctuation exact on both sides, whitespace trim); the test highlight was restored to its original extent through the same adjust flow (punctuation-precision drag back to the comma). --- templates/reader.templ | 10 ++ web/src/reader/reader.ts | 264 +++++++++++++++++++++++++++++++++++++++ web/static/input.css | 23 ++++ web/static/style.css | 2 +- 4 files changed, 298 insertions(+), 1 deletion(-) diff --git a/templates/reader.templ b/templates/reader.templ index d9dc261b..4c41c254 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -161,6 +161,16 @@ templ Reader(user User, metadata ReaderMetadata) { > +