@embedpdf/plugin-annotation 2.2.0 → 2.3.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1196 -92
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +31 -2
- package/dist/lib/annotation-plugin.d.ts +177 -2
- package/dist/lib/handlers/types.d.ts +1 -1
- package/dist/lib/helpers.d.ts +6 -1
- package/dist/lib/selectors.d.ts +97 -8
- package/dist/lib/tools/default-tools.d.ts +39 -11
- package/dist/lib/tools/types.d.ts +7 -1
- package/dist/lib/types.d.ts +265 -1
- package/dist/preact/adapter.d.ts +3 -3
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +857 -403
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +857 -403
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +8 -1
- package/dist/shared/components/annotation-layer.d.ts +4 -2
- package/dist/shared/components/annotations/ink.d.ts +3 -3
- package/dist/shared/components/annotations/link.d.ts +28 -0
- package/dist/shared/components/annotations.d.ts +2 -1
- package/dist/shared/components/group-selection-box.d.ts +32 -0
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared/components/text-markup/underline.d.ts +3 -2
- package/dist/shared/components/types.d.ts +7 -0
- package/dist/shared-preact/components/annotation-container.d.ts +8 -1
- package/dist/shared-preact/components/annotation-layer.d.ts +4 -2
- package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
- package/dist/shared-preact/components/annotations/link.d.ts +28 -0
- package/dist/shared-preact/components/annotations.d.ts +2 -1
- package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-preact/components/types.d.ts +7 -0
- package/dist/shared-react/components/annotation-container.d.ts +8 -1
- package/dist/shared-react/components/annotation-layer.d.ts +4 -2
- package/dist/shared-react/components/annotations/ink.d.ts +3 -3
- package/dist/shared-react/components/annotations/link.d.ts +28 -0
- package/dist/shared-react/components/annotations.d.ts +2 -1
- package/dist/shared-react/components/group-selection-box.d.ts +32 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
- package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
- package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
- package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
- package/dist/shared-react/components/types.d.ts +7 -0
- package/dist/svelte/components/AnnotationLayer.svelte.d.ts +5 -1
- package/dist/svelte/components/Annotations.svelte.d.ts +5 -1
- package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
- package/dist/svelte/components/types.d.ts +2 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +905 -255
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +7 -0
- package/dist/vue/components/annotation-container.vue.d.ts +2 -0
- package/dist/vue/components/annotation-layer.vue.d.ts +28 -5
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
- package/dist/vue/components/annotations/line.vue.d.ts +1 -1
- package/dist/vue/components/annotations/link.vue.d.ts +29 -0
- package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
- package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
- package/dist/vue/components/annotations.vue.d.ts +65 -1
- package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
- package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
- package/dist/vue/hooks/use-annotation.d.ts +2 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +946 -406
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +7 -0
- package/package.json +10 -10
package/dist/react/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/react";
|
|
2
|
-
import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex,
|
|
2
|
+
import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp, isLink } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
|
-
import { useState, useEffect, useRef, useMemo, useLayoutEffect, Fragment as Fragment$1
|
|
4
|
+
import { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect, Fragment as Fragment$1 } from "react";
|
|
5
5
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
6
|
-
import { PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
|
|
6
|
+
import { boundingRectOrEmpty, PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
|
|
7
7
|
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
8
8
|
import { useSelectionCapability } from "@embedpdf/plugin-selection/react";
|
|
9
9
|
import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/react";
|
|
@@ -41,6 +41,7 @@ function AnnotationContainer({
|
|
|
41
41
|
trackedAnnotation,
|
|
42
42
|
children,
|
|
43
43
|
isSelected,
|
|
44
|
+
isMultiSelected = false,
|
|
44
45
|
isDraggable,
|
|
45
46
|
isResizable,
|
|
46
47
|
lockAspectRatio = false,
|
|
@@ -59,10 +60,11 @@ function AnnotationContainer({
|
|
|
59
60
|
}) {
|
|
60
61
|
const [preview, setPreview] = useState(trackedAnnotation.object);
|
|
61
62
|
const { provides: annotationCapability } = useAnnotationCapability();
|
|
63
|
+
const { plugin } = useAnnotationPlugin();
|
|
62
64
|
const { canModifyAnnotations } = useDocumentPermissions(documentId);
|
|
63
65
|
const gestureBaseRef = useRef(null);
|
|
64
|
-
const effectiveIsDraggable = canModifyAnnotations && isDraggable;
|
|
65
|
-
const effectiveIsResizable = canModifyAnnotations && isResizable;
|
|
66
|
+
const effectiveIsDraggable = canModifyAnnotations && isDraggable && !isMultiSelected;
|
|
67
|
+
const effectiveIsResizable = canModifyAnnotations && isResizable && !isMultiSelected;
|
|
66
68
|
const annotationProvides = useMemo(
|
|
67
69
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
68
70
|
[annotationCapability, documentId]
|
|
@@ -72,6 +74,73 @@ function AnnotationContainer({
|
|
|
72
74
|
const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
|
|
73
75
|
const HANDLE_SIZE = (resizeUI == null ? void 0 : resizeUI.size) ?? 12;
|
|
74
76
|
const VERTEX_SIZE = (vertexUI == null ? void 0 : vertexUI.size) ?? 12;
|
|
77
|
+
const gestureBaseRectRef = useRef(null);
|
|
78
|
+
const handleUpdate = useCallback(
|
|
79
|
+
(event) => {
|
|
80
|
+
var _a;
|
|
81
|
+
if (!((_a = event.transformData) == null ? void 0 : _a.type) || isMultiSelected || !plugin) return;
|
|
82
|
+
const { type, changes, metadata } = event.transformData;
|
|
83
|
+
const id = trackedAnnotation.object.id;
|
|
84
|
+
const pageSize = { width: pageWidth, height: pageHeight };
|
|
85
|
+
if (event.state === "start") {
|
|
86
|
+
gestureBaseRectRef.current = trackedAnnotation.object.rect;
|
|
87
|
+
gestureBaseRef.current = trackedAnnotation.object;
|
|
88
|
+
if (type === "move") {
|
|
89
|
+
plugin.startDrag(documentId, { annotationIds: [id], pageSize });
|
|
90
|
+
} else if (type === "resize") {
|
|
91
|
+
plugin.startResize(documentId, {
|
|
92
|
+
annotationIds: [id],
|
|
93
|
+
pageSize,
|
|
94
|
+
resizeHandle: (metadata == null ? void 0 : metadata.handle) ?? "se"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (changes.rect && gestureBaseRectRef.current) {
|
|
99
|
+
if (type === "move") {
|
|
100
|
+
const delta = {
|
|
101
|
+
x: changes.rect.origin.x - gestureBaseRectRef.current.origin.x,
|
|
102
|
+
y: changes.rect.origin.y - gestureBaseRectRef.current.origin.y
|
|
103
|
+
};
|
|
104
|
+
plugin.updateDrag(documentId, delta);
|
|
105
|
+
} else if (type === "resize") {
|
|
106
|
+
plugin.updateResize(documentId, changes.rect);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (type === "vertex-edit" && changes.vertices && vertexConfig) {
|
|
110
|
+
const base = gestureBaseRef.current ?? trackedAnnotation.object;
|
|
111
|
+
const vertexChanges = vertexConfig.transformAnnotation(base, changes.vertices);
|
|
112
|
+
const patched = annotationCapability == null ? void 0 : annotationCapability.transformAnnotation(base, {
|
|
113
|
+
type,
|
|
114
|
+
changes: vertexChanges,
|
|
115
|
+
metadata
|
|
116
|
+
});
|
|
117
|
+
if (patched) {
|
|
118
|
+
setPreview((prev) => ({ ...prev, ...patched }));
|
|
119
|
+
if (event.state === "end") {
|
|
120
|
+
annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, id, patched);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (event.state === "end") {
|
|
125
|
+
gestureBaseRectRef.current = null;
|
|
126
|
+
gestureBaseRef.current = null;
|
|
127
|
+
if (type === "move") plugin.commitDrag(documentId);
|
|
128
|
+
else if (type === "resize") plugin.commitResize(documentId);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
[
|
|
132
|
+
plugin,
|
|
133
|
+
documentId,
|
|
134
|
+
trackedAnnotation.object,
|
|
135
|
+
pageWidth,
|
|
136
|
+
pageHeight,
|
|
137
|
+
pageIndex,
|
|
138
|
+
isMultiSelected,
|
|
139
|
+
vertexConfig,
|
|
140
|
+
annotationCapability,
|
|
141
|
+
annotationProvides
|
|
142
|
+
]
|
|
143
|
+
);
|
|
75
144
|
const { dragProps, vertices, resize } = useInteractionHandles({
|
|
76
145
|
controller: {
|
|
77
146
|
element: currentObject.rect,
|
|
@@ -84,32 +153,9 @@ function AnnotationContainer({
|
|
|
84
153
|
maintainAspectRatio: lockAspectRatio,
|
|
85
154
|
pageRotation: rotation,
|
|
86
155
|
scale,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
}
|
|
156
|
+
// Disable interaction handles when multi-selected
|
|
157
|
+
enabled: isSelected && !isMultiSelected,
|
|
158
|
+
onUpdate: handleUpdate
|
|
113
159
|
},
|
|
114
160
|
resizeUI: {
|
|
115
161
|
handleSize: HANDLE_SIZE,
|
|
@@ -132,6 +178,20 @@ function AnnotationContainer({
|
|
|
132
178
|
useEffect(() => {
|
|
133
179
|
setPreview(trackedAnnotation.object);
|
|
134
180
|
}, [trackedAnnotation.object]);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (!plugin) return;
|
|
183
|
+
const id = trackedAnnotation.object.id;
|
|
184
|
+
const handleEvent = (event) => {
|
|
185
|
+
var _a;
|
|
186
|
+
if (event.documentId !== documentId) return;
|
|
187
|
+
const patch = (_a = event.previewPatches) == null ? void 0 : _a[id];
|
|
188
|
+
if (event.type === "update" && patch) setPreview((prev) => ({ ...prev, ...patch }));
|
|
189
|
+
else if (event.type === "cancel") setPreview(trackedAnnotation.object);
|
|
190
|
+
};
|
|
191
|
+
const unsubs = [plugin.onDragChange(handleEvent), plugin.onResizeChange(handleEvent)];
|
|
192
|
+
return () => unsubs.forEach((u) => u());
|
|
193
|
+
}, [plugin, documentId, trackedAnnotation.object]);
|
|
194
|
+
const showOutline = isSelected && !isMultiSelected;
|
|
135
195
|
return /* @__PURE__ */ jsxs("div", { "data-no-interaction": true, children: [
|
|
136
196
|
/* @__PURE__ */ jsxs(
|
|
137
197
|
"div",
|
|
@@ -144,9 +204,9 @@ function AnnotationContainer({
|
|
|
144
204
|
top: currentObject.rect.origin.y * scale,
|
|
145
205
|
width: currentObject.rect.size.width * scale,
|
|
146
206
|
height: currentObject.rect.size.height * scale,
|
|
147
|
-
outline:
|
|
148
|
-
outlineOffset:
|
|
149
|
-
pointerEvents: isSelected ? "auto" : "none",
|
|
207
|
+
outline: showOutline ? `1px solid ${selectionOutlineColor}` : "none",
|
|
208
|
+
outlineOffset: showOutline ? `${outlineOffset}px` : "0px",
|
|
209
|
+
pointerEvents: isSelected && !isMultiSelected ? "auto" : "none",
|
|
150
210
|
touchAction: "none",
|
|
151
211
|
cursor: isSelected && effectiveIsDraggable ? "move" : "default",
|
|
152
212
|
zIndex,
|
|
@@ -186,7 +246,7 @@ function AnnotationContainer({
|
|
|
186
246
|
key
|
|
187
247
|
)
|
|
188
248
|
),
|
|
189
|
-
isSelected && canModifyAnnotations && vertices.map(
|
|
249
|
+
isSelected && canModifyAnnotations && !isMultiSelected && vertices.map(
|
|
190
250
|
({ key, ...vProps }) => (vertexUI == null ? void 0 : vertexUI.component) ? vertexUI.component({
|
|
191
251
|
key,
|
|
192
252
|
...vProps,
|
|
@@ -203,7 +263,7 @@ function AnnotationContainer({
|
|
|
203
263
|
]
|
|
204
264
|
}
|
|
205
265
|
),
|
|
206
|
-
selectionMenu && /* @__PURE__ */ jsx(
|
|
266
|
+
selectionMenu && !isMultiSelected && /* @__PURE__ */ jsx(
|
|
207
267
|
CounterRotate,
|
|
208
268
|
{
|
|
209
269
|
rect: {
|
|
@@ -217,8 +277,8 @@ function AnnotationContainer({
|
|
|
217
277
|
}
|
|
218
278
|
},
|
|
219
279
|
rotation,
|
|
220
|
-
children: (
|
|
221
|
-
...
|
|
280
|
+
children: (counterRotateProps) => selectionMenu({
|
|
281
|
+
...counterRotateProps,
|
|
222
282
|
context: {
|
|
223
283
|
type: "annotation",
|
|
224
284
|
annotation: trackedAnnotation,
|
|
@@ -233,8 +293,194 @@ function AnnotationContainer({
|
|
|
233
293
|
)
|
|
234
294
|
] });
|
|
235
295
|
}
|
|
296
|
+
function GroupSelectionBox({
|
|
297
|
+
documentId,
|
|
298
|
+
pageIndex,
|
|
299
|
+
scale,
|
|
300
|
+
rotation,
|
|
301
|
+
pageWidth,
|
|
302
|
+
pageHeight,
|
|
303
|
+
selectedAnnotations,
|
|
304
|
+
isDraggable,
|
|
305
|
+
isResizable,
|
|
306
|
+
resizeUI,
|
|
307
|
+
selectionOutlineColor = "#007ACC",
|
|
308
|
+
outlineOffset = 2,
|
|
309
|
+
zIndex = 100,
|
|
310
|
+
groupSelectionMenu
|
|
311
|
+
}) {
|
|
312
|
+
const { plugin } = useAnnotationPlugin();
|
|
313
|
+
const gestureBaseRef = useRef(null);
|
|
314
|
+
const isDraggingRef = useRef(false);
|
|
315
|
+
const isResizingRef = useRef(false);
|
|
316
|
+
const groupBox = useMemo(() => {
|
|
317
|
+
const rects = selectedAnnotations.map((ta) => ta.object.rect);
|
|
318
|
+
return boundingRectOrEmpty(rects);
|
|
319
|
+
}, [selectedAnnotations]);
|
|
320
|
+
const [previewGroupBox, setPreviewGroupBox] = useState(groupBox);
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (!isDraggingRef.current && !isResizingRef.current) {
|
|
323
|
+
setPreviewGroupBox(groupBox);
|
|
324
|
+
}
|
|
325
|
+
}, [groupBox]);
|
|
326
|
+
const handleUpdate = useCallback(
|
|
327
|
+
(event) => {
|
|
328
|
+
var _a, _b;
|
|
329
|
+
if (!((_a = event.transformData) == null ? void 0 : _a.type)) return;
|
|
330
|
+
if (!plugin) return;
|
|
331
|
+
const transformType = event.transformData.type;
|
|
332
|
+
const isMove = transformType === "move";
|
|
333
|
+
const isResize = transformType === "resize";
|
|
334
|
+
if (isMove && !isDraggable) return;
|
|
335
|
+
if (event.state === "start") {
|
|
336
|
+
gestureBaseRef.current = groupBox;
|
|
337
|
+
if (isMove) {
|
|
338
|
+
isDraggingRef.current = true;
|
|
339
|
+
plugin.startDrag(documentId, {
|
|
340
|
+
annotationIds: selectedAnnotations.map((ta) => ta.object.id),
|
|
341
|
+
pageSize: { width: pageWidth, height: pageHeight }
|
|
342
|
+
});
|
|
343
|
+
} else if (isResize) {
|
|
344
|
+
isResizingRef.current = true;
|
|
345
|
+
plugin.startResize(documentId, {
|
|
346
|
+
annotationIds: selectedAnnotations.map((ta) => ta.object.id),
|
|
347
|
+
pageSize: { width: pageWidth, height: pageHeight },
|
|
348
|
+
resizeHandle: ((_b = event.transformData.metadata) == null ? void 0 : _b.handle) ?? "se"
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const base = gestureBaseRef.current ?? groupBox;
|
|
353
|
+
if (isMove && event.transformData.changes.rect) {
|
|
354
|
+
const newRect = event.transformData.changes.rect;
|
|
355
|
+
const rawDelta = {
|
|
356
|
+
x: newRect.origin.x - base.origin.x,
|
|
357
|
+
y: newRect.origin.y - base.origin.y
|
|
358
|
+
};
|
|
359
|
+
const clampedDelta = plugin.updateDrag(documentId, rawDelta);
|
|
360
|
+
setPreviewGroupBox({
|
|
361
|
+
...base,
|
|
362
|
+
origin: {
|
|
363
|
+
x: base.origin.x + clampedDelta.x,
|
|
364
|
+
y: base.origin.y + clampedDelta.y
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
} else if (isResize && event.transformData.changes.rect) {
|
|
368
|
+
const newGroupBox = event.transformData.changes.rect;
|
|
369
|
+
plugin.updateResize(documentId, newGroupBox);
|
|
370
|
+
setPreviewGroupBox(newGroupBox);
|
|
371
|
+
}
|
|
372
|
+
if (event.state === "end") {
|
|
373
|
+
gestureBaseRef.current = null;
|
|
374
|
+
if (isMove && isDraggingRef.current) {
|
|
375
|
+
isDraggingRef.current = false;
|
|
376
|
+
plugin.commitDrag(documentId);
|
|
377
|
+
} else if (isResize && isResizingRef.current) {
|
|
378
|
+
isResizingRef.current = false;
|
|
379
|
+
plugin.commitResize(documentId);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
[plugin, documentId, pageWidth, pageHeight, groupBox, isDraggable, selectedAnnotations]
|
|
384
|
+
);
|
|
385
|
+
const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
|
|
386
|
+
const HANDLE_SIZE = (resizeUI == null ? void 0 : resizeUI.size) ?? 12;
|
|
387
|
+
const { dragProps, resize } = useInteractionHandles({
|
|
388
|
+
controller: {
|
|
389
|
+
element: previewGroupBox,
|
|
390
|
+
constraints: {
|
|
391
|
+
minWidth: 20,
|
|
392
|
+
minHeight: 20,
|
|
393
|
+
boundingBox: { width: pageWidth, height: pageHeight }
|
|
394
|
+
},
|
|
395
|
+
maintainAspectRatio: false,
|
|
396
|
+
pageRotation: rotation,
|
|
397
|
+
scale,
|
|
398
|
+
enabled: true,
|
|
399
|
+
onUpdate: handleUpdate
|
|
400
|
+
},
|
|
401
|
+
resizeUI: {
|
|
402
|
+
handleSize: HANDLE_SIZE,
|
|
403
|
+
spacing: outlineOffset,
|
|
404
|
+
offsetMode: "outside",
|
|
405
|
+
includeSides: true,
|
|
406
|
+
zIndex: zIndex + 1
|
|
407
|
+
},
|
|
408
|
+
vertexUI: {
|
|
409
|
+
vertexSize: 0,
|
|
410
|
+
zIndex
|
|
411
|
+
},
|
|
412
|
+
includeVertices: false
|
|
413
|
+
});
|
|
414
|
+
if (selectedAnnotations.length < 2) {
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
return /* @__PURE__ */ jsxs("div", { "data-group-selection-box": true, "data-no-interaction": true, children: [
|
|
418
|
+
/* @__PURE__ */ jsx(
|
|
419
|
+
"div",
|
|
420
|
+
{
|
|
421
|
+
...isDraggable ? dragProps : {
|
|
422
|
+
onPointerDown: (e) => e.stopPropagation()
|
|
423
|
+
},
|
|
424
|
+
style: {
|
|
425
|
+
position: "absolute",
|
|
426
|
+
left: previewGroupBox.origin.x * scale,
|
|
427
|
+
top: previewGroupBox.origin.y * scale,
|
|
428
|
+
width: previewGroupBox.size.width * scale,
|
|
429
|
+
height: previewGroupBox.size.height * scale,
|
|
430
|
+
outline: `2px dashed ${selectionOutlineColor}`,
|
|
431
|
+
outlineOffset: outlineOffset - 1,
|
|
432
|
+
cursor: isDraggable ? "move" : "default",
|
|
433
|
+
touchAction: "none",
|
|
434
|
+
zIndex
|
|
435
|
+
},
|
|
436
|
+
children: isResizable && resize.map(
|
|
437
|
+
({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
|
|
438
|
+
key,
|
|
439
|
+
...hProps,
|
|
440
|
+
backgroundColor: HANDLE_COLOR
|
|
441
|
+
}) : /* @__PURE__ */ jsx(
|
|
442
|
+
"div",
|
|
443
|
+
{
|
|
444
|
+
...hProps,
|
|
445
|
+
style: { ...hProps.style, backgroundColor: HANDLE_COLOR }
|
|
446
|
+
},
|
|
447
|
+
key
|
|
448
|
+
)
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
groupSelectionMenu && /* @__PURE__ */ jsx(
|
|
453
|
+
CounterRotate,
|
|
454
|
+
{
|
|
455
|
+
rect: {
|
|
456
|
+
origin: {
|
|
457
|
+
x: previewGroupBox.origin.x * scale,
|
|
458
|
+
y: previewGroupBox.origin.y * scale
|
|
459
|
+
},
|
|
460
|
+
size: {
|
|
461
|
+
width: previewGroupBox.size.width * scale,
|
|
462
|
+
height: previewGroupBox.size.height * scale
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
rotation,
|
|
466
|
+
children: (counterRotateProps) => groupSelectionMenu({
|
|
467
|
+
...counterRotateProps,
|
|
468
|
+
context: {
|
|
469
|
+
type: "group",
|
|
470
|
+
annotations: selectedAnnotations,
|
|
471
|
+
pageIndex
|
|
472
|
+
},
|
|
473
|
+
selected: true,
|
|
474
|
+
placement: {
|
|
475
|
+
suggestTop: false
|
|
476
|
+
}
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
)
|
|
480
|
+
] });
|
|
481
|
+
}
|
|
236
482
|
function Highlight({
|
|
237
|
-
|
|
483
|
+
strokeColor,
|
|
238
484
|
opacity = 0.5,
|
|
239
485
|
segmentRects,
|
|
240
486
|
rect,
|
|
@@ -242,6 +488,7 @@ function Highlight({
|
|
|
242
488
|
onClick,
|
|
243
489
|
style
|
|
244
490
|
}) {
|
|
491
|
+
const resolvedColor = strokeColor ?? "#FFFF00";
|
|
245
492
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
|
|
246
493
|
"div",
|
|
247
494
|
{
|
|
@@ -253,7 +500,7 @@ function Highlight({
|
|
|
253
500
|
top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
|
|
254
501
|
width: b.size.width * scale,
|
|
255
502
|
height: b.size.height * scale,
|
|
256
|
-
background:
|
|
503
|
+
background: resolvedColor,
|
|
257
504
|
opacity,
|
|
258
505
|
pointerEvents: onClick ? "auto" : "none",
|
|
259
506
|
cursor: onClick ? "pointer" : "default",
|
|
@@ -265,7 +512,7 @@ function Highlight({
|
|
|
265
512
|
)) });
|
|
266
513
|
}
|
|
267
514
|
function Underline({
|
|
268
|
-
|
|
515
|
+
strokeColor,
|
|
269
516
|
opacity = 0.5,
|
|
270
517
|
segmentRects,
|
|
271
518
|
rect,
|
|
@@ -273,6 +520,7 @@ function Underline({
|
|
|
273
520
|
onClick,
|
|
274
521
|
style
|
|
275
522
|
}) {
|
|
523
|
+
const resolvedColor = strokeColor ?? "#FFFF00";
|
|
276
524
|
const thickness = 2 * scale;
|
|
277
525
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
|
|
278
526
|
"div",
|
|
@@ -300,7 +548,7 @@ function Underline({
|
|
|
300
548
|
bottom: 0,
|
|
301
549
|
width: "100%",
|
|
302
550
|
height: thickness,
|
|
303
|
-
background:
|
|
551
|
+
background: resolvedColor,
|
|
304
552
|
opacity,
|
|
305
553
|
pointerEvents: "none"
|
|
306
554
|
}
|
|
@@ -311,7 +559,7 @@ function Underline({
|
|
|
311
559
|
)) });
|
|
312
560
|
}
|
|
313
561
|
function Strikeout({
|
|
314
|
-
|
|
562
|
+
strokeColor,
|
|
315
563
|
opacity = 0.5,
|
|
316
564
|
segmentRects,
|
|
317
565
|
rect,
|
|
@@ -319,6 +567,7 @@ function Strikeout({
|
|
|
319
567
|
onClick,
|
|
320
568
|
style
|
|
321
569
|
}) {
|
|
570
|
+
const resolvedColor = strokeColor ?? "#FFFF00";
|
|
322
571
|
const thickness = 2 * scale;
|
|
323
572
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
|
|
324
573
|
"div",
|
|
@@ -346,7 +595,7 @@ function Strikeout({
|
|
|
346
595
|
top: "50%",
|
|
347
596
|
width: "100%",
|
|
348
597
|
height: thickness,
|
|
349
|
-
background:
|
|
598
|
+
background: resolvedColor,
|
|
350
599
|
opacity,
|
|
351
600
|
transform: "translateY(-50%)",
|
|
352
601
|
pointerEvents: "none"
|
|
@@ -358,7 +607,7 @@ function Strikeout({
|
|
|
358
607
|
)) });
|
|
359
608
|
}
|
|
360
609
|
function Squiggly({
|
|
361
|
-
|
|
610
|
+
strokeColor,
|
|
362
611
|
opacity = 0.5,
|
|
363
612
|
segmentRects,
|
|
364
613
|
rect,
|
|
@@ -366,11 +615,12 @@ function Squiggly({
|
|
|
366
615
|
onClick,
|
|
367
616
|
style
|
|
368
617
|
}) {
|
|
618
|
+
const resolvedColor = strokeColor ?? "#FFFF00";
|
|
369
619
|
const amplitude = 2 * scale;
|
|
370
620
|
const period = 6 * scale;
|
|
371
621
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
|
|
372
622
|
<path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
|
|
373
|
-
fill="none" stroke="${
|
|
623
|
+
fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
|
|
374
624
|
</svg>`;
|
|
375
625
|
const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
|
|
376
626
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
|
|
@@ -413,7 +663,7 @@ function Squiggly({
|
|
|
413
663
|
}
|
|
414
664
|
function Ink({
|
|
415
665
|
isSelected,
|
|
416
|
-
|
|
666
|
+
strokeColor,
|
|
417
667
|
opacity = 1,
|
|
418
668
|
strokeWidth,
|
|
419
669
|
inkList,
|
|
@@ -421,6 +671,7 @@ function Ink({
|
|
|
421
671
|
scale,
|
|
422
672
|
onClick
|
|
423
673
|
}) {
|
|
674
|
+
const resolvedColor = strokeColor ?? "#000000";
|
|
424
675
|
const paths = useMemo(() => {
|
|
425
676
|
return inkList.map(({ points }) => {
|
|
426
677
|
let d = "";
|
|
@@ -459,7 +710,7 @@ function Ink({
|
|
|
459
710
|
style: {
|
|
460
711
|
cursor: isSelected ? "move" : "pointer",
|
|
461
712
|
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
462
|
-
stroke:
|
|
713
|
+
stroke: resolvedColor,
|
|
463
714
|
strokeWidth,
|
|
464
715
|
strokeLinecap: "round",
|
|
465
716
|
strokeLinejoin: "round"
|
|
@@ -997,7 +1248,7 @@ function FreeText({
|
|
|
997
1248
|
flexDirection: "column",
|
|
998
1249
|
justifyContent: annotation.object.verticalAlign === PdfVerticalAlignment.Top ? "flex-start" : annotation.object.verticalAlign === PdfVerticalAlignment.Middle ? "center" : "flex-end",
|
|
999
1250
|
display: "flex",
|
|
1000
|
-
backgroundColor: annotation.object.backgroundColor,
|
|
1251
|
+
backgroundColor: annotation.object.color ?? annotation.object.backgroundColor,
|
|
1001
1252
|
opacity: annotation.object.opacity,
|
|
1002
1253
|
width: needsComp ? `${invScalePercent}%` : "100%",
|
|
1003
1254
|
height: needsComp ? `${invScalePercent}%` : "100%",
|
|
@@ -1110,26 +1361,123 @@ function Stamp({
|
|
|
1110
1361
|
}
|
|
1111
1362
|
);
|
|
1112
1363
|
}
|
|
1364
|
+
function Link({
|
|
1365
|
+
isSelected,
|
|
1366
|
+
strokeColor = "#0000FF",
|
|
1367
|
+
strokeWidth = 2,
|
|
1368
|
+
strokeStyle = PdfAnnotationBorderStyle.UNDERLINE,
|
|
1369
|
+
strokeDashArray,
|
|
1370
|
+
rect,
|
|
1371
|
+
scale,
|
|
1372
|
+
onClick,
|
|
1373
|
+
hasIRT = false
|
|
1374
|
+
}) {
|
|
1375
|
+
const { width, height } = useMemo(() => {
|
|
1376
|
+
return {
|
|
1377
|
+
width: rect.size.width,
|
|
1378
|
+
height: rect.size.height
|
|
1379
|
+
};
|
|
1380
|
+
}, [rect]);
|
|
1381
|
+
const svgWidth = width * scale;
|
|
1382
|
+
const svgHeight = height * scale;
|
|
1383
|
+
const dashArray = useMemo(() => {
|
|
1384
|
+
if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {
|
|
1385
|
+
return (strokeDashArray == null ? void 0 : strokeDashArray.join(",")) ?? `${strokeWidth * 3},${strokeWidth}`;
|
|
1386
|
+
}
|
|
1387
|
+
return void 0;
|
|
1388
|
+
}, [strokeStyle, strokeDashArray, strokeWidth]);
|
|
1389
|
+
const isUnderline2 = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
|
|
1390
|
+
return /* @__PURE__ */ jsxs(
|
|
1391
|
+
"svg",
|
|
1392
|
+
{
|
|
1393
|
+
style: {
|
|
1394
|
+
position: "absolute",
|
|
1395
|
+
width: svgWidth,
|
|
1396
|
+
height: svgHeight,
|
|
1397
|
+
pointerEvents: "none",
|
|
1398
|
+
zIndex: 2
|
|
1399
|
+
},
|
|
1400
|
+
width: svgWidth,
|
|
1401
|
+
height: svgHeight,
|
|
1402
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1403
|
+
children: [
|
|
1404
|
+
/* @__PURE__ */ jsx(
|
|
1405
|
+
"rect",
|
|
1406
|
+
{
|
|
1407
|
+
x: 0,
|
|
1408
|
+
y: 0,
|
|
1409
|
+
width,
|
|
1410
|
+
height,
|
|
1411
|
+
fill: "transparent",
|
|
1412
|
+
onPointerDown: hasIRT ? void 0 : onClick,
|
|
1413
|
+
onTouchStart: hasIRT ? void 0 : onClick,
|
|
1414
|
+
style: {
|
|
1415
|
+
cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
|
|
1416
|
+
pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
),
|
|
1420
|
+
isUnderline2 ? (
|
|
1421
|
+
// Underline style: line at bottom of rect
|
|
1422
|
+
/* @__PURE__ */ jsx(
|
|
1423
|
+
"line",
|
|
1424
|
+
{
|
|
1425
|
+
x1: 1,
|
|
1426
|
+
y1: height - 1,
|
|
1427
|
+
x2: width - 1,
|
|
1428
|
+
y2: height - 1,
|
|
1429
|
+
stroke: strokeColor,
|
|
1430
|
+
strokeWidth,
|
|
1431
|
+
strokeDasharray: dashArray,
|
|
1432
|
+
style: {
|
|
1433
|
+
pointerEvents: "none"
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
)
|
|
1437
|
+
) : (
|
|
1438
|
+
// Solid/Dashed style: rectangle border
|
|
1439
|
+
/* @__PURE__ */ jsx(
|
|
1440
|
+
"rect",
|
|
1441
|
+
{
|
|
1442
|
+
x: strokeWidth / 2,
|
|
1443
|
+
y: strokeWidth / 2,
|
|
1444
|
+
width: Math.max(width - strokeWidth, 0),
|
|
1445
|
+
height: Math.max(height - strokeWidth, 0),
|
|
1446
|
+
fill: "transparent",
|
|
1447
|
+
stroke: strokeColor,
|
|
1448
|
+
strokeWidth,
|
|
1449
|
+
strokeDasharray: dashArray,
|
|
1450
|
+
style: {
|
|
1451
|
+
pointerEvents: "none"
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
)
|
|
1455
|
+
)
|
|
1456
|
+
]
|
|
1457
|
+
}
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1113
1460
|
function Annotations(annotationsProps) {
|
|
1114
|
-
const { documentId, pageIndex, scale, selectionMenu } = annotationsProps;
|
|
1461
|
+
const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
|
|
1115
1462
|
const { provides: annotationCapability } = useAnnotationCapability();
|
|
1116
1463
|
const { provides: selectionProvides } = useSelectionCapability();
|
|
1117
1464
|
const [annotations, setAnnotations] = useState([]);
|
|
1118
1465
|
const { register } = usePointerHandlers({ documentId, pageIndex });
|
|
1119
|
-
const [
|
|
1466
|
+
const [allSelectedIds, setAllSelectedIds] = useState([]);
|
|
1120
1467
|
const [editingId, setEditingId] = useState(null);
|
|
1121
1468
|
const annotationProvides = useMemo(
|
|
1122
1469
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
1123
1470
|
[annotationCapability, documentId]
|
|
1124
1471
|
);
|
|
1472
|
+
const isMultiSelected = allSelectedIds.length > 1;
|
|
1125
1473
|
useEffect(() => {
|
|
1126
1474
|
if (annotationProvides) {
|
|
1127
1475
|
const currentState = annotationProvides.getState();
|
|
1128
1476
|
setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
|
|
1129
|
-
|
|
1477
|
+
setAllSelectedIds(getSelectedAnnotationIds(currentState));
|
|
1130
1478
|
return annotationProvides.onStateChange((state) => {
|
|
1131
1479
|
setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
|
|
1132
|
-
|
|
1480
|
+
setAllSelectedIds(getSelectedAnnotationIds(state));
|
|
1133
1481
|
});
|
|
1134
1482
|
}
|
|
1135
1483
|
}, [annotationProvides, pageIndex]);
|
|
@@ -1148,8 +1496,13 @@ function Annotations(annotationsProps) {
|
|
|
1148
1496
|
(e, annotation) => {
|
|
1149
1497
|
e.stopPropagation();
|
|
1150
1498
|
if (annotationProvides && selectionProvides) {
|
|
1151
|
-
annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
|
|
1152
1499
|
selectionProvides.clear();
|
|
1500
|
+
const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
|
|
1501
|
+
if (isModifierPressed) {
|
|
1502
|
+
annotationProvides.toggleSelection(pageIndex, annotation.object.id);
|
|
1503
|
+
} else {
|
|
1504
|
+
annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
|
|
1505
|
+
}
|
|
1153
1506
|
if (annotation.object.id !== editingId) {
|
|
1154
1507
|
setEditingId(null);
|
|
1155
1508
|
}
|
|
@@ -1157,369 +1510,467 @@ function Annotations(annotationsProps) {
|
|
|
1157
1510
|
},
|
|
1158
1511
|
[annotationProvides, selectionProvides, editingId, pageIndex]
|
|
1159
1512
|
);
|
|
1513
|
+
const handleLinkClick = useCallback(
|
|
1514
|
+
(e, annotation) => {
|
|
1515
|
+
e.stopPropagation();
|
|
1516
|
+
if (!annotationProvides || !selectionProvides) return;
|
|
1517
|
+
selectionProvides.clear();
|
|
1518
|
+
if (annotation.object.inReplyToId) {
|
|
1519
|
+
const parentId = annotation.object.inReplyToId;
|
|
1520
|
+
const parent = annotations.find((a) => a.object.id === parentId);
|
|
1521
|
+
if (parent) {
|
|
1522
|
+
annotationProvides.selectAnnotation(parent.object.pageIndex, parentId);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
|
|
1527
|
+
},
|
|
1528
|
+
[annotationProvides, selectionProvides, annotations, pageIndex]
|
|
1529
|
+
);
|
|
1160
1530
|
useEffect(() => {
|
|
1161
1531
|
return register(handlers, {
|
|
1162
1532
|
documentId
|
|
1163
1533
|
});
|
|
1164
1534
|
}, [register, handlers]);
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
if (
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
scale,
|
|
1218
|
-
onClick: (e) => handleClick(e, annotation)
|
|
1219
|
-
}
|
|
1220
|
-
)
|
|
1221
|
-
},
|
|
1222
|
-
annotation.object.id
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
if (isCircle(annotation)) {
|
|
1226
|
-
return /* @__PURE__ */ jsx(
|
|
1227
|
-
AnnotationContainer,
|
|
1228
|
-
{
|
|
1229
|
-
trackedAnnotation: annotation,
|
|
1230
|
-
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,
|
|
1242
|
-
{
|
|
1243
|
-
...obj,
|
|
1244
|
-
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)
|
|
1535
|
+
const selectedAnnotationsOnPage = useMemo(() => {
|
|
1536
|
+
return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
|
|
1537
|
+
}, [annotations, allSelectedIds]);
|
|
1538
|
+
const areAllSelectedDraggable = useMemo(() => {
|
|
1539
|
+
if (selectedAnnotationsOnPage.length < 2) return false;
|
|
1540
|
+
return selectedAnnotationsOnPage.every((ta) => {
|
|
1541
|
+
const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(ta.object);
|
|
1542
|
+
return (tool == null ? void 0 : tool.interaction.isGroupDraggable) ?? (tool == null ? void 0 : tool.interaction.isDraggable) ?? true;
|
|
1543
|
+
});
|
|
1544
|
+
}, [selectedAnnotationsOnPage, annotationProvides]);
|
|
1545
|
+
const areAllSelectedResizable = useMemo(() => {
|
|
1546
|
+
if (selectedAnnotationsOnPage.length < 2) return false;
|
|
1547
|
+
return selectedAnnotationsOnPage.every((ta) => {
|
|
1548
|
+
const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(ta.object);
|
|
1549
|
+
return (tool == null ? void 0 : tool.interaction.isGroupResizable) ?? (tool == null ? void 0 : tool.interaction.isResizable) ?? true;
|
|
1550
|
+
});
|
|
1551
|
+
}, [selectedAnnotationsOnPage, annotationProvides]);
|
|
1552
|
+
const allSelectedOnSamePage = useMemo(() => {
|
|
1553
|
+
if (!annotationProvides) return false;
|
|
1554
|
+
const allSelected = annotationProvides.getSelectedAnnotations();
|
|
1555
|
+
return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);
|
|
1556
|
+
}, [annotationProvides, pageIndex, allSelectedIds]);
|
|
1557
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1558
|
+
annotations.map((annotation) => {
|
|
1559
|
+
const isSelected = allSelectedIds.includes(annotation.object.id);
|
|
1560
|
+
const isEditing = editingId === annotation.object.id;
|
|
1561
|
+
const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
|
|
1562
|
+
if (isInk(annotation)) {
|
|
1563
|
+
return /* @__PURE__ */ jsx(
|
|
1564
|
+
AnnotationContainer,
|
|
1565
|
+
{
|
|
1566
|
+
trackedAnnotation: annotation,
|
|
1567
|
+
isSelected,
|
|
1568
|
+
isMultiSelected,
|
|
1569
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1570
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1571
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1572
|
+
selectionMenu,
|
|
1573
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1574
|
+
style: {
|
|
1575
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1576
|
+
},
|
|
1577
|
+
...annotationsProps,
|
|
1578
|
+
children: (obj) => /* @__PURE__ */ jsx(
|
|
1579
|
+
Ink,
|
|
1580
|
+
{
|
|
1581
|
+
...obj,
|
|
1582
|
+
isSelected,
|
|
1583
|
+
scale,
|
|
1584
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1585
|
+
}
|
|
1586
|
+
)
|
|
1267
1587
|
},
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1588
|
+
annotation.object.id
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
if (isSquare(annotation)) {
|
|
1592
|
+
return /* @__PURE__ */ jsx(
|
|
1593
|
+
AnnotationContainer,
|
|
1594
|
+
{
|
|
1595
|
+
trackedAnnotation: annotation,
|
|
1596
|
+
isSelected,
|
|
1597
|
+
isMultiSelected,
|
|
1598
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1599
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1600
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1601
|
+
selectionMenu,
|
|
1602
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1603
|
+
style: {
|
|
1604
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1605
|
+
},
|
|
1606
|
+
...annotationsProps,
|
|
1607
|
+
children: (obj) => /* @__PURE__ */ jsx(
|
|
1608
|
+
Square,
|
|
1609
|
+
{
|
|
1610
|
+
...obj,
|
|
1611
|
+
isSelected,
|
|
1612
|
+
scale,
|
|
1613
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1614
|
+
}
|
|
1615
|
+
)
|
|
1288
1616
|
},
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1617
|
+
annotation.object.id
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
if (isCircle(annotation)) {
|
|
1621
|
+
return /* @__PURE__ */ jsx(
|
|
1622
|
+
AnnotationContainer,
|
|
1623
|
+
{
|
|
1624
|
+
trackedAnnotation: annotation,
|
|
1625
|
+
isSelected,
|
|
1626
|
+
isMultiSelected,
|
|
1627
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1628
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1629
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1630
|
+
selectionMenu,
|
|
1631
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1632
|
+
style: {
|
|
1633
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1634
|
+
},
|
|
1635
|
+
...annotationsProps,
|
|
1636
|
+
children: (obj) => /* @__PURE__ */ jsx(
|
|
1637
|
+
Circle,
|
|
1638
|
+
{
|
|
1639
|
+
...obj,
|
|
1640
|
+
isSelected,
|
|
1641
|
+
scale,
|
|
1642
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1643
|
+
}
|
|
1644
|
+
)
|
|
1309
1645
|
},
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1646
|
+
annotation.object.id
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
if (isUnderline(annotation)) {
|
|
1650
|
+
return /* @__PURE__ */ jsx(
|
|
1651
|
+
AnnotationContainer,
|
|
1652
|
+
{
|
|
1653
|
+
trackedAnnotation: annotation,
|
|
1654
|
+
isSelected,
|
|
1655
|
+
isMultiSelected,
|
|
1656
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1657
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1658
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1659
|
+
selectionMenu,
|
|
1660
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1661
|
+
zIndex: 0,
|
|
1662
|
+
style: {
|
|
1663
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1664
|
+
},
|
|
1665
|
+
...annotationsProps,
|
|
1666
|
+
children: (obj) => /* @__PURE__ */ jsx(Underline, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
|
|
1330
1667
|
},
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
],
|
|
1353
|
-
transformAnnotation: (annotation2, vertices) => {
|
|
1354
|
-
return {
|
|
1355
|
-
...annotation2,
|
|
1356
|
-
linePoints: {
|
|
1357
|
-
start: vertices[0],
|
|
1358
|
-
end: vertices[1]
|
|
1359
|
-
}
|
|
1360
|
-
};
|
|
1361
|
-
}
|
|
1668
|
+
annotation.object.id
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1671
|
+
if (isStrikeout(annotation)) {
|
|
1672
|
+
return /* @__PURE__ */ jsx(
|
|
1673
|
+
AnnotationContainer,
|
|
1674
|
+
{
|
|
1675
|
+
trackedAnnotation: annotation,
|
|
1676
|
+
isSelected,
|
|
1677
|
+
isMultiSelected,
|
|
1678
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1679
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1680
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1681
|
+
selectionMenu,
|
|
1682
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1683
|
+
zIndex: 0,
|
|
1684
|
+
style: {
|
|
1685
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1686
|
+
},
|
|
1687
|
+
...annotationsProps,
|
|
1688
|
+
children: (obj) => /* @__PURE__ */ jsx(Strikeout, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
|
|
1362
1689
|
},
|
|
1363
|
-
|
|
1364
|
-
|
|
1690
|
+
annotation.object.id
|
|
1691
|
+
);
|
|
1692
|
+
}
|
|
1693
|
+
if (isSquiggly(annotation)) {
|
|
1694
|
+
return /* @__PURE__ */ jsx(
|
|
1695
|
+
AnnotationContainer,
|
|
1696
|
+
{
|
|
1697
|
+
trackedAnnotation: annotation,
|
|
1698
|
+
isSelected,
|
|
1699
|
+
isMultiSelected,
|
|
1700
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1701
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1702
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1703
|
+
selectionMenu,
|
|
1704
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1705
|
+
zIndex: 0,
|
|
1706
|
+
style: {
|
|
1707
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1708
|
+
},
|
|
1709
|
+
...annotationsProps,
|
|
1710
|
+
children: (obj) => /* @__PURE__ */ jsx(Squiggly, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
|
|
1365
1711
|
},
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
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
|
-
}
|
|
1712
|
+
annotation.object.id
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
if (isHighlight(annotation)) {
|
|
1716
|
+
return /* @__PURE__ */ jsx(
|
|
1717
|
+
AnnotationContainer,
|
|
1718
|
+
{
|
|
1719
|
+
trackedAnnotation: annotation,
|
|
1720
|
+
isSelected,
|
|
1721
|
+
isMultiSelected,
|
|
1722
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1723
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1724
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1725
|
+
selectionMenu,
|
|
1726
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1727
|
+
zIndex: 0,
|
|
1728
|
+
style: {
|
|
1729
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
|
|
1730
|
+
},
|
|
1731
|
+
...annotationsProps,
|
|
1732
|
+
children: (obj) => /* @__PURE__ */ jsx(Highlight, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
|
|
1399
1733
|
},
|
|
1400
|
-
|
|
1401
|
-
|
|
1734
|
+
annotation.object.id
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
if (isLine(annotation)) {
|
|
1738
|
+
return /* @__PURE__ */ jsx(
|
|
1739
|
+
AnnotationContainer,
|
|
1740
|
+
{
|
|
1741
|
+
trackedAnnotation: annotation,
|
|
1742
|
+
isSelected,
|
|
1743
|
+
isMultiSelected,
|
|
1744
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1745
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1746
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1747
|
+
selectionMenu,
|
|
1748
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1749
|
+
vertexConfig: {
|
|
1750
|
+
extractVertices: (annotation2) => [
|
|
1751
|
+
annotation2.linePoints.start,
|
|
1752
|
+
annotation2.linePoints.end
|
|
1753
|
+
],
|
|
1754
|
+
transformAnnotation: (annotation2, vertices) => {
|
|
1755
|
+
return {
|
|
1756
|
+
...annotation2,
|
|
1757
|
+
linePoints: {
|
|
1758
|
+
start: vertices[0],
|
|
1759
|
+
end: vertices[1]
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
},
|
|
1764
|
+
style: {
|
|
1765
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1766
|
+
},
|
|
1767
|
+
...annotationsProps,
|
|
1768
|
+
children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
|
|
1769
|
+
Line,
|
|
1770
|
+
{
|
|
1771
|
+
...obj,
|
|
1772
|
+
isSelected,
|
|
1773
|
+
scale,
|
|
1774
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1775
|
+
}
|
|
1776
|
+
) })
|
|
1402
1777
|
},
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1778
|
+
annotation.object.id
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
if (isPolyline(annotation)) {
|
|
1782
|
+
return /* @__PURE__ */ jsx(
|
|
1783
|
+
AnnotationContainer,
|
|
1784
|
+
{
|
|
1785
|
+
trackedAnnotation: annotation,
|
|
1786
|
+
isSelected,
|
|
1787
|
+
isMultiSelected,
|
|
1788
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1789
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1790
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1791
|
+
selectionMenu,
|
|
1792
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1793
|
+
vertexConfig: {
|
|
1794
|
+
extractVertices: (annotation2) => annotation2.vertices,
|
|
1795
|
+
transformAnnotation: (annotation2, vertices) => {
|
|
1796
|
+
return {
|
|
1797
|
+
...annotation2,
|
|
1798
|
+
vertices
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
},
|
|
1802
|
+
style: {
|
|
1803
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1804
|
+
},
|
|
1805
|
+
...annotationsProps,
|
|
1806
|
+
children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
|
|
1807
|
+
Polyline,
|
|
1808
|
+
{
|
|
1809
|
+
...obj,
|
|
1810
|
+
isSelected,
|
|
1811
|
+
scale,
|
|
1812
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1813
|
+
}
|
|
1814
|
+
) })
|
|
1436
1815
|
},
|
|
1437
|
-
|
|
1438
|
-
|
|
1816
|
+
annotation.object.id
|
|
1817
|
+
);
|
|
1818
|
+
}
|
|
1819
|
+
if (isPolygon(annotation)) {
|
|
1820
|
+
return /* @__PURE__ */ jsx(
|
|
1821
|
+
AnnotationContainer,
|
|
1822
|
+
{
|
|
1823
|
+
trackedAnnotation: annotation,
|
|
1824
|
+
isSelected,
|
|
1825
|
+
isMultiSelected,
|
|
1826
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1827
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1828
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1829
|
+
selectionMenu,
|
|
1830
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1831
|
+
vertexConfig: {
|
|
1832
|
+
extractVertices: (annotation2) => annotation2.vertices,
|
|
1833
|
+
transformAnnotation: (annotation2, vertices) => {
|
|
1834
|
+
return {
|
|
1835
|
+
...annotation2,
|
|
1836
|
+
vertices
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
style: {
|
|
1841
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1842
|
+
},
|
|
1843
|
+
...annotationsProps,
|
|
1844
|
+
children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
|
|
1845
|
+
Polygon,
|
|
1846
|
+
{
|
|
1847
|
+
...obj,
|
|
1848
|
+
isSelected,
|
|
1849
|
+
scale,
|
|
1850
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1851
|
+
}
|
|
1852
|
+
) })
|
|
1439
1853
|
},
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1854
|
+
annotation.object.id
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
if (isFreeText(annotation)) {
|
|
1858
|
+
return /* @__PURE__ */ jsx(
|
|
1859
|
+
AnnotationContainer,
|
|
1860
|
+
{
|
|
1861
|
+
trackedAnnotation: annotation,
|
|
1862
|
+
isSelected,
|
|
1863
|
+
isMultiSelected,
|
|
1864
|
+
isDraggable: ((tool == null ? void 0 : tool.interaction.isDraggable) ?? true) && !isEditing,
|
|
1865
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1866
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1867
|
+
selectionMenu,
|
|
1868
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1869
|
+
style: {
|
|
1870
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1871
|
+
},
|
|
1872
|
+
onDoubleClick: (e) => {
|
|
1873
|
+
e.stopPropagation();
|
|
1874
|
+
setEditingId(annotation.object.id);
|
|
1875
|
+
},
|
|
1876
|
+
...annotationsProps,
|
|
1877
|
+
children: (object) => /* @__PURE__ */ jsx(
|
|
1878
|
+
FreeText,
|
|
1879
|
+
{
|
|
1880
|
+
isSelected,
|
|
1881
|
+
isEditing,
|
|
1882
|
+
annotation: {
|
|
1883
|
+
...annotation,
|
|
1884
|
+
object
|
|
1885
|
+
},
|
|
1886
|
+
pageIndex,
|
|
1887
|
+
scale,
|
|
1888
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1889
|
+
}
|
|
1890
|
+
)
|
|
1467
1891
|
},
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1892
|
+
annotation.object.id
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
if (isStamp(annotation)) {
|
|
1896
|
+
return /* @__PURE__ */ jsx(
|
|
1897
|
+
AnnotationContainer,
|
|
1898
|
+
{
|
|
1899
|
+
trackedAnnotation: annotation,
|
|
1900
|
+
isSelected,
|
|
1901
|
+
isMultiSelected,
|
|
1902
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1903
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1904
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1905
|
+
selectionMenu,
|
|
1906
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1907
|
+
style: {
|
|
1908
|
+
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1909
|
+
},
|
|
1910
|
+
...annotationsProps,
|
|
1911
|
+
children: (_object) => /* @__PURE__ */ jsx(
|
|
1912
|
+
Stamp,
|
|
1913
|
+
{
|
|
1914
|
+
isSelected,
|
|
1915
|
+
annotation,
|
|
1916
|
+
documentId,
|
|
1917
|
+
pageIndex,
|
|
1918
|
+
scale,
|
|
1919
|
+
onClick: (e) => handleClick(e, annotation)
|
|
1920
|
+
}
|
|
1921
|
+
)
|
|
1471
1922
|
},
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
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)
|
|
1923
|
+
annotation.object.id
|
|
1924
|
+
);
|
|
1925
|
+
}
|
|
1926
|
+
if (isLink(annotation)) {
|
|
1927
|
+
const hasIRT = !!annotation.object.inReplyToId;
|
|
1928
|
+
return /* @__PURE__ */ jsx(
|
|
1929
|
+
AnnotationContainer,
|
|
1930
|
+
{
|
|
1931
|
+
trackedAnnotation: annotation,
|
|
1932
|
+
isSelected,
|
|
1933
|
+
isMultiSelected,
|
|
1934
|
+
isDraggable: false,
|
|
1935
|
+
isResizable: false,
|
|
1936
|
+
lockAspectRatio: false,
|
|
1937
|
+
selectionMenu: hasIRT ? void 0 : selectionMenu,
|
|
1938
|
+
onSelect: (e) => handleLinkClick(e, annotation),
|
|
1939
|
+
...annotationsProps,
|
|
1940
|
+
children: (obj) => /* @__PURE__ */ jsx(
|
|
1941
|
+
Link,
|
|
1942
|
+
{
|
|
1943
|
+
...obj,
|
|
1944
|
+
isSelected,
|
|
1945
|
+
scale,
|
|
1946
|
+
onClick: (e) => handleLinkClick(e, annotation),
|
|
1947
|
+
hasIRT
|
|
1948
|
+
}
|
|
1949
|
+
)
|
|
1504
1950
|
},
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1951
|
+
annotation.object.id
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
return null;
|
|
1955
|
+
}),
|
|
1956
|
+
allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && /* @__PURE__ */ jsx(
|
|
1957
|
+
GroupSelectionBox,
|
|
1958
|
+
{
|
|
1959
|
+
documentId,
|
|
1960
|
+
pageIndex,
|
|
1961
|
+
scale,
|
|
1962
|
+
rotation: annotationsProps.rotation,
|
|
1963
|
+
pageWidth,
|
|
1964
|
+
pageHeight,
|
|
1965
|
+
selectedAnnotations: selectedAnnotationsOnPage,
|
|
1966
|
+
isDraggable: areAllSelectedDraggable,
|
|
1967
|
+
isResizable: areAllSelectedResizable,
|
|
1968
|
+
resizeUI: annotationsProps.resizeUI,
|
|
1969
|
+
selectionOutlineColor: annotationsProps.selectionOutlineColor,
|
|
1970
|
+
groupSelectionMenu: annotationsProps.groupSelectionMenu
|
|
1971
|
+
}
|
|
1972
|
+
)
|
|
1973
|
+
] });
|
|
1523
1974
|
}
|
|
1524
1975
|
function TextMarkup({ documentId, pageIndex, scale }) {
|
|
1525
1976
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
@@ -1556,7 +2007,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
1556
2007
|
children: /* @__PURE__ */ jsx(
|
|
1557
2008
|
Underline,
|
|
1558
2009
|
{
|
|
1559
|
-
|
|
2010
|
+
strokeColor: (_b = activeTool.defaults) == null ? void 0 : _b.strokeColor,
|
|
1560
2011
|
opacity: (_c = activeTool.defaults) == null ? void 0 : _c.opacity,
|
|
1561
2012
|
segmentRects: rects,
|
|
1562
2013
|
scale
|
|
@@ -1577,7 +2028,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
1577
2028
|
children: /* @__PURE__ */ jsx(
|
|
1578
2029
|
Highlight,
|
|
1579
2030
|
{
|
|
1580
|
-
|
|
2031
|
+
strokeColor: (_e = activeTool.defaults) == null ? void 0 : _e.strokeColor,
|
|
1581
2032
|
opacity: (_f = activeTool.defaults) == null ? void 0 : _f.opacity,
|
|
1582
2033
|
segmentRects: rects,
|
|
1583
2034
|
scale
|
|
@@ -1598,7 +2049,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
1598
2049
|
children: /* @__PURE__ */ jsx(
|
|
1599
2050
|
Strikeout,
|
|
1600
2051
|
{
|
|
1601
|
-
|
|
2052
|
+
strokeColor: (_h = activeTool.defaults) == null ? void 0 : _h.strokeColor,
|
|
1602
2053
|
opacity: (_i = activeTool.defaults) == null ? void 0 : _i.opacity,
|
|
1603
2054
|
segmentRects: rects,
|
|
1604
2055
|
scale
|
|
@@ -1619,7 +2070,7 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
1619
2070
|
children: /* @__PURE__ */ jsx(
|
|
1620
2071
|
Squiggly,
|
|
1621
2072
|
{
|
|
1622
|
-
|
|
2073
|
+
strokeColor: (_k = activeTool.defaults) == null ? void 0 : _k.strokeColor,
|
|
1623
2074
|
opacity: (_l = activeTool.defaults) == null ? void 0 : _l.opacity,
|
|
1624
2075
|
segmentRects: rects,
|
|
1625
2076
|
scale
|
|
@@ -1752,6 +2203,7 @@ function AnnotationLayer({
|
|
|
1752
2203
|
scale: overrideScale,
|
|
1753
2204
|
rotation: overrideRotation,
|
|
1754
2205
|
selectionMenu,
|
|
2206
|
+
groupSelectionMenu,
|
|
1755
2207
|
resizeUI,
|
|
1756
2208
|
vertexUI,
|
|
1757
2209
|
selectionOutlineColor,
|
|
@@ -1784,6 +2236,7 @@ function AnnotationLayer({
|
|
|
1784
2236
|
{
|
|
1785
2237
|
documentId,
|
|
1786
2238
|
selectionMenu,
|
|
2239
|
+
groupSelectionMenu,
|
|
1787
2240
|
pageIndex,
|
|
1788
2241
|
scale: actualScale,
|
|
1789
2242
|
rotation: actualRotation,
|
|
@@ -1803,6 +2256,7 @@ function AnnotationLayer({
|
|
|
1803
2256
|
}
|
|
1804
2257
|
export {
|
|
1805
2258
|
AnnotationLayer,
|
|
2259
|
+
GroupSelectionBox,
|
|
1806
2260
|
useAnnotation,
|
|
1807
2261
|
useAnnotationCapability,
|
|
1808
2262
|
useAnnotationPlugin
|