| @embedpdf/plugin-annotation | major |
|---|
The annotation plugin now supports multiple documents with per-document annotation state and tool management.
-
All Actions: All annotation actions now require a
documentIdparameter:setAnnotations(documentId, annotations)- wassetAnnotations(annotations)selectAnnotation(documentId, pageIndex, id)- wasselectAnnotation(pageIndex, id)deselectAnnotation(documentId)- wasdeselectAnnotation()(no params)setActiveToolId(documentId, toolId)- wassetActiveToolId(toolId)createAnnotation(documentId, pageIndex, annotation)- wascreateAnnotation(pageIndex, annotation)patchAnnotation(documentId, pageIndex, id, patch)- waspatchAnnotation(pageIndex, id, patch)deleteAnnotation(documentId, pageIndex, id)- wasdeleteAnnotation(pageIndex, id)commitPendingChanges(documentId)- wascommitPendingChanges()(no params)purgeAnnotation(documentId, uid)- waspurgeAnnotation(uid)
-
State Structure: Plugin state now uses
documents: Record<string, AnnotationDocumentState>instead of a flat structure. Each document has its own annotations, selected annotation, and active tool. -
Capability Methods: All capability methods that previously operated on a single document now require document scoping or operate on the active document by default.
-
AnnotationContainer Component:
- Now requires
documentIdprop (React/Preact:@embedpdf/plugin-annotation/react, Svelte:@embedpdf/plugin-annotation/svelte, Vue:@embedpdf/plugin-annotation/vue) - Component now uses
forDocument(documentId)to get document-scoped annotation capability selectionMenuprop type changed toAnnotationSelectionMenuRenderFnfor better type safety- Bounding box constraints now use unscaled page dimensions (scale is applied internally)
- Now requires
-
Annotation Hooks:
- All hooks now work with document-scoped capabilities via
forDocument() - Components automatically scope operations to the provided
documentId
- All hooks now work with document-scoped capabilities via
- Per-document annotation storage and management
- Per-document active tool tracking
- Document lifecycle hooks for automatic state initialization and cleanup
forDocument()method for document-scoped operations