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