forked from akai/readest
feat(annotator): support global highlights that fan out across all matching positions (#4257)
Introduces a 'global' annotation flag so a highlight/note created on one occurrence of a phrase is automatically applied to every matching occurrence in the book (and stays applied across reloads). Renders these expansions as transient overlays without creating duplicate persisted notes. This flag will not show when the book is fixed layout like PDF or CBZ. - types: add 'global?: boolean' to BookNote and DBBookNote; transform layer round-trips the field, with regression coverage ensuring older clients do not clobber it on write-back. - db: new migration 013_add_book_notes_global.sql adds nullable 'global' column to public.book_notes; init schema.sql updated to match. - annotator: new utils/globalAnnotations.ts handles cfi expansion / text-match search across the spine and overlay synthesis. Annotator.tsx fans out global notes on load and on overlay creation; AnnotationPopup and HighlightOptions expose a toggle to mark a highlight as global. - sync path is transparent: a global note created on another device is fanned out locally on next render with no extra UI required.
This commit is contained in:
@@ -67,6 +67,7 @@ CREATE TABLE public.book_notes (
|
||||
color text NULL,
|
||||
note text NULL,
|
||||
page integer NULL,
|
||||
global boolean NULL,
|
||||
created_at timestamp with time zone NULL DEFAULT now(),
|
||||
updated_at timestamp with time zone NULL DEFAULT now(),
|
||||
deleted_at timestamp with time zone NULL,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Migration 013: Add `global` flag to book_notes
|
||||
--
|
||||
-- The `global` flag, when true, indicates that an annotation should be
|
||||
-- applied to every occurrence of `text` within the same section (chapter
|
||||
-- / spine item), in addition to the original anchor identified by `cfi`.
|
||||
-- Defaults to NULL/false, preserving prior single-range semantics for all
|
||||
-- existing notes.
|
||||
|
||||
ALTER TABLE public.book_notes
|
||||
ADD COLUMN IF NOT EXISTS global boolean NULL;
|
||||
Reference in New Issue
Block a user