As a user I want to highlight rectangular sections of a PDF so we can mark passages for discussion #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
Family documents often contain handwriting, abbreviations, or damaged text that is hard to read alone. Highlighting a specific region of the PDF lets family members mark passages for discussion. All highlights are stored as structured data and overlaid on the PDF viewer at render time — the original file is never modified.
Depends on #39 (PDF.js viewer) — the annotation overlay requires the per-page container structure defined there.
Comments on annotations are handled separately in #41.
Desired behaviour
Creating an annotation:
No overlapping annotations. A new annotation that partially or fully overlaps an existing one on the same page is not allowed. Enforced both client-side (real-time visual feedback while drawing) and server-side (SQL overlap check as a race-condition backstop).
Viewing annotations:
Resolve / unresolve:
Mobile / touch: Drag-to-create annotations on touch devices is deferred to a follow-up issue. Viewing annotations must work on mobile from day one; only annotation creation is desktop-only in this iteration.
Permission model
A new
ANNOTATE_ALLpermission is added to thePermissionenum, sitting betweenREAD_ALLandWRITE_ALL:READ_ALL— can view documents and annotationsANNOTATE_ALL— can view + create annotations (but not edit document metadata or files)WRITE_ALL— can do everything, including annotateAdmin groups should have
WRITE_ALL. A "reader with discussion rights" group would haveREAD_ALL + ANNOTATE_ALL.Data model
Coordinates are fractions of page width/height so overlays render correctly at any zoom level.
author_nameis denormalised at write time.Server-side overlap check on
POST .../annotations:If any row is returned, respond
409 Conflict.REST endpoints
GET/api/documents/{id}/annotationsPOST/api/documents/{id}/annotationsDELETE/api/documents/{id}/annotations/{annId}PATCH/api/documents/{id}/annotations/{annId}/resolveFrontend
<div>elements positioned absolutely inside the per-page.pdf-pagecontainers from #39, using fractional coordinates × current rendered page dimensionsmousedown/mousemove/mouseupon a transparent overlay div in annotation mode; overlap checked against loaded annotations in real timeTesting
AnnotationServiceTest— only the author or admin can delete; non-owner gets 403; overlapping annotation returns 409@WebMvcTest— create returns 201; overlap returns 409; user withoutANNOTATE_ALLgets 403User journey
User opens a document with a PDF. They click "Annotate" — cursor changes. They drag a rectangle over an unclear passage. A colour picker popup appears; they pick yellow and click Save. A yellow highlight appears. Later, if they try to draw over an existing highlight, the selection turns red and Save is disabled.
Dependencies
As a user I want to highlight sections of a PDF and discuss them with others so we can transcribe and interpret documents togetherto As a user I want to highlight rectangular sections of a PDF so we can mark passages for discussion