@embedpdf/plugin-annotation 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1232 -101
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +33 -3
  6. package/dist/lib/annotation-plugin.d.ts +178 -2
  7. package/dist/lib/handlers/types.d.ts +1 -1
  8. package/dist/lib/helpers.d.ts +8 -2
  9. package/dist/lib/selectors.d.ts +97 -8
  10. package/dist/lib/tools/default-tools.d.ts +39 -11
  11. package/dist/lib/tools/types.d.ts +22 -4
  12. package/dist/lib/types.d.ts +278 -1
  13. package/dist/preact/adapter.d.ts +3 -3
  14. package/dist/preact/index.cjs +1 -1
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.js +1133 -403
  17. package/dist/preact/index.js.map +1 -1
  18. package/dist/react/adapter.d.ts +1 -1
  19. package/dist/react/index.cjs +1 -1
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.js +1132 -402
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/shared/components/annotation-container.d.ts +13 -2
  24. package/dist/shared/components/annotation-layer.d.ts +6 -2
  25. package/dist/shared/components/annotations/ink.d.ts +3 -3
  26. package/dist/shared/components/annotations/link.d.ts +28 -0
  27. package/dist/shared/components/annotations.d.ts +4 -1
  28. package/dist/shared/components/group-selection-box.d.ts +32 -0
  29. package/dist/shared/components/index.d.ts +1 -0
  30. package/dist/shared/components/text-markup/highlight.d.ts +3 -2
  31. package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
  32. package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
  33. package/dist/shared/components/text-markup/underline.d.ts +3 -2
  34. package/dist/shared/components/types.d.ts +50 -1
  35. package/dist/shared/context/index.d.ts +1 -0
  36. package/dist/shared/context/renderer-registry.d.ts +21 -0
  37. package/dist/shared/index.d.ts +2 -0
  38. package/dist/shared-preact/components/annotation-container.d.ts +13 -2
  39. package/dist/shared-preact/components/annotation-layer.d.ts +6 -2
  40. package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
  41. package/dist/shared-preact/components/annotations/link.d.ts +28 -0
  42. package/dist/shared-preact/components/annotations.d.ts +4 -1
  43. package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
  44. package/dist/shared-preact/components/index.d.ts +1 -0
  45. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
  46. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
  47. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
  48. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
  49. package/dist/shared-preact/components/types.d.ts +50 -1
  50. package/dist/shared-preact/context/index.d.ts +1 -0
  51. package/dist/shared-preact/context/renderer-registry.d.ts +21 -0
  52. package/dist/shared-preact/index.d.ts +2 -0
  53. package/dist/shared-react/components/annotation-container.d.ts +13 -2
  54. package/dist/shared-react/components/annotation-layer.d.ts +6 -2
  55. package/dist/shared-react/components/annotations/ink.d.ts +3 -3
  56. package/dist/shared-react/components/annotations/link.d.ts +28 -0
  57. package/dist/shared-react/components/annotations.d.ts +4 -1
  58. package/dist/shared-react/components/group-selection-box.d.ts +32 -0
  59. package/dist/shared-react/components/index.d.ts +1 -0
  60. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
  61. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
  62. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
  63. package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
  64. package/dist/shared-react/components/types.d.ts +50 -1
  65. package/dist/shared-react/context/index.d.ts +1 -0
  66. package/dist/shared-react/context/renderer-registry.d.ts +21 -0
  67. package/dist/shared-react/index.d.ts +2 -0
  68. package/dist/svelte/components/AnnotationLayer.svelte.d.ts +8 -1
  69. package/dist/svelte/components/Annotations.svelte.d.ts +8 -1
  70. package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
  71. package/dist/svelte/components/RendererRegistryProvider.svelte.d.ts +7 -0
  72. package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
  73. package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
  74. package/dist/svelte/components/annotations/index.d.ts +1 -0
  75. package/dist/svelte/components/index.d.ts +2 -0
  76. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
  77. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
  78. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
  79. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
  80. package/dist/svelte/components/types.d.ts +2 -0
  81. package/dist/svelte/context/index.d.ts +2 -0
  82. package/dist/svelte/context/renderer-registry.svelte.d.ts +20 -0
  83. package/dist/svelte/context/types.d.ts +33 -0
  84. package/dist/svelte/index.cjs +1 -1
  85. package/dist/svelte/index.cjs.map +1 -1
  86. package/dist/svelte/index.d.ts +2 -0
  87. package/dist/svelte/index.js +1215 -394
  88. package/dist/svelte/index.js.map +1 -1
  89. package/dist/svelte/types.d.ts +7 -0
  90. package/dist/vue/components/annotation-container.vue.d.ts +3 -1
  91. package/dist/vue/components/annotation-layer.vue.d.ts +31 -5
  92. package/dist/vue/components/annotations/free-text.vue.d.ts +1 -1
  93. package/dist/vue/components/annotations/index.d.ts +1 -0
  94. package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
  95. package/dist/vue/components/annotations/line.vue.d.ts +1 -1
  96. package/dist/vue/components/annotations/link.vue.d.ts +29 -0
  97. package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
  98. package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
  99. package/dist/vue/components/annotations/stamp.vue.d.ts +1 -1
  100. package/dist/vue/components/annotations.vue.d.ts +151 -53
  101. package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
  102. package/dist/vue/components/index.d.ts +2 -0
  103. package/dist/vue/components/preview-renderer.vue.d.ts +1 -1
  104. package/dist/vue/components/renderer-registry-provider.vue.d.ts +13 -0
  105. package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
  106. package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
  107. package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
  108. package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
  109. package/dist/vue/context/index.d.ts +2 -0
  110. package/dist/vue/context/renderer-registry.d.ts +26 -0
  111. package/dist/vue/context/types.d.ts +33 -0
  112. package/dist/vue/hooks/use-annotation.d.ts +7 -5
  113. package/dist/vue/index.cjs +1 -1
  114. package/dist/vue/index.cjs.map +1 -1
  115. package/dist/vue/index.d.ts +3 -1
  116. package/dist/vue/index.js +1124 -459
  117. package/dist/vue/index.js.map +1 -1
  118. package/dist/vue/types.d.ts +8 -1
  119. package/package.json +10 -10
@@ -1,14 +1,42 @@
1
- import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/preact";
2
- import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp } from "@embedpdf/plugin-annotation";
1
+ import { createPluginPackage } from "@embedpdf/core";
2
+ import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp, isLink, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
3
3
  export * from "@embedpdf/plugin-annotation";
