DN-3497 Implement react-pdf-highlighter-extended and create POC#43
Open
danielleklaasen wants to merge 3 commits intomainfrom
Open
DN-3497 Implement react-pdf-highlighter-extended and create POC#43danielleklaasen wants to merge 3 commits intomainfrom
danielleklaasen wants to merge 3 commits intomainfrom
Conversation
f26fd5c to
07527e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses: UvA-FNWI/workflow-api#96
PDF Review & Annotation — POC
What is this?
This POC adds inline PDF reviewing and annotation directly inside the workflow UI. Reviewers can open a submitted PDF, highlight text or areas, leave comments, and have those annotations persisted to the backend.
How does it work?
User flow
Altand dragging a rectangle → same comment tooltip.Components added
src/components/instance/PdfReviewModal.tsxreact-pdf-highlighterviewersrc/store/api/annotationsApi.tsGETandPOSTannotationssrc/store/api/types/annotations.tsAPI contract
Annotations are stored and retrieved via two REST endpoints:
Each annotation payload:
{ "id": "...", "highlightedText": "The selected text", "comment": "Reviewer comment", "position": { "boundingRect": { "x1": 0, "y1": 0, "x2": 100, "y2": 20, "width": 595, "height": 842 }, "rects": [...], "pageNumber": 2 } }The position format is defined by
react-pdf-highlighter-extendedand stored in this format (no transformation is done on the backend).Key dependency
react-pdf-highlighter-extended— a React library built on top ofpdf.jsthat handles PDF rendering, text layer extraction, coordinate mapping, and highlight rendering out of the box.Limitations of the current POC
createAnnotationrather than a dedicated update endpoint; this creates duplicates.style={{height: "70vh"}}instead of Tailwind.Next steps
1. Backend completeness
DELETE /Annotations/.../{annotationId}PUT /Annotations/.../{annotationId}2. Replace area highlight re-creation with a proper update
The
AreaHighlight.onChangecallback currently callscreateAnnotation. Wire it to aupdateAnnotationmutation instead, and pass the annotationidto avoid duplicates.3. Add a highlights sidebar
react-pdf-highlighteris designed to work alongside a sidebar that lists all highlights. Clicking a highlight in the list should callscrollViewerTo(already wired up viauseRef) to scroll the PDF to that position. This makes reviewing manageable for long documents.4. Internationalise
Add translation keys for
"Review","Loading PDF…", and any future annotation UI strings, then runpnpm translations:generate.5. Polish the modal UI
style={{height: "70vh"}}with a Tailwind class (e.g.h-[70vh]).PdfLoaderfails (e.g. expired URL, network error).6. Permissions
Decide who may annotate (e.g. only reviewers, not submitters). Gate the "Review" button and the API calls behind the appropriate role check, consistent with how the rest of the app handles impersonation and roles.
7. Performance
Large PDFs can be slow. Consider:
pdf.jsinternally, but verify).Summary
The POC proves that end-to-end PDF annotation — render, select, highlight, persist, reload — is achievable with a small amount of code. The core technical risk is resolved. The remaining work is primarily UX polish, backend completion, and productionising the edge cases listed above.