readest/packages
Huang Xin a389b68b35
feat(annotator): draw a global annotation's copies as a dashed underline (#7309)
* feat(annotator): draw a global annotation's copies as a dashed underline (owner: "showing dashed underline without note icon")

Every other occurrence of a global annotation's text used to get the
annotation's own highlight plus a note icon. Each copy now draws one
fine dashed underline in the theme's text color at 50% (solid on
black-and-white e-ink) and no note icon. Clicking a copy opens the note
when the annotation has one, and the highlight toolbar otherwise. The
original keeps its highlight and note icon.

- The underline strokes var(--color-base-content) set as a style, so it
  follows a light/dark switch: overlays aren't redrawn on a theme change,
  and a resolved color drawn in dark mode stayed light gray on a light
  page.
- Global annotations are now also bucketed under their own section.
  They were kept out of it, so the original's note icon was never drawn
  after the book reopened; the copies' icons used to hide that.
- Click resolution moved into resolveAnnotationClick so it can be tested.

Verified:
- With the source reverted to origin/main, 9 of the new tests fail: 6 on
  assertions (6 overlays instead of 3 for a global note, 'highlight'
  instead of 'global' for a copy, no theme-variable stroke, a global note
  missing from its section's notes) and 3 because resolveAnnotationClick
  did not exist. All pass with the change.
- pnpm format:check, pnpm lint and pnpm test (1253 files) pass.
- In Chrome on pnpm dev-web, with a global "Alice" plus a note in
  Alice's Adventures in Wonderland: copies across chapters draw dashed
  with no icon; clicking one opens the note; after a reload the original
  keeps its highlight and icon; a live dark/light switch recolors the
  dashes; on e-ink all 53 copies on the open pages draw solid.
- Not checked: vertical writing mode, mobile devices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(annotator): keep toolbar actions on a global copy bound to its highlight

Answers CodeRabbit on #7309. Clicking a copy of a global highlight with no
note opens the toolbar with the highlight's cfi but the copy's range.
handleHighlight recomputed the CFI from that range, so Delete Highlight
(and a restyle) missed the highlight and added a new one at the copy. An
annotated single-range selection now keeps its cfi, as popup selections
already did; the range editor keeps that cfi in step when it resizes a
highlight. A copy also no longer opens the range handles: dragging them
moved the highlight itself to the copy's text.

Black-and-white e-ink draws the copies dashed at full opacity, not solid
as the first commit said: a solid line would look like an Underline
highlight. The comment and test say so.

Verified:
- Two new tests in AnnotatorShowImportedAnnotation.test.tsx fail without
  the fix: Delete Highlight on a copy left
  `expected [ { …(2) }, { …(2) } ] to deeply equal [ { …(2) } ]` (the
  highlight kept plus a new record at the copy), and the copy rendered
  the range editor. Both pass with it.
- pnpm lint and pnpm test (1253 files) pass.
- In Chrome on pnpm dev-web: a global "Rabbit" with no note, clicked on a
  copy, opens the toolbar with no handles; Delete Highlight removes the
  highlight and all its copies, and a reload shows nothing left behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(annotator): draw global copies with foliate's Overlayer.dashedUnderline (owner: "should we draw the dashed line in foliate overlayer?")

drawDashedUnderline copied Overlayer.underline's placement (the edge,
the padding, the vertical writing-mode branch) into annotatorUtil. The
dashed line now lives in foliate-js as Overlayer.dashedUnderline
(readest/foliate-js#146), next to underline and squiggly. Readest still
chooses the look: var(--color-base-content) as the color, 50% opacity,
full opacity on black-and-white e-ink.

The submodule points at the PR branch's commit 31d584c. It has to be
re-pointed at the merged commit once readest/foliate-js#146 is merged.

Verified:
- overlayer-dashed-underline.test.ts fails before the method exists
  (`Overlayer.dashedUnderline is not a function`) and passes with it. It
  checks the stroke, opacity, width and dash attributes, and that each
  line runs along the centre of underline's rect, horizontally and in
  vertical-rl.
- The existing drawAnnotationOverlay tests pass unchanged against the
  foliate method. pnpm lint and pnpm test (1254 files) pass.
- In Chrome on pnpm dev-web from this branch: 29 copies on the open
  pages draw with stroke var(--color-base-content) (rgb(23, 23, 23) in
  the light theme), opacity 0.5, width 1, dashes 2 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(foliate-js): point at the merged dashedUnderline (#146)

readest/foliate-js#146 merged as 2e4dbc1, with the same content as the
branch commit 31d584c this PR pointed at before (empty diff between them).

Verified: overlayer-dashed-underline.test.ts and annotatorUtil.test.ts
pass against 2e4dbc1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(annotator): open the note editor when annotating a global copy

Answers CodeRabbit's outside-diff finding on #7309. After dbee344de,
Annotate on a copy of a global highlight with no note found the highlight
in handleHighlight (it keeps the selection's cfi) but looked the target up
again by the copy's range, found nothing and returned: no editor opened.
Both now use keepsSelectionCfi, so the editor opens on the highlight.

Verified: a new test in AnnotatorShowImportedAnnotation.test.tsx fails
without this (`expected null not to be null`: no note editor) and passes
with it, with no record added. pnpm lint and pnpm test (1254 files) pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 08:13:11 +01:00
..
foliate-js@2e4dbc10c1 feat(annotator): draw a global annotation's copies as a dashed underline (#7309) 2026-11-04 08:13:11 +01:00
js-mdict@d01bf62af8 feat(dict): faster MDict/StarDict import + lazy lookup; raw .dict; UX (#4334) 2026-05-28 07:48:16 +02:00
qcms@fc23a407f1 chore(fdroid): get rid of wasm binaries in fdroid build (#3677) 2026-03-29 18:31:46 +02:00
simplecc-wasm@5e5b56f5b8 chore(fdroid): get rid of wasm binaries in fdroid build (#3677) 2026-03-29 18:31:46 +02:00
swift-rs feat(reader): Page Flip page-turn style on Android, iOS and desktop (#7160) 2026-10-30 12:57:43 +01:00
tauri@382ea858bd fix(android): stop the app freezing at launch on a page load deadlock (#6240) 2026-09-17 17:43:36 +08:00
tauri-runtime-cef-stub chore(linux): catch up the CEF runtime with upstream feat/cef, closes #6397 (#6487) 2026-09-30 04:07:58 +08:00