4
- import { Fragment as Fragment$1 } from "preact";
5
- import { useState, useEffect, useRef, useMemo, useLayoutEffect, useCallback } from "preact/hooks";
6
- import { jsxs, jsx, Fragment } from "preact/jsx-runtime";
7
- import { PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
4
+ import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
5
+ import { createContext, Fragment as Fragment$1 } from "preact";
6
+ import { useState, useCallback, useContext, useRef, useEffect, useMemo, useLayoutEffect } from "preact/hooks";
7
+ import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/preact";
8
+ import { boundingRectOrEmpty, PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
8
9
  import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
9
10
  import { useSelectionCapability } from "@embedpdf/plugin-selection/preact";
10
11
  import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/preact";
11
12
  const suppressContentEditableWarningProps = {};
13
+ const RegisterContext = createContext(null);
14
+ const RenderersContext = createContext([]);
15
+ function AnnotationRendererProvider({ children }) {
16
+ const [renderers, setRenderers] = useState([]);
17
+ const register = useCallback((entries) => {
18
+ setRenderers((prev) => {
19
+ const ids = new Set(entries.map((e) => e.id));
20
+ return [...prev.filter((r) => !ids.has(r.id)), ...entries];
21
+ });
22
+ return () => setRenderers((prev) => prev.filter((r) => !entries.some((e) => e.id === r.id)));
23
+ }, []);
24
+ return /* @__PURE__ */ jsx(RegisterContext.Provider, { value: register, children: /* @__PURE__ */ jsx(RenderersContext.Provider, { value: renderers, children }) });
25
+ }
26
+ function useRegisterRenderers(renderers) {
27
+ const register = useContext(RegisterContext);
28
+ const renderersRef = useRef(renderers);
29
+ useEffect(() => {
30
+ if (!register) return;
31
+ return register(renderersRef.current);
32
+ }, [register]);
33
+ }
34
+ function useRegisteredRenderers() {
35
+ return useContext(RenderersContext);
36
+ }
37
+ function useRendererRegistry() {
38
+ return useContext(RegisterContext);
39
+ }
12
40
  const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
13
41
  const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
14
42
  const useAnnotation = (documentId) => {
@@ -40,6 +68,7 @@ function AnnotationContainer({
40
68
  trackedAnnotation,
41
69
  children,
42
70
  isSelected,
71
+ isMultiSelected = false,
43
72
  isDraggable,
44
73
  isResizable,
45
74
  lockAspectRatio = false,
@@ -54,14 +83,18 @@ function AnnotationContainer({
54
83
  vertexUI,
55
84
  selectionOutlineColor = "#007ACC",
56
85
  customAnnotationRenderer,
86
+ // Destructure props that shouldn't be passed to DOM elements
87
+ groupSelectionMenu: _groupSelectionMenu,
88
+ annotationRenderers: _annotationRenderers,
57
89
  ...props
58
90
  }) {
59
91
  const [preview, setPreview] = useState(trackedAnnotation.object);
60
92
  const { provides: annotationCapability } = useAnnotationCapability();
93
+ const { plugin } = useAnnotationPlugin();
61
94
  const { canModifyAnnotations } = useDocumentPermissions(documentId);
62
95
  const gestureBaseRef = useRef(null);
63
- const effectiveIsDraggable = canModifyAnnotations && isDraggable;
64
- const effectiveIsResizable = canModifyAnnotations && isResizable;
96
+ const effectiveIsDraggable = canModifyAnnotations && isDraggable && !isMultiSelected;
97
+ const effectiveIsResizable = canModifyAnnotations && isResizable && !isMultiSelected;
65
98
  const annotationProvides = useMemo(
66
99
  () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
67
100
  [annotationCapability, documentId]
@@ -71,6 +104,73 @@ function AnnotationContainer({
71
104
  const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
72
105
  const HANDLE_SIZE = (resizeUI == null ? void 0 : resizeUI.size) ?? 12;
73
106
  const VERTEX_SIZE = (vertexUI == null ? void 0 : vertexUI.size) ?? 12;
107
+ const gestureBaseRectRef = useRef(null);
108
+ const handleUpdate = useCallback(
109
+ (event) => {
110
+ var _a;
111
+ if (!((_a = event.transformData) == null ? void 0 : _a.type) || isMultiSelected || !plugin) return;
112
+ const { type, changes, metadata } = event.transformData;
113
+ const id = trackedAnnotation.object.id;
114
+ const pageSize = { width: pageWidth, height: pageHeight };
115
+ if (event.state === "start") {
116
+ gestureBaseRectRef.current = trackedAnnotation.object.rect;
117
+ gestureBaseRef.current = trackedAnnotation.object;
118
+ if (type === "move") {
119
+ plugin.startDrag(documentId, { annotationIds: [id], pageSize });
120
+ } else if (type === "resize") {
121
+ plugin.startResize(documentId, {
122
+ annotationIds: [id],
123
+ pageSize,
124
+ resizeHandle: (metadata == null ? void 0 : metadata.handle) ?? "se"
125
+ });
126
+ }
127
+ }
128
+ if (changes.rect && gestureBaseRectRef.current) {
129
+ if (type === "move") {
130
+ const delta = {
131
+ x: changes.rect.origin.x - gestureBaseRectRef.current.origin.x,
132
+ y: changes.rect.origin.y - gestureBaseRectRef.current.origin.y
133
+ };
134
+ plugin.updateDrag(documentId, delta);
135
+ } else if (type === "resize") {
136
+ plugin.updateResize(documentId, changes.rect);
137
+ }
138
+ }
139
+ if (type === "vertex-edit" && changes.vertices && vertexConfig) {
140
+ const base = gestureBaseRef.current ?? trackedAnnotation.object;
141
+ const vertexChanges = vertexConfig.transformAnnotation(base, changes.vertices);
142
+ const patched = annotationCapability == null ? void 0 : annotationCapability.transformAnnotation(base, {
143
+ type,
144
+ changes: vertexChanges,
145
+ metadata
146
+ });
147
+ if (patched) {
148
+ setPreview((prev) => ({ ...prev, ...patched }));
149
+ if (event.state === "end") {
150
+ annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, id, patched);
151
+ }
152
+ }
153
+ }
154
+ if (event.state === "end") {
155
+ gestureBaseRectRef.current = null;
156
+ gestureBaseRef.current = null;
157
+ if (type === "move") plugin.commitDrag(documentId);
158
+ else if (type === "resize") plugin.commitResize(documentId);
159
+ }
160
+ },
161
+ [
162
+ plugin,
163
+ documentId,
164
+ trackedAnnotation.object,
165
+ pageWidth,
166
+ pageHeight,
167
+ pageIndex,
168
+ isMultiSelected,
169
+ vertexConfig,
170
+ annotationCapability,
171
+ annotationProvides
172
+ ]
173
+ );
74
174
  const { dragProps, vertices, resize } = useInteractionHandles({
75
175
  controller: {
76
176
  element: currentObject.rect,
@@ -83,32 +183,9 @@ function AnnotationContainer({
83
183
  maintainAspectRatio: lockAspectRatio,
84
184
  pageRotation: rotation,
85
185
  scale,
86
- enabled: isSelected,
87
- onUpdate: (event) => {
88
- var _a;
89
- if (!((_a = event.transformData) == null ? void 0 : _a.type)) return;
90
- if (event.state === "start") {
91
- gestureBaseRef.current = currentObject;
92
- }
93
- const transformType = event.transformData.type;
94
- const base = gestureBaseRef.current ?? currentObject;
95
- const changes = event.transformData.changes.vertices ? vertexConfig == null ? void 0 : vertexConfig.transformAnnotation(base, event.transformData.changes.vertices) : { rect: event.transformData.changes.rect };
96
- const patched = annotationCapability == null ? void 0 : annotationCapability.transformAnnotation(base, {
97
- type: transformType,
98
- changes,
99
- metadata: event.transformData.metadata
100
- });
101
- if (patched) {
102
- setPreview((prev) => ({
103
- ...prev,
104
- ...patched
105
- }));
106
- }
107
- if (event.state === "end" && patched) {
108
- gestureBaseRef.current = null;
109
- annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patched);
110
- }
111
- }
186
+ // Disable interaction handles when multi-selected
187
+ enabled: isSelected && !isMultiSelected,
188
+ onUpdate: handleUpdate
112
189
  },
113
190
  resizeUI: {
114
191
  handleSize: HANDLE_SIZE,
@@ -131,6 +208,20 @@ function AnnotationContainer({
131
208
  useEffect(() => {
132
209
  setPreview(trackedAnnotation.object);
133
210
  }, [trackedAnnotation.object]);
211
+ useEffect(() => {
212
+ if (!plugin) return;
213
+ const id = trackedAnnotation.object.id;
214
+ const handleEvent = (event) => {
215
+ var _a;
216
+ if (event.documentId !== documentId) return;
217
+ const patch = (_a = event.previewPatches) == null ? void 0 : _a[id];
218
+ if (event.type === "update" && patch) setPreview((prev) => ({ ...prev, ...patch }));
219
+ else if (event.type === "cancel") setPreview(trackedAnnotation.object);
220
+ };
221
+ const unsubs = [plugin.onDragChange(handleEvent), plugin.onResizeChange(handleEvent)];
222
+ return () => unsubs.forEach((u) => u());
223
+ }, [plugin, documentId, trackedAnnotation.object]);
224
+ const showOutline = isSelected && !isMultiSelected;
134
225
  return /* @__PURE__ */ jsxs("div", { "data-no-interaction": true, children: [
135
226
  /* @__PURE__ */ jsxs(
136
227
  "div",
@@ -143,9 +234,9 @@ function AnnotationContainer({
143
234
  top: currentObject.rect.origin.y * scale,
144
235
  width: currentObject.rect.size.width * scale,
145
236
  height: currentObject.rect.size.height * scale,
146
- outline: isSelected ? `1px solid ${selectionOutlineColor}` : "none",
147
- outlineOffset: isSelected ? `${outlineOffset}px` : "0px",
148
- pointerEvents: isSelected ? "auto" : "none",
237
+ outline: showOutline ? `1px solid ${selectionOutlineColor}` : "none",
238
+ outlineOffset: showOutline ? `${outlineOffset}px` : "0px",
239
+ pointerEvents: isSelected && !isMultiSelected ? "auto" : "none",
149
240
  touchAction: "none",
150
241
  cursor: isSelected && effectiveIsDraggable ? "move" : "default",
151
242
  zIndex,
@@ -185,7 +276,7 @@ function AnnotationContainer({
185
276
  key
186
277
  )
187
278
  ),
188
- isSelected && canModifyAnnotations && vertices.map(
279
+ isSelected && canModifyAnnotations && !isMultiSelected && vertices.map(
189
280
  ({ key, ...vProps }) => (vertexUI == null ? void 0 : vertexUI.component) ? vertexUI.component({
190
281
  key,
191
282
  ...vProps,
@@ -202,7 +293,7 @@ function AnnotationContainer({
202
293
  ]
203
294
  }
204
295
  ),
205
- selectionMenu && /* @__PURE__ */ jsx(
296
+ selectionMenu && !isMultiSelected && /* @__PURE__ */ jsx(
206
297
  CounterRotate,
207
298
  {
208
299
  rect: {
@@ -216,8 +307,8 @@ function AnnotationContainer({
216
307
  }
217
308
  },
218
309
  rotation,
219
- children: (props2) => selectionMenu({
220
- ...props2,
310
+ children: (counterRotateProps) => selectionMenu({
311
+ ...counterRotateProps,
221
312
  context: {
222
313
  type: "annotation",
223
314
  annotation: trackedAnnotation,
@@ -232,8 +323,205 @@ function AnnotationContainer({
232
323
  )
233
324
  ] });
234
325
  }
326
+ function GroupSelectionBox({
327
+ documentId,
328
+ pageIndex,
329
+ scale,
330
+ rotation,
331
+ pageWidth,
332
+ pageHeight,
333
+ selectedAnnotations,
334
+ isDraggable,
335
+ isResizable,
336
+ resizeUI,
337
+ selectionOutlineColor = "#007ACC",
338
+ outlineOffset = 2,
339
+ zIndex = 100,
340
+ groupSelectionMenu
341
+ }) {
342
+ const { plugin } = useAnnotationPlugin();
343
+ const { canModifyAnnotations } = useDocumentPermissions(documentId);
344
+ const gestureBaseRef = useRef(null);
345
+ const isDraggingRef = useRef(false);
346
+ const isResizingRef = useRef(false);
347
+ const effectiveIsDraggable = canModifyAnnotations && isDraggable;
348
+ const effectiveIsResizable = canModifyAnnotations && isResizable;
349
+ const groupBox = useMemo(() => {
350
+ const rects = selectedAnnotations.map((ta) => ta.object.rect);
351
+ return boundingRectOrEmpty(rects);
352
+ }, [selectedAnnotations]);
353
+ const [previewGroupBox, setPreviewGroupBox] = useState(groupBox);
354
+ useEffect(() => {
355
+ if (!isDraggingRef.current && !isResizingRef.current) {
356
+ setPreviewGroupBox(groupBox);
357
+ }
358
+ }, [groupBox]);
359
+ const handleUpdate = useCallback(
360
+ (event) => {
361
+ var _a, _b;
362
+ if (!((_a = event.transformData) == null ? void 0 : _a.type)) return;
363
+ if (!plugin) return;
364
+ const transformType = event.transformData.type;
365
+ const isMove = transformType === "move";
366
+ const isResize = transformType === "resize";
367
+ if (isMove && !effectiveIsDraggable) return;
368
+ if (event.state === "start") {
369
+ gestureBaseRef.current = groupBox;
370
+ if (isMove) {
371
+ isDraggingRef.current = true;
372
+ plugin.startDrag(documentId, {
373
+ annotationIds: selectedAnnotations.map((ta) => ta.object.id),
374
+ pageSize: { width: pageWidth, height: pageHeight }
375
+ });
376
+ } else if (isResize) {
377
+ isResizingRef.current = true;
378
+ plugin.startResize(documentId, {
379
+ annotationIds: selectedAnnotations.map((ta) => ta.object.id),
380
+ pageSize: { width: pageWidth, height: pageHeight },
381
+ resizeHandle: ((_b = event.transformData.metadata) == null ? void 0 : _b.handle) ?? "se"
382
+ });
383
+ }
384
+ }
385
+ const base = gestureBaseRef.current ?? groupBox;
386
+ if (isMove && event.transformData.changes.rect) {
387
+ const newRect = event.transformData.changes.rect;
388
+ const rawDelta = {
389
+ x: newRect.origin.x - base.origin.x,
390
+ y: newRect.origin.y - base.origin.y
391
+ };
392
+ const clampedDelta = plugin.updateDrag(documentId, rawDelta);
393
+ setPreviewGroupBox({
394
+ ...base,
395
+ origin: {
396
+ x: base.origin.x + clampedDelta.x,
397
+ y: base.origin.y + clampedDelta.y
398
+ }
399
+ });
400
+ } else if (isResize && event.transformData.changes.rect) {
401
+ const newGroupBox = event.transformData.changes.rect;
402
+ plugin.updateResize(documentId, newGroupBox);
403
+ setPreviewGroupBox(newGroupBox);
404
+ }
405
+ if (event.state === "end") {
406
+ gestureBaseRef.current = null;
407
+ if (isMove && isDraggingRef.current) {
408
+ isDraggingRef.current = false;
409
+ plugin.commitDrag(documentId);
410
+ } else if (isResize && isResizingRef.current) {
411
+ isResizingRef.current = false;
412
+ plugin.commitResize(documentId);
413
+ }
414
+ }
415
+ },
416
+ [
417
+ plugin,
418
+ documentId,
419
+ pageWidth,
420
+ pageHeight,
421
+ groupBox,
422
+ effectiveIsDraggable,
423
+ selectedAnnotations
424
+ ]
425
+ );
426
+ const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
427
+ const HANDLE_SIZE = (resizeUI == null ? void 0 : resizeUI.size) ?? 12;
428
+ const { dragProps, resize } = useInteractionHandles({
429
+ controller: {
430
+ element: previewGroupBox,
431
+ constraints: {
432
+ minWidth: 20,
433
+ minHeight: 20,
434
+ boundingBox: { width: pageWidth, height: pageHeight }
435
+ },
436
+ maintainAspectRatio: false,
437
+ pageRotation: rotation,
438
+ scale,
439
+ enabled: true,
440
+ onUpdate: handleUpdate
441
+ },
442
+ resizeUI: {
443
+ handleSize: HANDLE_SIZE,
444
+ spacing: outlineOffset,
445
+ offsetMode: "outside",
446
+ includeSides: true,
447
+ zIndex: zIndex + 1
448
+ },
449
+ vertexUI: {
450
+ vertexSize: 0,
451
+ zIndex
452
+ },
453
+ includeVertices: false
454
+ });
455
+ if (selectedAnnotations.length < 2) {
456
+ return null;
457
+ }
458
+ return /* @__PURE__ */ jsxs("div", { "data-group-selection-box": true, "data-no-interaction": true, children: [
459
+ /* @__PURE__ */ jsx(
460
+ "div",
461
+ {
462
+ ...effectiveIsDraggable ? dragProps : {
463
+ onPointerDown: (e) => e.stopPropagation()
464
+ },
465
+ style: {
466
+ position: "absolute",
467
+ left: previewGroupBox.origin.x * scale,
468
+ top: previewGroupBox.origin.y * scale,
469
+ width: previewGroupBox.size.width * scale,
470
+ height: previewGroupBox.size.height * scale,
471
+ outline: `2px dashed ${selectionOutlineColor}`,
472
+ outlineOffset: outlineOffset - 1,
473
+ cursor: effectiveIsDraggable ? "move" : "default",
474
+ touchAction: "none",
475
+ zIndex
476
+ },
477
+ children: effectiveIsResizable && resize.map(
478
+ ({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
479
+ key,
480
+ ...hProps,
481
+ backgroundColor: HANDLE_COLOR
482
+ }) : /* @__PURE__ */ jsx(
483
+ "div",
484
+ {
485
+ ...hProps,
486
+ style: { ...hProps.style, backgroundColor: HANDLE_COLOR }
487
+ },
488
+ key
489
+ )
490
+ )
491
+ }
492
+ ),
493
+ groupSelectionMenu && /* @__PURE__ */ jsx(
494
+ CounterRotate,
495
+ {
496
+ rect: {
497
+ origin: {
498
+ x: previewGroupBox.origin.x * scale,
499
+ y: previewGroupBox.origin.y * scale
500
+ },
501
+ size: {
502
+ width: previewGroupBox.size.width * scale,
503
+ height: previewGroupBox.size.height * scale
504
+ }
505
+ },
506
+ rotation,
507
+ children: (counterRotateProps) => groupSelectionMenu({
508
+ ...counterRotateProps,
509
+ context: {
510
+ type: "group",
511
+ annotations: selectedAnnotations,
512
+ pageIndex
513
+ },
514
+ selected: true,
515
+ placement: {
516
+ suggestTop: false
517
+ }
518
+ })
519
+ }
520
+ )
521
+ ] });
522
+ }
235
523
  function Highlight({
236
- color = "#FFFF00",
524
+ strokeColor,
237
525
  opacity = 0.5,
238
526
  segmentRects,
239
527
  rect,
@@ -241,6 +529,7 @@ function Highlight({
241
529
  onClick,
242
530
  style
243
531
  }) {
532
+ const resolvedColor = strokeColor ?? "#FFFF00";
244
533
  return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
245
534
  "div",
246
535
  {
@@ -252,7 +541,7 @@ function Highlight({
252
541
  top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
253
542
  width: b.size.width * scale,
254
543
  height: b.size.height * scale,
255
- background: color,
544
+ background: resolvedColor,
256
545
  opacity,
257
546
  pointerEvents: onClick ? "auto" : "none",
258
547
  cursor: onClick ? "pointer" : "default",
@@ -264,7 +553,7 @@ function Highlight({
264
553
  )) });
265
554
  }
266
555
  function Underline({
267
- color = "#FFFF00",
556
+ strokeColor,
268
557
  opacity = 0.5,
269
558
  segmentRects,
270
559
  rect,
@@ -272,6 +561,7 @@ function Underline({
272
561
  onClick,
273
562
  style
274
563
  }) {
564
+ const resolvedColor = strokeColor ?? "#FFFF00";
275
565
  const thickness = 2 * scale;
276
566
  return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
277
567
  "div",
@@ -299,7 +589,7 @@ function Underline({
299
589
  bottom: 0,
300
590
  width: "100%",
301
591
  height: thickness,
302
- background: color,
592
+ background: resolvedColor,
303
593
  opacity,
304
594
  pointerEvents: "none"
305
595
  }
@@ -310,7 +600,7 @@ function Underline({
310
600
  )) });
311
601
  }
312
602
  function Strikeout({
313
- color = "#FFFF00",
603
+ strokeColor,
314
604
  opacity = 0.5,
315
605
  segmentRects,
316
606
  rect,
@@ -318,6 +608,7 @@ function Strikeout({
318
608
  onClick,
319
609
  style
320
610
  }) {
611
+ const resolvedColor = strokeColor ?? "#FFFF00";
321
612
  const thickness = 2 * scale;
322
613
  return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
323
614
  "div",
@@ -345,7 +636,7 @@ function Strikeout({
345
636
  top: "50%",
346
637
  width: "100%",
347
638
  height: thickness,
348
- background: color,
639
+ background: resolvedColor,
349
640
  opacity,
350
641
  transform: "translateY(-50%)",
351
642
  pointerEvents: "none"
@@ -357,7 +648,7 @@ function Strikeout({
357
648
  )) });
358
649
  }
359
650
  function Squiggly({
360
- color = "#FFFF00",
651
+ strokeColor,
361
652
  opacity = 0.5,
362
653
  segmentRects,
363
654
  rect,
@@ -365,11 +656,12 @@ function Squiggly({
365
656
  onClick,
366
657
  style
367
658
  }) {
659
+ const resolvedColor = strokeColor ?? "#FFFF00";
368
660
  const amplitude = 2 * scale;
369
661
  const period = 6 * scale;
370
662
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
371
663
  <path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
372
- fill="none" stroke="${color}" stroke-width="${amplitude}" stroke-linecap="round"/>
664
+ fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
373
665
  </svg>`;
374
666
  const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
375
667
  return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
@@ -412,7 +704,7 @@ function Squiggly({
412
704
  }
413
705
  function Ink({
414
706
  isSelected,
415
- color = "#000000",
707
+ strokeColor,
416
708
  opacity = 1,
417
709
  strokeWidth,
418
710
  inkList,
@@ -420,6 +712,7 @@ function Ink({
420
712
  scale,
421
713
  onClick
422
714
  }) {
715
+ const resolvedColor = strokeColor ?? "#000000";
423
716
  const paths = useMemo(() => {
424
717
  return inkList.map(({ points }) => {
425
718
  let d = "";
@@ -458,7 +751,7 @@ function Ink({
458
751
  style: {
459
752
  cursor: isSelected ? "move" : "pointer",
460
753
  pointerEvents: isSelected ? "none" : "visibleStroke",
461
- stroke: color,
754
+ stroke: resolvedColor,
462
755
  strokeWidth,
463
756
  strokeLinecap: "round",
464
757
  strokeLinejoin: "round"
@@ -996,7 +1289,7 @@ function FreeText({
996
1289
  flexDirection: "column",
997
1290
  justifyContent: annotation.object.verticalAlign === PdfVerticalAlignment.Top ? "flex-start" : annotation.object.verticalAlign === PdfVerticalAlignment.Middle ? "center" : "flex-end",
998
1291
  display: "flex",
999
- backgroundColor: annotation.object.backgroundColor,
1292
+ backgroundColor: annotation.object.color ?? annotation.object.backgroundColor,
1000
1293
  opacity: annotation.object.opacity,
1001
1294
  width: needsComp ? `${invScalePercent}%` : "100%",
1002
1295
  height: needsComp ? `${invScalePercent}%` : "100%",
@@ -1109,26 +1402,123 @@ function Stamp({
1109
1402
  }
1110
1403
  );
1111
1404
  }
1405
+ function Link({
1406
+ isSelected,
1407
+ strokeColor = "#0000FF",
1408
+ strokeWidth = 2,
1409
+ strokeStyle = PdfAnnotationBorderStyle.UNDERLINE,
1410
+ strokeDashArray,
1411
+ rect,
1412
+ scale,
1413
+ onClick,
1414
+ hasIRT = false
1415
+ }) {
1416
+ const { width, height } = useMemo(() => {
1417
+ return {
1418
+ width: rect.size.width,
1419
+ height: rect.size.height
1420
+ };
1421
+ }, [rect]);
1422
+ const svgWidth = width * scale;
1423
+ const svgHeight = height * scale;
1424
+ const dashArray = useMemo(() => {
1425
+ if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
1426
+ return (strokeDashArray == null ? void 0 : strokeDashArray.join(",")) ?? `${strokeWidth * 3},${strokeWidth}`;
1427
+ }
1428
+ return void 0;
1429
+ }, [strokeStyle, strokeDashArray, strokeWidth]);
1430
+ const isUnderline2 = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
1431
+ return /* @__PURE__ */ jsxs(
1432
+ "svg",
1433
+ {
1434
+ style: {
1435
+ position: "absolute",
1436
+ width: svgWidth,
1437
+ height: svgHeight,
1438
+ pointerEvents: "none",
1439
+ zIndex: 2
1440
+ },
1441
+ width: svgWidth,
1442
+ height: svgHeight,
1443
+ viewBox: `0 0 ${width} ${height}`,
1444
+ children: [
1445
+ /* @__PURE__ */ jsx(
1446
+ "rect",
1447
+ {
1448
+ x: 0,
1449
+ y: 0,
1450
+ width,
1451
+ height,
1452
+ fill: "transparent",
1453
+ onPointerDown: hasIRT ? void 0 : onClick,
1454
+ onTouchStart: hasIRT ? void 0 : onClick,
1455
+ style: {
1456
+ cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
1457
+ pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
1458
+ }
1459
+ }
1460
+ ),
1461
+ isUnderline2 ? (
1462
+ // Underline style: line at bottom of rect
1463
+ /* @__PURE__ */ jsx(
1464
+ "line",
1465
+ {
1466
+ x1: 1,
1467
+ y1: height - 1,
1468
+ x2: width - 1,
1469
+ y2: height - 1,
1470
+ stroke: strokeColor,
1471
+ strokeWidth,
1472
+ strokeDasharray: dashArray,
1473
+ style: {
1474
+ pointerEvents: "none"
1475
+ }
1476
+ }
1477
+ )
1478
+ ) : (
1479
+ // Solid/Dashed style: rectangle border
1480
+ /* @__PURE__ */ jsx(
1481
+ "rect",
1482
+ {
1483
+ x: strokeWidth / 2,
1484
+ y: strokeWidth / 2,
1485
+ width: Math.max(width - strokeWidth, 0),
1486
+ height: Math.max(height - strokeWidth, 0),
1487
+ fill: "transparent",
1488
+ stroke: strokeColor,
1489
+ strokeWidth,
1490
+ strokeDasharray: dashArray,
1491
+ style: {
1492
+ pointerEvents: "none"
1493
+ }
1494
+ }
1495
+ )
1496
+ )
1497
+ ]
1498
+ }
1499
+ );
1500
+ }
1112
1501
  function Annotations(annotationsProps) {
1113
- const { documentId, pageIndex, scale, selectionMenu } = annotationsProps;
1502
+ const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
1114
1503
  const { provides: annotationCapability } = useAnnotationCapability();
1115
1504
  const { provides: selectionProvides } = useSelectionCapability();
1116
1505
  const [annotations, setAnnotations] = useState([]);
1117
1506
  const { register } = usePointerHandlers({ documentId, pageIndex });
1118
- const [selectionState, setSelectionState] = useState(null);
1507
+ const [allSelectedIds, setAllSelectedIds] = useState([]);
1119
1508
  const [editingId, setEditingId] = useState(null);
1120
1509
  const annotationProvides = useMemo(
1121
1510
  () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
1122
1511
  [annotationCapability, documentId]
1123
1512
  );
1513
+ const isMultiSelected = allSelectedIds.length > 1;
1124
1514
  useEffect(() => {
1125
1515
  if (annotationProvides) {
1126
1516
  const currentState = annotationProvides.getState();
1127
1517
  setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
1128
- setSelectionState(getSelectedAnnotationByPageIndex(currentState, pageIndex));
1518
+ setAllSelectedIds(getSelectedAnnotationIds(currentState));
1129
1519
  return annotationProvides.onStateChange((state) => {
1130
1520
  setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
1131
- setSelectionState(getSelectedAnnotationByPageIndex(state, pageIndex));
1521
+ setAllSelectedIds(getSelectedAnnotationIds(state));
1132
1522
  });
1133
1523
  }
1134
1524
  }, [annotationProvides, pageIndex]);
@@ -1147,8 +1537,13 @@ function Annotations(annotationsProps) {
1147
1537
  (e, annotation) => {
1148
1538
  e.stopPropagation();
1149
1539
  if (annotationProvides && selectionProvides) {
1150
- annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
1151
1540
  selectionProvides.clear();
1541
+ const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
1542
+ if (isModifierPressed) {
1543
+ annotationProvides.toggleSelection(pageIndex, annotation.object.id);
1544
+ } else {
1545
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
1546
+ }
1152
1547
  if (annotation.object.id !== editingId) {
1153
1548
  setEditingId(null);
1154
1549
  }
@@ -1156,369 +1551,668 @@ function Annotations(annotationsProps) {
1156
1551
  },
1157
1552
  [annotationProvides, selectionProvides, editingId, pageIndex]
1158
1553
  );
1554
+ const handleLinkClick = useCallback(
1555
+ (e, annotation) => {
1556
+ e.stopPropagation();
1557
+ if (!annotationProvides || !selectionProvides) return;
1558
+ selectionProvides.clear();
1559
+ if (annotation.object.inReplyToId) {
1560
+ const parentId = annotation.object.inReplyToId;
1561
+ const parent = annotations.find((a) => a.object.id === parentId);
1562
+ if (parent) {
1563
+ annotationProvides.selectAnnotation(parent.object.pageIndex, parentId);
1564
+ return;
1565
+ }
1566
+ }
1567
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
1568
+ },
1569
+ [annotationProvides, selectionProvides, annotations, pageIndex]
1570
+ );
1159
1571
  useEffect(() => {
1160
1572
  return register(handlers, {
1161
1573
  documentId
1162
1574
  });
1163
1575
  }, [register, handlers]);
1164
- return /* @__PURE__ */ jsx(Fragment, { children: annotations.map((annotation) => {
1165
- const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
1166
- const isEditing = editingId === annotation.object.id;
1167
- const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
1168
- if (isInk(annotation)) {
1169
- return /* @__PURE__ */ jsx(
1170
- AnnotationContainer,
1171
- {
1172
- trackedAnnotation: annotation,
1173
- isSelected,
1174
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1175
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
1176
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1177
- selectionMenu,
1178
- onSelect: (e) => handleClick(e, annotation),
1179
- style: {
1180
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1181
- },
1182
- ...annotationsProps,
1183
- children: (obj) => /* @__PURE__ */ jsx(
1184
- Ink,
1185
- {
1186
- ...obj,
1187
- isSelected,
1188
- scale,
1189
- onClick: (e) => handleClick(e, annotation)
1190
- }
1191
- )
1192
- },
1193
- annotation.object.id
1576
+ const selectedAnnotationsOnPage = useMemo(() => {
1577
+ return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
1578
+ }, [annotations, allSelectedIds]);
1579
+ const areAllSelectedDraggable = useMemo(() => {
1580
+ if (selectedAnnotationsOnPage.length < 2) return false;
1581
+ return selectedAnnotationsOnPage.every((ta) => {
1582
+ const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(ta.object);
1583
+ const groupDraggable = resolveInteractionProp(
1584
+ tool == null ? void 0 : tool.interaction.isGroupDraggable,
1585
+ ta.object,
1586
+ true
1194
1587
  );
1195
- }
1196
- if (isSquare(annotation)) {
1197
- return /* @__PURE__ */ jsx(
1198
- AnnotationContainer,
1199
- {
1200
- trackedAnnotation: annotation,
1201
- isSelected,
1202
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1203
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
1204
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1205
- selectionMenu,
1206
- onSelect: (e) => handleClick(e, annotation),
1207
- style: {
1208
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1209
- },
1210
- ...annotationsProps,
1211
- children: (obj) => /* @__PURE__ */ jsx(
1212
- Square,
1213
- {
1214
- ...obj,
1215
- isSelected,
1216
- scale,
1217
- onClick: (e) => handleClick(e, annotation)
1218
- }
1219
- )
1220
- },
1221
- annotation.object.id
1588
+ const singleDraggable = resolveInteractionProp(
1589
+ tool == null ? void 0 : tool.interaction.isDraggable,
1590
+ ta.object,
1591
+ true
1222
1592
  );
1223
- }
1224
- if (isCircle(annotation)) {
1225
- return /* @__PURE__ */ jsx(
1226
- AnnotationContainer,
1227
- {
1228
- trackedAnnotation: annotation,
1593
+ return (tool == null ? void 0 : tool.interaction.isGroupDraggable) !== void 0 ? groupDraggable : singleDraggable;
1594
+ });
1595
+ }, [selectedAnnotationsOnPage, annotationProvides]);
1596
+ const areAllSelectedResizable = useMemo(() => {
1597
+ if (selectedAnnotationsOnPage.length < 2) return false;
1598
+ return selectedAnnotationsOnPage.every((ta) => {
1599
+ const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(ta.object);
1600
+ const groupResizable = resolveInteractionProp(
1601
+ tool == null ? void 0 : tool.interaction.isGroupResizable,
1602
+ ta.object,
1603
+ true
1604
+ );
1605
+ const singleResizable = resolveInteractionProp(
1606
+ tool == null ? void 0 : tool.interaction.isResizable,
1607
+ ta.object,
1608
+ true
1609
+ );
1610
+ return (tool == null ? void 0 : tool.interaction.isGroupResizable) !== void 0 ? groupResizable : singleResizable;
1611
+ });
1612
+ }, [selectedAnnotationsOnPage, annotationProvides]);
1613
+ const allSelectedOnSamePage = useMemo(() => {
1614
+ if (!annotationProvides) return false;
1615
+ const allSelected = annotationProvides.getSelectedAnnotations();
1616
+ return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);
1617
+ }, [annotationProvides, pageIndex, allSelectedIds]);
1618
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1619
+ annotations.map((annotation) => {
1620
+ const isSelected = allSelectedIds.includes(annotation.object.id);
1621
+ const isEditing = editingId === annotation.object.id;
1622
+ const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
1623
+ for (const renderer of annotationsProps.annotationRenderers ?? []) {
1624
+ const element = renderer.tryRender(annotation, {
1229
1625
  isSelected,
1230
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1231
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
1232
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1233
- selectionMenu,
1234
- onSelect: (e) => handleClick(e, annotation),
1235
- style: {
1236
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1237
- },
1238
- ...annotationsProps,
1239
- children: (obj) => /* @__PURE__ */ jsx(
1240
- Circle,
1626
+ scale,
1627
+ pageIndex,
1628
+ onClick: (e) => handleClick(e, annotation)
1629
+ });
1630
+ if (element) {
1631
+ return /* @__PURE__ */ jsx(
1632
+ AnnotationContainer,
1241
1633
  {
1242
- ...obj,
1634
+ trackedAnnotation: annotation,
1243
1635
  isSelected,
1244
- scale,
1245
- onClick: (e) => handleClick(e, annotation)
1246
- }
1247
- )
1248
- },
1249
- annotation.object.id
1250
- );
1251
- }
1252
- if (isUnderline(annotation)) {
1253
- return /* @__PURE__ */ jsx(
1254
- AnnotationContainer,
1255
- {
1256
- trackedAnnotation: annotation,
1257
- isSelected,
1258
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
1259
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1260
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1261
- selectionMenu,
1262
- onSelect: (e) => handleClick(e, annotation),
1263
- zIndex: 0,
1264
- style: {
1265
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1636
+ isMultiSelected,
1637
+ isDraggable: resolveInteractionProp(
1638
+ tool == null ? void 0 : tool.interaction.isDraggable,
1639
+ annotation.object,
1640
+ false
1641
+ ),
1642
+ isResizable: resolveInteractionProp(
1643
+ tool == null ? void 0 : tool.interaction.isResizable,
1644
+ annotation.object,
1645
+ false
1646
+ ),
1647
+ lockAspectRatio: resolveInteractionProp(
1648
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1649
+ annotation.object,
1650
+ false
1651
+ ),
1652
+ selectionMenu,
1653
+ onSelect: (e) => handleClick(e, annotation),
1654
+ style: {
1655
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1656
+ },
1657
+ ...annotationsProps,
1658
+ children: () => element
1659
+ },
1660
+ annotation.object.id
1661
+ );
1662
+ }
1663
+ }
1664
+ if (isInk(annotation)) {
1665
+ return /* @__PURE__ */ jsx(
1666
+ AnnotationContainer,
1667
+ {
1668
+ trackedAnnotation: annotation,
1669
+ isSelected,
1670
+ isMultiSelected,
1671
+ isDraggable: resolveInteractionProp(
1672
+ tool == null ? void 0 : tool.interaction.isDraggable,
1673
+ annotation.object,
1674
+ true
1675
+ ),
1676
+ isResizable: resolveInteractionProp(
1677
+ tool == null ? void 0 : tool.interaction.isResizable,
1678
+ annotation.object,
1679
+ true
1680
+ ),
1681
+ lockAspectRatio: resolveInteractionProp(
1682
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1683
+ annotation.object,
1684
+ false
1685
+ ),
1686
+ selectionMenu,
1687
+ onSelect: (e) => handleClick(e, annotation),
1688
+ style: {
1689
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1690
+ },
1691
+ ...annotationsProps,
1692
+ children: (obj) => /* @__PURE__ */ jsx(
1693
+ Ink,
1694
+ {
1695
+ ...obj,
1696
+ isSelected,
1697
+ scale,
1698
+ onClick: (e) => handleClick(e, annotation)
1699
+ }
1700
+ )
1266
1701
  },
1267
- ...annotationsProps,
1268
- children: (obj) => /* @__PURE__ */ jsx(Underline, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1269
- },
1270
- annotation.object.id
1271
- );
1272
- }
1273
- if (isStrikeout(annotation)) {
1274
- return /* @__PURE__ */ jsx(
1275
- AnnotationContainer,
1276
- {
1277
- trackedAnnotation: annotation,
1278
- isSelected,
1279
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
1280
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1281
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1282
- selectionMenu,
1283
- onSelect: (e) => handleClick(e, annotation),
1284
- zIndex: 0,
1285
- style: {
1286
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1702
+ annotation.object.id
1703
+ );
1704
+ }
1705
+ if (isSquare(annotation)) {
1706
+ return /* @__PURE__ */ jsx(
1707
+ AnnotationContainer,
1708
+ {
1709
+ trackedAnnotation: annotation,
1710
+ isSelected,
1711
+ isMultiSelected,
1712
+ isDraggable: resolveInteractionProp(
1713
+ tool == null ? void 0 : tool.interaction.isDraggable,
1714
+ annotation.object,
1715
+ true
1716
+ ),
1717
+ isResizable: resolveInteractionProp(
1718
+ tool == null ? void 0 : tool.interaction.isResizable,
1719
+ annotation.object,
1720
+ true
1721
+ ),
1722
+ lockAspectRatio: resolveInteractionProp(
1723
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1724
+ annotation.object,
1725
+ false
1726
+ ),
1727
+ selectionMenu,
1728
+ onSelect: (e) => handleClick(e, annotation),
1729
+ style: {
1730
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1731
+ },
1732
+ ...annotationsProps,
1733
+ children: (obj) => /* @__PURE__ */ jsx(
1734
+ Square,
1735
+ {
1736
+ ...obj,
1737
+ isSelected,
1738
+ scale,
1739
+ onClick: (e) => handleClick(e, annotation)
1740
+ }
1741
+ )
1287
1742
  },
1288
- ...annotationsProps,
1289
- children: (obj) => /* @__PURE__ */ jsx(Strikeout, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1290
- },
1291
- annotation.object.id
1292
- );
1293
- }
1294
- if (isSquiggly(annotation)) {
1295
- return /* @__PURE__ */ jsx(
1296
- AnnotationContainer,
1297
- {
1298
- trackedAnnotation: annotation,
1299
- isSelected,
1300
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
1301
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1302
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1303
- selectionMenu,
1304
- onSelect: (e) => handleClick(e, annotation),
1305
- zIndex: 0,
1306
- style: {
1307
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1743
+ annotation.object.id
1744
+ );
1745
+ }
1746
+ if (isCircle(annotation)) {
1747
+ return /* @__PURE__ */ jsx(
1748
+ AnnotationContainer,
1749
+ {
1750
+ trackedAnnotation: annotation,
1751
+ isSelected,
1752
+ isMultiSelected,
1753
+ isDraggable: resolveInteractionProp(
1754
+ tool == null ? void 0 : tool.interaction.isDraggable,
1755
+ annotation.object,
1756
+ true
1757
+ ),
1758
+ isResizable: resolveInteractionProp(
1759
+ tool == null ? void 0 : tool.interaction.isResizable,
1760
+ annotation.object,
1761
+ true
1762
+ ),
1763
+ lockAspectRatio: resolveInteractionProp(
1764
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1765
+ annotation.object,
1766
+ false
1767
+ ),
1768
+ selectionMenu,
1769
+ onSelect: (e) => handleClick(e, annotation),
1770
+ style: {
1771
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1772
+ },
1773
+ ...annotationsProps,
1774
+ children: (obj) => /* @__PURE__ */ jsx(
1775
+ Circle,
1776
+ {
1777
+ ...obj,
1778
+ isSelected,
1779
+ scale,
1780
+ onClick: (e) => handleClick(e, annotation)
1781
+ }
1782
+ )
1308
1783
  },
1309
- ...annotationsProps,
1310
- children: (obj) => /* @__PURE__ */ jsx(Squiggly, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1311
- },
1312
- annotation.object.id
1313
- );
1314
- }
1315
- if (isHighlight(annotation)) {
1316
- return /* @__PURE__ */ jsx(
1317
- AnnotationContainer,
1318
- {
1319
- trackedAnnotation: annotation,
1320
- isSelected,
1321
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
1322
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1323
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1324
- selectionMenu,
1325
- onSelect: (e) => handleClick(e, annotation),
1326
- zIndex: 0,
1327
- style: {
1328
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
1784
+ annotation.object.id
1785
+ );
1786
+ }
1787
+ if (isUnderline(annotation)) {
1788
+ return /* @__PURE__ */ jsx(
1789
+ AnnotationContainer,
1790
+ {
1791
+ trackedAnnotation: annotation,
1792
+ isSelected,
1793
+ isMultiSelected,
1794
+ isDraggable: resolveInteractionProp(
1795
+ tool == null ? void 0 : tool.interaction.isDraggable,
1796
+ annotation.object,
1797
+ false
1798
+ ),
1799
+ isResizable: resolveInteractionProp(
1800
+ tool == null ? void 0 : tool.interaction.isResizable,
1801
+ annotation.object,
1802
+ false
1803
+ ),
1804
+ lockAspectRatio: resolveInteractionProp(
1805
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1806
+ annotation.object,
1807
+ false
1808
+ ),
1809
+ selectionMenu,
1810
+ onSelect: (e) => handleClick(e, annotation),
1811
+ zIndex: 0,
1812
+ style: {
1813
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1814
+ },
1815
+ ...annotationsProps,
1816
+ children: (obj) => /* @__PURE__ */ jsx(Underline, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1329
1817
  },
1330
- ...annotationsProps,
1331
- children: (obj) => /* @__PURE__ */ jsx(Highlight, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1332
- },
1333
- annotation.object.id
1334
- );
1335
- }
1336
- if (isLine(annotation)) {
1337
- return /* @__PURE__ */ jsx(
1338
- AnnotationContainer,
1339
- {
1340
- trackedAnnotation: annotation,
1341
- isSelected,
1342
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1343
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1344
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1345
- selectionMenu,
1346
- onSelect: (e) => handleClick(e, annotation),
1347
- vertexConfig: {
1348
- extractVertices: (annotation2) => [
1349
- annotation2.linePoints.start,
1350
- annotation2.linePoints.end
1351
- ],
1352
- transformAnnotation: (annotation2, vertices) => {
1353
- return {
1354
- ...annotation2,
1355
- linePoints: {
1356
- start: vertices[0],
1357
- end: vertices[1]
1358
- }
1359
- };
1360
- }
1818
+ annotation.object.id
1819
+ );
1820
+ }
1821
+ if (isStrikeout(annotation)) {
1822
+ return /* @__PURE__ */ jsx(
1823
+ AnnotationContainer,
1824
+ {
1825
+ trackedAnnotation: annotation,
1826
+ isSelected,
1827
+ isMultiSelected,
1828
+ isDraggable: resolveInteractionProp(
1829
+ tool == null ? void 0 : tool.interaction.isDraggable,
1830
+ annotation.object,
1831
+ false
1832
+ ),
1833
+ isResizable: resolveInteractionProp(
1834
+ tool == null ? void 0 : tool.interaction.isResizable,
1835
+ annotation.object,
1836
+ false
1837
+ ),
1838
+ lockAspectRatio: resolveInteractionProp(
1839
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1840
+ annotation.object,
1841
+ false
1842
+ ),
1843
+ selectionMenu,
1844
+ onSelect: (e) => handleClick(e, annotation),
1845
+ zIndex: 0,
1846
+ style: {
1847
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1848
+ },
1849
+ ...annotationsProps,
1850
+ children: (obj) => /* @__PURE__ */ jsx(Strikeout, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1361
1851
  },
1362
- style: {
1363
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1852
+ annotation.object.id
1853
+ );
1854
+ }
1855
+ if (isSquiggly(annotation)) {
1856
+ return /* @__PURE__ */ jsx(
1857
+ AnnotationContainer,
1858
+ {
1859
+ trackedAnnotation: annotation,
1860
+ isSelected,
1861
+ isMultiSelected,
1862
+ isDraggable: resolveInteractionProp(
1863
+ tool == null ? void 0 : tool.interaction.isDraggable,
1864
+ annotation.object,
1865
+ false
1866
+ ),
1867
+ isResizable: resolveInteractionProp(
1868
+ tool == null ? void 0 : tool.interaction.isResizable,
1869
+ annotation.object,
1870
+ false
1871
+ ),
1872
+ lockAspectRatio: resolveInteractionProp(
1873
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1874
+ annotation.object,
1875
+ false
1876
+ ),
1877
+ selectionMenu,
1878
+ onSelect: (e) => handleClick(e, annotation),
1879
+ zIndex: 0,
1880
+ style: {
1881
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1882
+ },
1883
+ ...annotationsProps,
1884
+ children: (obj) => /* @__PURE__ */ jsx(Squiggly, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1364
1885
  },
1365
- ...annotationsProps,
1366
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
1367
- Line,
1368
- {
1369
- ...obj,
1370
- isSelected,
1371
- scale,
1372
- onClick: (e) => handleClick(e, annotation)
1373
- }
1374
- ) })
1375
- },
1376
- annotation.object.id
1377
- );
1378
- }
1379
- if (isPolyline(annotation)) {
1380
- return /* @__PURE__ */ jsx(
1381
- AnnotationContainer,
1382
- {
1383
- trackedAnnotation: annotation,
1384
- isSelected,
1385
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1386
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1387
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1388
- selectionMenu,
1389
- onSelect: (e) => handleClick(e, annotation),
1390
- vertexConfig: {
1391
- extractVertices: (annotation2) => annotation2.vertices,
1392
- transformAnnotation: (annotation2, vertices) => {
1393
- return {
1394
- ...annotation2,
1395
- vertices
1396
- };
1397
- }
1886
+ annotation.object.id
1887
+ );
1888
+ }
1889
+ if (isHighlight(annotation)) {
1890
+ return /* @__PURE__ */ jsx(
1891
+ AnnotationContainer,
1892
+ {
1893
+ trackedAnnotation: annotation,
1894
+ isSelected,
1895
+ isMultiSelected,
1896
+ isDraggable: resolveInteractionProp(
1897
+ tool == null ? void 0 : tool.interaction.isDraggable,
1898
+ annotation.object,
1899
+ false
1900
+ ),
1901
+ isResizable: resolveInteractionProp(
1902
+ tool == null ? void 0 : tool.interaction.isResizable,
1903
+ annotation.object,
1904
+ false
1905
+ ),
1906
+ lockAspectRatio: resolveInteractionProp(
1907
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1908
+ annotation.object,
1909
+ false
1910
+ ),
1911
+ selectionMenu,
1912
+ onSelect: (e) => handleClick(e, annotation),
1913
+ zIndex: 0,
1914
+ style: {
1915
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
1916
+ },
1917
+ ...annotationsProps,
1918
+ children: (obj) => /* @__PURE__ */ jsx(Highlight, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
1398
1919
  },
1399
- style: {
1400
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1920
+ annotation.object.id
1921
+ );
1922
+ }
1923
+ if (isLine(annotation)) {
1924
+ return /* @__PURE__ */ jsx(
1925
+ AnnotationContainer,
1926
+ {
1927
+ trackedAnnotation: annotation,
1928
+ isSelected,
1929
+ isMultiSelected,
1930
+ isDraggable: resolveInteractionProp(
1931
+ tool == null ? void 0 : tool.interaction.isDraggable,
1932
+ annotation.object,
1933
+ true
1934
+ ),
1935
+ isResizable: resolveInteractionProp(
1936
+ tool == null ? void 0 : tool.interaction.isResizable,
1937
+ annotation.object,
1938
+ false
1939
+ ),
1940
+ lockAspectRatio: resolveInteractionProp(
1941
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1942
+ annotation.object,
1943
+ false
1944
+ ),
1945
+ selectionMenu,
1946
+ onSelect: (e) => handleClick(e, annotation),
1947
+ vertexConfig: {
1948
+ extractVertices: (annotation2) => [
1949
+ annotation2.linePoints.start,
1950
+ annotation2.linePoints.end
1951
+ ],
1952
+ transformAnnotation: (annotation2, vertices) => {
1953
+ return {
1954
+ ...annotation2,
1955
+ linePoints: {
1956
+ start: vertices[0],
1957
+ end: vertices[1]
1958
+ }
1959
+ };
1960
+ }
1961
+ },
1962
+ style: {
1963
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
1964
+ },
1965
+ ...annotationsProps,
1966
+ children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
1967
+ Line,
1968
+ {
1969
+ ...obj,
1970
+ isSelected,
1971
+ scale,
1972
+ onClick: (e) => handleClick(e, annotation)
1973
+ }
1974
+ ) })
1401
1975
  },
1402
- ...annotationsProps,
1403
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
1404
- Polyline,
1405
- {
1406
- ...obj,
1407
- isSelected,
1408
- scale,
1409
- onClick: (e) => handleClick(e, annotation)
1410
- }
1411
- ) })
1412
- },
1413
- annotation.object.id
1414
- );
1415
- }
1416
- if (isPolygon(annotation)) {
1417
- return /* @__PURE__ */ jsx(
1418
- AnnotationContainer,
1419
- {
1420
- trackedAnnotation: annotation,
1421
- isSelected,
1422
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1423
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
1424
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1425
- selectionMenu,
1426
- onSelect: (e) => handleClick(e, annotation),
1427
- vertexConfig: {
1428
- extractVertices: (annotation2) => annotation2.vertices,
1429
- transformAnnotation: (annotation2, vertices) => {
1430
- return {
1431
- ...annotation2,
1432
- vertices
1433
- };
1434
- }
1976
+ annotation.object.id
1977
+ );
1978
+ }
1979
+ if (isPolyline(annotation)) {
1980
+ return /* @__PURE__ */ jsx(
1981
+ AnnotationContainer,
1982
+ {
1983
+ trackedAnnotation: annotation,
1984
+ isSelected,
1985
+ isMultiSelected,
1986
+ isDraggable: resolveInteractionProp(
1987
+ tool == null ? void 0 : tool.interaction.isDraggable,
1988
+ annotation.object,
1989
+ true
1990
+ ),
1991
+ isResizable: resolveInteractionProp(
1992
+ tool == null ? void 0 : tool.interaction.isResizable,
1993
+ annotation.object,
1994
+ false
1995
+ ),
1996
+ lockAspectRatio: resolveInteractionProp(
1997
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
1998
+ annotation.object,
1999
+ false
2000
+ ),
2001
+ selectionMenu,
2002
+ onSelect: (e) => handleClick(e, annotation),
2003
+ vertexConfig: {
2004
+ extractVertices: (annotation2) => annotation2.vertices,
2005
+ transformAnnotation: (annotation2, vertices) => {
2006
+ return {
2007
+ ...annotation2,
2008
+ vertices
2009
+ };
2010
+ }
2011
+ },
2012
+ style: {
2013
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2014
+ },
2015
+ ...annotationsProps,
2016
+ children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2017
+ Polyline,
2018
+ {
2019
+ ...obj,
2020
+ isSelected,
2021
+ scale,
2022
+ onClick: (e) => handleClick(e, annotation)
2023
+ }
2024
+ ) })
1435
2025
  },
1436
- style: {
1437
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2026
+ annotation.object.id
2027
+ );
2028
+ }
2029
+ if (isPolygon(annotation)) {
2030
+ return /* @__PURE__ */ jsx(
2031
+ AnnotationContainer,
2032
+ {
2033
+ trackedAnnotation: annotation,
2034
+ isSelected,
2035
+ isMultiSelected,
2036
+ isDraggable: resolveInteractionProp(
2037
+ tool == null ? void 0 : tool.interaction.isDraggable,
2038
+ annotation.object,
2039
+ true
2040
+ ),
2041
+ isResizable: resolveInteractionProp(
2042
+ tool == null ? void 0 : tool.interaction.isResizable,
2043
+ annotation.object,
2044
+ false
2045
+ ),
2046
+ lockAspectRatio: resolveInteractionProp(
2047
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
2048
+ annotation.object,
2049
+ false
2050
+ ),
2051
+ selectionMenu,
2052
+ onSelect: (e) => handleClick(e, annotation),
2053
+ vertexConfig: {
2054
+ extractVertices: (annotation2) => annotation2.vertices,
2055
+ transformAnnotation: (annotation2, vertices) => {
2056
+ return {
2057
+ ...annotation2,
2058
+ vertices
2059
+ };
2060
+ }
2061
+ },
2062
+ style: {
2063
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2064
+ },
2065
+ ...annotationsProps,
2066
+ children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2067
+ Polygon,
2068
+ {
2069
+ ...obj,
2070
+ isSelected,
2071
+ scale,
2072
+ onClick: (e) => handleClick(e, annotation)
2073
+ }
2074
+ ) })
1438
2075
  },
1439
- ...annotationsProps,
1440
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
1441
- Polygon,
1442
- {
1443
- ...obj,
1444
- isSelected,
1445
- scale,
1446
- onClick: (e) => handleClick(e, annotation)
1447
- }
1448
- ) })
1449
- },
1450
- annotation.object.id
1451
- );
1452
- }
1453
- if (isFreeText(annotation)) {
1454
- return /* @__PURE__ */ jsx(
1455
- AnnotationContainer,
1456
- {
1457
- trackedAnnotation: annotation,
1458
- isSelected,
1459
- isDraggable: ((tool == null ? void 0 : tool.interaction.isDraggable) ?? true) && !isEditing,
1460
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
1461
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1462
- selectionMenu,
1463
- onSelect: (e) => handleClick(e, annotation),
1464
- style: {
1465
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2076
+ annotation.object.id
2077
+ );
2078
+ }
2079
+ if (isFreeText(annotation)) {
2080
+ return /* @__PURE__ */ jsx(
2081
+ AnnotationContainer,
2082
+ {
2083
+ trackedAnnotation: annotation,
2084
+ isSelected,
2085
+ isMultiSelected,
2086
+ isDraggable: resolveInteractionProp(tool == null ? void 0 : tool.interaction.isDraggable, annotation.object, true) && !isEditing,
2087
+ isResizable: resolveInteractionProp(
2088
+ tool == null ? void 0 : tool.interaction.isResizable,
2089
+ annotation.object,
2090
+ true
2091
+ ),
2092
+ lockAspectRatio: resolveInteractionProp(
2093
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
2094
+ annotation.object,
2095
+ false
2096
+ ),
2097
+ selectionMenu,
2098
+ onSelect: (e) => handleClick(e, annotation),
2099
+ style: {
2100
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2101
+ },
2102
+ onDoubleClick: (e) => {
2103
+ e.stopPropagation();
2104
+ setEditingId(annotation.object.id);
2105
+ },
2106
+ ...annotationsProps,
2107
+ children: (object) => /* @__PURE__ */ jsx(
2108
+ FreeText,
2109
+ {
2110
+ isSelected,
2111
+ isEditing,
2112
+ annotation: {
2113
+ ...annotation,
2114
+ object
2115
+ },
2116
+ pageIndex,
2117
+ scale,
2118
+ onClick: (e) => handleClick(e, annotation)
2119
+ }
2120
+ )
1466
2121
  },
1467
- onDoubleClick: (e) => {
1468
- e.stopPropagation();
1469
- setEditingId(annotation.object.id);
2122
+ annotation.object.id
2123
+ );
2124
+ }
2125
+ if (isStamp(annotation)) {
2126
+ return /* @__PURE__ */ jsx(
2127
+ AnnotationContainer,
2128
+ {
2129
+ trackedAnnotation: annotation,
2130
+ isSelected,
2131
+ isMultiSelected,
2132
+ isDraggable: resolveInteractionProp(
2133
+ tool == null ? void 0 : tool.interaction.isDraggable,
2134
+ annotation.object,
2135
+ true
2136
+ ),
2137
+ isResizable: resolveInteractionProp(
2138
+ tool == null ? void 0 : tool.interaction.isResizable,
2139
+ annotation.object,
2140
+ true
2141
+ ),
2142
+ lockAspectRatio: resolveInteractionProp(
2143
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
2144
+ annotation.object,
2145
+ false
2146
+ ),
2147
+ selectionMenu,
2148
+ onSelect: (e) => handleClick(e, annotation),
2149
+ style: {
2150
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2151
+ },
2152
+ ...annotationsProps,
2153
+ children: (_object) => /* @__PURE__ */ jsx(
2154
+ Stamp,
2155
+ {
2156
+ isSelected,
2157
+ annotation,
2158
+ documentId,
2159
+ pageIndex,
2160
+ scale,
2161
+ onClick: (e) => handleClick(e, annotation)
2162
+ }
2163
+ )
1470
2164
  },
1471
- ...annotationsProps,
1472
- children: (object) => /* @__PURE__ */ jsx(
1473
- FreeText,
1474
- {
1475
- isSelected,
1476
- isEditing,
1477
- annotation: {
1478
- ...annotation,
1479
- object
1480
- },
1481
- pageIndex,
1482
- scale,
1483
- onClick: (e) => handleClick(e, annotation)
1484
- }
1485
- )
1486
- },
1487
- annotation.object.id
1488
- );
1489
- }
1490
- if (isStamp(annotation)) {
1491
- return /* @__PURE__ */ jsx(
1492
- AnnotationContainer,
1493
- {
1494
- trackedAnnotation: annotation,
1495
- isSelected,
1496
- isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
1497
- isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
1498
- lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
1499
- selectionMenu,
1500
- onSelect: (e) => handleClick(e, annotation),
1501
- style: {
1502
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2165
+ annotation.object.id
2166
+ );
2167
+ }
2168
+ if (isLink(annotation)) {
2169
+ const hasIRT = !!annotation.object.inReplyToId;
2170
+ return /* @__PURE__ */ jsx(
2171
+ AnnotationContainer,
2172
+ {
2173
+ trackedAnnotation: annotation,
2174
+ isSelected,
2175
+ isMultiSelected,
2176
+ isDraggable: false,
2177
+ isResizable: false,
2178
+ lockAspectRatio: false,
2179
+ selectionMenu: hasIRT ? void 0 : selectionMenu,
2180
+ onSelect: (e) => handleLinkClick(e, annotation),
2181
+ ...annotationsProps,
2182
+ children: (obj) => /* @__PURE__ */ jsx(
2183
+ Link,
2184
+ {
2185
+ ...obj,
2186
+ isSelected,
2187
+ scale,
2188
+ onClick: (e) => handleLinkClick(e, annotation),
2189
+ hasIRT
2190
+ }
2191
+ )
1503
2192
  },
1504
- ...annotationsProps,
1505
- children: (_object) => /* @__PURE__ */ jsx(
1506
- Stamp,
1507
- {
1508
- isSelected,
1509
- annotation,
1510
- documentId,
1511
- pageIndex,
1512
- scale,
1513
- onClick: (e) => handleClick(e, annotation)
1514
- }
1515
- )
1516
- },
1517
- annotation.object.id
1518
- );
1519
- }
1520
- return null;
1521
- }) });
2193
+ annotation.object.id
2194
+ );
2195
+ }
2196
+ return null;
2197
+ }),
2198
+ allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && /* @__PURE__ */ jsx(
2199
+ GroupSelectionBox,
2200
+ {
2201
+ documentId,
2202
+ pageIndex,
2203
+ scale,
2204
+ rotation: annotationsProps.rotation,
2205
+ pageWidth,
2206
+ pageHeight,
2207
+ selectedAnnotations: selectedAnnotationsOnPage,
2208
+ isDraggable: areAllSelectedDraggable,
2209
+ isResizable: areAllSelectedResizable,
2210
+ resizeUI: annotationsProps.resizeUI,
2211
+ selectionOutlineColor: annotationsProps.selectionOutlineColor,
2212
+ groupSelectionMenu: annotationsProps.groupSelectionMenu
2213
+ }
2214
+ )
2215
+ ] });
1522
2216
  }
1523
2217
  function TextMarkup({ documentId, pageIndex, scale }) {
1524
2218
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
@@ -1555,7 +2249,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
1555
2249
  children: /* @__PURE__ */ jsx(
1556
2250
  Underline,
1557
2251
  {
1558
- color: (_b = activeTool.defaults) == null ? void 0 : _b.color,
2252
+ strokeColor: (_b = activeTool.defaults) == null ? void 0 : _b.strokeColor,
1559
2253
  opacity: (_c = activeTool.defaults) == null ? void 0 : _c.opacity,
1560
2254
  segmentRects: rects,
1561
2255
  scale
@@ -1576,7 +2270,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
1576
2270
  children: /* @__PURE__ */ jsx(
1577
2271
  Highlight,
1578
2272
  {
1579
- color: (_e = activeTool.defaults) == null ? void 0 : _e.color,
2273
+ strokeColor: (_e = activeTool.defaults) == null ? void 0 : _e.strokeColor,
1580
2274
  opacity: (_f = activeTool.defaults) == null ? void 0 : _f.opacity,
1581
2275
  segmentRects: rects,
1582
2276
  scale
@@ -1597,7 +2291,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
1597
2291
  children: /* @__PURE__ */ jsx(
1598
2292
  Strikeout,
1599
2293
  {
1600
- color: (_h = activeTool.defaults) == null ? void 0 : _h.color,
2294
+ strokeColor: (_h = activeTool.defaults) == null ? void 0 : _h.strokeColor,
1601
2295
  opacity: (_i = activeTool.defaults) == null ? void 0 : _i.opacity,
1602
2296
  segmentRects: rects,
1603
2297
  scale
@@ -1618,7 +2312,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
1618
2312
  children: /* @__PURE__ */ jsx(
1619
2313
  Squiggly,
1620
2314
  {
1621
- color: (_k = activeTool.defaults) == null ? void 0 : _k.color,
2315
+ strokeColor: (_k = activeTool.defaults) == null ? void 0 : _k.strokeColor,
1622
2316
  opacity: (_l = activeTool.defaults) == null ? void 0 : _l.opacity,
1623
2317
  segmentRects: rects,
1624
2318
  scale
@@ -1751,10 +2445,12 @@ function AnnotationLayer({
1751
2445
  scale: overrideScale,
1752
2446
  rotation: overrideRotation,
1753
2447
  selectionMenu,
2448
+ groupSelectionMenu,
1754
2449
  resizeUI,
1755
2450
  vertexUI,
1756
2451
  selectionOutlineColor,
1757
2452
  customAnnotationRenderer,
2453
+ annotationRenderers,
1758
2454
  ...props
1759
2455
  }) {
1760
2456
  var _a, _b, _c, _d;
@@ -1762,6 +2458,16 @@ function AnnotationLayer({
1762
2458
  const page = (_b = (_a = documentState == null ? void 0 : documentState.document) == null ? void 0 : _a.pages) == null ? void 0 : _b[pageIndex];
1763
2459
  const width = ((_c = page == null ? void 0 : page.size) == null ? void 0 : _c.width) ?? 0;
1764
2460
  const height = ((_d = page == null ? void 0 : page.size) == null ? void 0 : _d.height) ?? 0;
2461
+ const contextRenderers = useRegisteredRenderers();
2462
+ const allRenderers = useMemo(() => {
2463
+ const merged = [...contextRenderers];
2464
+ for (const renderer of annotationRenderers ?? []) {
2465
+ const idx = merged.findIndex((r) => r.id === renderer.id);
2466
+ if (idx >= 0) merged[idx] = renderer;
2467
+ else merged.push(renderer);
2468
+ }
2469
+ return merged;
2470
+ }, [contextRenderers, annotationRenderers]);
1765
2471
  const actualScale = useMemo(() => {
1766
2472
  if (overrideScale !== void 0) return overrideScale;
1767
2473
  return (documentState == null ? void 0 : documentState.scale) ?? 1;
@@ -1783,6 +2489,7 @@ function AnnotationLayer({
1783
2489
  {
1784
2490
  documentId,
1785
2491
  selectionMenu,
2492
+ groupSelectionMenu,
1786
2493
  pageIndex,
1787
2494
  scale: actualScale,
1788
2495
  rotation: actualRotation,
@@ -1791,7 +2498,8 @@ function AnnotationLayer({
1791
2498
  resizeUI,
1792
2499
  vertexUI,
1793
2500
  selectionOutlineColor,
1794
- customAnnotationRenderer
2501
+ customAnnotationRenderer,
2502
+ annotationRenderers: allRenderers
1795
2503
  }
1796
2504
  ),
1797
2505
  /* @__PURE__ */ jsx(TextMarkup, { documentId, pageIndex, scale: actualScale }),
@@ -1800,10 +2508,32 @@ function AnnotationLayer({
1800
2508
  }
1801
2509
  );
1802
2510
  }
2511
+ function createRenderer(entry) {
2512
+ return {
2513
+ id: entry.id,
2514
+ tryRender: (annotation, props) => {
2515
+ if (entry.matches(annotation.object)) {
2516
+ return entry.render({
2517
+ ...props,
2518
+ annotation
2519
+ });
2520
+ }
2521
+ return null;
2522
+ }
2523
+ };
2524
+ }
2525
+ const AnnotationPluginPackage = createPluginPackage(AnnotationPluginPackage$1).addWrapper(AnnotationRendererProvider).build();
1803
2526
  export {
1804
2527
  AnnotationLayer,
2528
+ AnnotationPluginPackage,
2529
+ AnnotationRendererProvider,
2530
+ GroupSelectionBox,
2531
+ createRenderer,
1805
2532
  useAnnotation,
1806
2533
  useAnnotationCapability,
1807
- useAnnotationPlugin
2534
+ useAnnotationPlugin,
2535
+ useRegisterRenderers,
2536
+ useRegisteredRenderers,
2537
+ useRendererRegistry
1808
2538
  };
1809
2539
  //# sourceMappingURL=index.js.map