feat(web): highlight extent adjustment — draggable handles with word/punctuation snap

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).
This commit is contained in:
John O'Keefe committed 2026-10-05 16:50:27 -04:00
1 parent f45adc6362
commit c8e85817aa
4 files changed
+298 -1

No files matched your search

+23
View File
@@ -945,6 +945,29 @@
.reader-popover-btn.danger:hover {
background-color: rgba(153, 27, 27, 0.6);
}
/* Highlight extent-adjustment handles (objective 9): teardrop dots that
sit on the range boundary; the stem points at the text line. */
.adjust-handle {
position: fixed;
width: 26px;
height: 26px;
border-radius: 50% 50% 50% 0;
transform: rotate(-45deg);
background: #3b82f6;
border: 2px solid #ffffff;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
pointer-events: auto;
cursor: grab;
touch-action: none;
}
.adjust-handle[data-which="end"] {
border-radius: 50% 50% 0 50%;
transform: rotate(135deg);
}
.adjust-handle[data-dragging] {
cursor: grabbing;
scale: 1.15;
}
.reader-note-input {
width: 100%;
resize: vertical;