@embedpdf/plugin-annotation 1.0.15 → 1.0.17
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 +190 -190
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +8 -26
- package/dist/lib/annotation-plugin.d.ts +1 -1
- package/dist/lib/helpers.d.ts +5 -1
- package/dist/lib/selectors.d.ts +29 -7
- package/dist/lib/types.d.ts +18 -19
- package/dist/preact/adapter.d.ts +1 -0
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +137 -87
- 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 +137 -87
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/annotations/circle.d.ts +5 -5
- package/dist/shared-preact/components/annotations/free-text.d.ts +2 -2
- package/dist/shared-preact/components/annotations/ink.d.ts +5 -5
- package/dist/shared-preact/components/annotations/line.d.ts +2 -2
- package/dist/shared-preact/components/annotations/polygon.d.ts +2 -2
- package/dist/shared-preact/components/annotations/polyline.d.ts +2 -2
- package/dist/shared-preact/components/annotations/square.d.ts +5 -5
- package/dist/shared-preact/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-preact/components/counter-rotate-container.d.ts +2 -1
- package/dist/shared-preact/components/text-markup/highlight.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +2 -2
- package/dist/shared-preact/components/text-markup/underline.d.ts +2 -2
- package/dist/shared-preact/hooks/use-drag-resize.d.ts +5 -1
- package/dist/shared-react/components/annotations/circle.d.ts +5 -5
- package/dist/shared-react/components/annotations/free-text.d.ts +2 -2
- package/dist/shared-react/components/annotations/ink.d.ts +5 -5
- package/dist/shared-react/components/annotations/line.d.ts +2 -2
- package/dist/shared-react/components/annotations/polygon.d.ts +2 -2
- package/dist/shared-react/components/annotations/polyline.d.ts +2 -2
- package/dist/shared-react/components/annotations/square.d.ts +5 -5
- package/dist/shared-react/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-react/components/counter-rotate-container.d.ts +2 -1
- package/dist/shared-react/components/text-markup/highlight.d.ts +2 -2
- package/dist/shared-react/components/text-markup/squiggly.d.ts +2 -2
- package/dist/shared-react/components/text-markup/strikeout.d.ts +2 -2
- package/dist/shared-react/components/text-markup/underline.d.ts +2 -2
- package/dist/shared-react/hooks/use-drag-resize.d.ts +5 -1
- package/package.json +14 -9
- package/dist/lib/utils.d.ts +0 -11
package/dist/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { usePlugin, useCapability } from "@embedpdf/core/react";
|
|
2
2
|
import { AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp } from "@embedpdf/plugin-annotation";
|
|
3
3
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
4
|
-
import { restoreOffset, rectEquals, PdfAnnotationBorderStyle, PdfAnnotationSubtype, expandRect, rectFromPoints, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
|
|
4
|
+
import { restoreOffset, rectEquals, PdfAnnotationBorderStyle, PdfAnnotationSubtype, expandRect, rectFromPoints, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, uuidV4 } from "@embedpdf/models";
|
|
5
5
|
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
6
6
|
import { useSelectionCapability } from "@embedpdf/plugin-selection/react";
|
|
7
7
|
import { Fragment, useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from "react";
|
|
@@ -53,7 +53,8 @@ function CounterRotate({ children, ...props }) {
|
|
|
53
53
|
};
|
|
54
54
|
const menuWrapperProps = {
|
|
55
55
|
style: menuWrapperStyle,
|
|
56
|
-
onPointerDown: (e) => e.stopPropagation()
|
|
56
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
57
|
+
onTouchStart: (e) => e.stopPropagation()
|
|
57
58
|
};
|
|
58
59
|
return /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
59
60
|
menuWrapperProps,
|
|
@@ -210,20 +211,16 @@ function useDragResize({
|
|
|
210
211
|
oy = clamp(oy, 0, pageH - h);
|
|
211
212
|
return { origin: { x: ox, y: oy }, size: { width: w, height: h } };
|
|
212
213
|
};
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
e.preventDefault();
|
|
217
|
-
drag.current = "dragging";
|
|
218
|
-
startPos.current = { x: e.clientX, y: e.clientY };
|
|
214
|
+
const beginDrag = (kind, clientX, clientY) => {
|
|
215
|
+
drag.current = kind;
|
|
216
|
+
startPos.current = { x: clientX, y: clientY };
|
|
219
217
|
startRect.current = currentRect;
|
|
220
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
221
218
|
};
|
|
222
|
-
const
|
|
219
|
+
const handleMove = (clientX, clientY) => {
|
|
223
220
|
if (drag.current === "idle" || !startPos.current) return;
|
|
224
221
|
const disp = {
|
|
225
|
-
x:
|
|
226
|
-
y:
|
|
222
|
+
x: clientX - startPos.current.x,
|
|
223
|
+
y: clientY - startPos.current.y
|
|
227
224
|
};
|
|
228
225
|
const { x, y } = restoreOffset(disp, rotation, scale);
|
|
229
226
|
const nextRect = applyDelta(x, y);
|
|
@@ -238,14 +235,8 @@ function useDragResize({
|
|
|
238
235
|
setCurrentRect(patch.rect ?? nextRect);
|
|
239
236
|
setPreviewObject(patch);
|
|
240
237
|
};
|
|
241
|
-
const
|
|
238
|
+
const finishDragInternal = () => {
|
|
242
239
|
if (drag.current === "idle") return;
|
|
243
|
-
if ((e == null ? void 0 : e.currentTarget) && e.pointerId !== void 0) {
|
|
244
|
-
try {
|
|
245
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
246
|
-
} catch {
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
240
|
const usedDir = dir.current || "bottom-right";
|
|
250
241
|
drag.current = "idle";
|
|
251
242
|
let patch = { rect: currentRect };
|
|
@@ -261,16 +252,45 @@ function useDragResize({
|
|
|
261
252
|
dir.current = "none";
|
|
262
253
|
setPreviewObject(null);
|
|
263
254
|
};
|
|
255
|
+
const onPointerDown = (e) => {
|
|
256
|
+
if (!isSelected || !isDraggable) return;
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
beginDrag("dragging", e.clientX, e.clientY);
|
|
260
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
261
|
+
};
|
|
262
|
+
const onPointerMove = (e) => handleMove(e.clientX, e.clientY);
|
|
263
|
+
const onPointerUp = (e) => {
|
|
264
|
+
finishDragInternal();
|
|
265
|
+
if ((e == null ? void 0 : e.currentTarget) && e.pointerId !== void 0) {
|
|
266
|
+
try {
|
|
267
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
268
|
+
} catch {
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
264
272
|
const startResize = (direction) => (e) => {
|
|
265
273
|
if (!isSelected || !isResizable) return;
|
|
266
274
|
e.stopPropagation();
|
|
267
275
|
e.preventDefault();
|
|
268
|
-
drag.current = "resizing";
|
|
269
276
|
dir.current = direction;
|
|
270
|
-
|
|
271
|
-
startRect.current = currentRect;
|
|
277
|
+
beginDrag("resizing", e.clientX, e.clientY);
|
|
272
278
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
273
279
|
};
|
|
280
|
+
const onTouchStart = (e) => {
|
|
281
|
+
if (!isSelected || !isDraggable) return;
|
|
282
|
+
e.stopPropagation();
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
const t = e.touches[0];
|
|
285
|
+
if (!t) return;
|
|
286
|
+
beginDrag("dragging", t.clientX, t.clientY);
|
|
287
|
+
};
|
|
288
|
+
const onTouchMove = (e) => {
|
|
289
|
+
const t = e.touches[0];
|
|
290
|
+
if (!t) return;
|
|
291
|
+
handleMove(t.clientX, t.clientY);
|
|
292
|
+
};
|
|
293
|
+
const onTouchEnd = () => finishDragInternal();
|
|
274
294
|
useEffect(() => {
|
|
275
295
|
drag.current = "idle";
|
|
276
296
|
dir.current = "none";
|
|
@@ -283,7 +303,12 @@ function useDragResize({
|
|
|
283
303
|
onPointerMove,
|
|
284
304
|
onPointerUp,
|
|
285
305
|
onPointerCancel: () => onPointerUp(),
|
|
286
|
-
onLostPointerCapture: () => onPointerUp()
|
|
306
|
+
onLostPointerCapture: () => onPointerUp(),
|
|
307
|
+
/* mobile touch fallback */
|
|
308
|
+
onTouchStart,
|
|
309
|
+
onTouchMove,
|
|
310
|
+
onTouchEnd,
|
|
311
|
+
onTouchCancel: onTouchEnd
|
|
287
312
|
},
|
|
288
313
|
startResize
|
|
289
314
|
};
|
|
@@ -390,7 +415,7 @@ function AnnotationContainer({
|
|
|
390
415
|
setCurrentRect,
|
|
391
416
|
setCurrentVertices,
|
|
392
417
|
setPreviewObject,
|
|
393
|
-
commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.
|
|
418
|
+
commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch)
|
|
394
419
|
});
|
|
395
420
|
useLayoutEffect(() => {
|
|
396
421
|
if (!rectEquals(trackedAnnotation.object.rect, currentRect)) {
|
|
@@ -415,6 +440,7 @@ function AnnotationContainer({
|
|
|
415
440
|
width: `${currentRect.size.width * scale}px`,
|
|
416
441
|
height: `${currentRect.size.height * scale}px`,
|
|
417
442
|
pointerEvents: isSelected ? "auto" : "none",
|
|
443
|
+
touchAction: isSelected ? "auto" : "none",
|
|
418
444
|
cursor: isSelected && isDraggable ? "move" : "default",
|
|
419
445
|
...isSelected && {
|
|
420
446
|
zIndex: 3
|
|
@@ -448,7 +474,7 @@ function AnnotationContainer({
|
|
|
448
474
|
rect: currentRect,
|
|
449
475
|
vertices: v
|
|
450
476
|
});
|
|
451
|
-
annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.
|
|
477
|
+
annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch);
|
|
452
478
|
}
|
|
453
479
|
}
|
|
454
480
|
}
|
|
@@ -495,7 +521,8 @@ function Highlight({
|
|
|
495
521
|
return /* @__PURE__ */ jsx(Fragment$1, { children: rects.map((b, i) => /* @__PURE__ */ jsx(
|
|
496
522
|
"div",
|
|
497
523
|
{
|
|
498
|
-
|
|
524
|
+
onPointerDown: onClick,
|
|
525
|
+
onTouchStart: onClick,
|
|
499
526
|
style: {
|
|
500
527
|
position: "absolute",
|
|
501
528
|
left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
|
|
@@ -528,7 +555,8 @@ function Underline({
|
|
|
528
555
|
return /* @__PURE__ */ jsx(Fragment$1, { children: rects.map((r, i) => /* @__PURE__ */ jsx(
|
|
529
556
|
"div",
|
|
530
557
|
{
|
|
531
|
-
|
|
558
|
+
onPointerDown: onClick,
|
|
559
|
+
onTouchStart: onClick,
|
|
532
560
|
style: {
|
|
533
561
|
position: "absolute",
|
|
534
562
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -575,7 +603,8 @@ function Strikeout({
|
|
|
575
603
|
return /* @__PURE__ */ jsx(Fragment$1, { children: rects.map((r, i) => /* @__PURE__ */ jsx(
|
|
576
604
|
"div",
|
|
577
605
|
{
|
|
578
|
-
|
|
606
|
+
onPointerDown: onClick,
|
|
607
|
+
onTouchStart: onClick,
|
|
579
608
|
style: {
|
|
580
609
|
position: "absolute",
|
|
581
610
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -629,7 +658,8 @@ function Squiggly({
|
|
|
629
658
|
return /* @__PURE__ */ jsx(Fragment$1, { children: rects.map((r, i) => /* @__PURE__ */ jsx(
|
|
630
659
|
"div",
|
|
631
660
|
{
|
|
632
|
-
|
|
661
|
+
onPointerDown: onClick,
|
|
662
|
+
onTouchStart: onClick,
|
|
633
663
|
style: {
|
|
634
664
|
position: "absolute",
|
|
635
665
|
left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
|
|
@@ -665,14 +695,14 @@ function Squiggly({
|
|
|
665
695
|
)) });
|
|
666
696
|
}
|
|
667
697
|
function Ink({
|
|
698
|
+
isSelected,
|
|
668
699
|
color = "#000000",
|
|
669
700
|
opacity = 1,
|
|
670
701
|
strokeWidth,
|
|
671
702
|
inkList,
|
|
672
703
|
rect,
|
|
673
704
|
scale,
|
|
674
|
-
onClick
|
|
675
|
-
cursor
|
|
705
|
+
onClick
|
|
676
706
|
}) {
|
|
677
707
|
const paths = useMemo(() => {
|
|
678
708
|
return inkList.map(({ points }) => {
|
|
@@ -707,10 +737,11 @@ function Ink({
|
|
|
707
737
|
d,
|
|
708
738
|
fill: "none",
|
|
709
739
|
opacity,
|
|
710
|
-
|
|
740
|
+
onPointerDown: onClick,
|
|
741
|
+
onTouchStart: onClick,
|
|
711
742
|
style: {
|
|
712
|
-
cursor,
|
|
713
|
-
pointerEvents: "visibleStroke",
|
|
743
|
+
cursor: isSelected ? "move" : "pointer",
|
|
744
|
+
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
714
745
|
stroke: color,
|
|
715
746
|
strokeWidth,
|
|
716
747
|
strokeLinecap: "round",
|
|
@@ -723,6 +754,7 @@ function Ink({
|
|
|
723
754
|
);
|
|
724
755
|
}
|
|
725
756
|
function Square({
|
|
757
|
+
isSelected,
|
|
726
758
|
color = "#000000",
|
|
727
759
|
strokeColor,
|
|
728
760
|
opacity = 1,
|
|
@@ -731,8 +763,7 @@ function Square({
|
|
|
731
763
|
strokeDashArray,
|
|
732
764
|
rect,
|
|
733
765
|
scale,
|
|
734
|
-
onClick
|
|
735
|
-
cursor
|
|
766
|
+
onClick
|
|
736
767
|
}) {
|
|
737
768
|
const { width, height, x, y } = useMemo(() => {
|
|
738
769
|
const outerW = rect.size.width;
|
|
@@ -770,10 +801,11 @@ function Square({
|
|
|
770
801
|
height,
|
|
771
802
|
fill: color,
|
|
772
803
|
opacity,
|
|
773
|
-
|
|
804
|
+
onPointerDown: onClick,
|
|
805
|
+
onTouchStart: onClick,
|
|
774
806
|
style: {
|
|
775
|
-
cursor,
|
|
776
|
-
pointerEvents: color === "transparent" ? "visibleStroke" : "visible",
|
|
807
|
+
cursor: isSelected ? "move" : "pointer",
|
|
808
|
+
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
777
809
|
stroke: strokeColor ?? color,
|
|
778
810
|
strokeWidth,
|
|
779
811
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
@@ -795,7 +827,7 @@ function Circle({
|
|
|
795
827
|
rect,
|
|
796
828
|
scale,
|
|
797
829
|
onClick,
|
|
798
|
-
|
|
830
|
+
isSelected
|
|
799
831
|
}) {
|
|
800
832
|
const { width, height, cx, cy, rx, ry } = useMemo(() => {
|
|
801
833
|
const outerW = rect.size.width;
|
|
@@ -836,10 +868,11 @@ function Circle({
|
|
|
836
868
|
ry,
|
|
837
869
|
fill: color,
|
|
838
870
|
opacity,
|
|
839
|
-
|
|
871
|
+
onPointerDown: onClick,
|
|
872
|
+
onTouchStart: onClick,
|
|
840
873
|
style: {
|
|
841
|
-
cursor,
|
|
842
|
-
pointerEvents: color === "transparent" ? "visibleStroke" : "visible",
|
|
874
|
+
cursor: isSelected ? "move" : "pointer",
|
|
875
|
+
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
843
876
|
stroke: strokeColor ?? color,
|
|
844
877
|
strokeWidth,
|
|
845
878
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
@@ -947,10 +980,11 @@ function Line({
|
|
|
947
980
|
x2,
|
|
948
981
|
y2,
|
|
949
982
|
opacity,
|
|
950
|
-
|
|
983
|
+
onPointerDown: onClick,
|
|
984
|
+
onTouchStart: onClick,
|
|
951
985
|
style: {
|
|
952
986
|
cursor: isSelected ? "move" : "pointer",
|
|
953
|
-
pointerEvents: "visibleStroke",
|
|
987
|
+
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
954
988
|
stroke: strokeColor,
|
|
955
989
|
strokeWidth,
|
|
956
990
|
strokeLinecap: "butt",
|
|
@@ -965,13 +999,14 @@ function Line({
|
|
|
965
999
|
{
|
|
966
1000
|
d: endings.start.d,
|
|
967
1001
|
transform: endings.start.transform,
|
|
968
|
-
|
|
1002
|
+
onPointerDown: onClick,
|
|
1003
|
+
onTouchStart: onClick,
|
|
969
1004
|
stroke: strokeColor,
|
|
970
1005
|
style: {
|
|
971
1006
|
cursor: isSelected ? "move" : "pointer",
|
|
972
1007
|
strokeWidth,
|
|
973
1008
|
strokeLinecap: "butt",
|
|
974
|
-
pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
|
|
1009
|
+
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
975
1010
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
976
1011
|
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
977
1012
|
}
|
|
@@ -985,12 +1020,13 @@ function Line({
|
|
|
985
1020
|
d: endings.end.d,
|
|
986
1021
|
transform: endings.end.transform,
|
|
987
1022
|
stroke: strokeColor,
|
|
988
|
-
|
|
1023
|
+
onPointerDown: onClick,
|
|
1024
|
+
onTouchStart: onClick,
|
|
989
1025
|
style: {
|
|
990
1026
|
cursor: isSelected ? "move" : "pointer",
|
|
991
1027
|
strokeWidth,
|
|
992
1028
|
strokeLinecap: "butt",
|
|
993
|
-
pointerEvents: endings.end.filled ? "visible" : "visibleStroke",
|
|
1029
|
+
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
994
1030
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
995
1031
|
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
996
1032
|
}
|
|
@@ -1066,14 +1102,15 @@ function Polyline({
|
|
|
1066
1102
|
"path",
|
|
1067
1103
|
{
|
|
1068
1104
|
d: pathData,
|
|
1069
|
-
|
|
1105
|
+
onPointerDown: onClick,
|
|
1106
|
+
onTouchStart: onClick,
|
|
1070
1107
|
opacity,
|
|
1071
1108
|
style: {
|
|
1072
1109
|
fill: "none",
|
|
1073
1110
|
stroke: strokeColor ?? color,
|
|
1074
1111
|
strokeWidth,
|
|
1075
1112
|
cursor: isSelected ? "move" : "pointer",
|
|
1076
|
-
pointerEvents: "visibleStroke",
|
|
1113
|
+
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
1077
1114
|
strokeLinecap: "butt",
|
|
1078
1115
|
strokeLinejoin: "miter"
|
|
1079
1116
|
}
|
|
@@ -1086,11 +1123,12 @@ function Polyline({
|
|
|
1086
1123
|
transform: endings.start.transform,
|
|
1087
1124
|
stroke: strokeColor,
|
|
1088
1125
|
fill: endings.start.filled ? color : "none",
|
|
1089
|
-
|
|
1126
|
+
onPointerDown: onClick,
|
|
1127
|
+
onTouchStart: onClick,
|
|
1090
1128
|
style: {
|
|
1091
1129
|
cursor: isSelected ? "move" : "pointer",
|
|
1092
1130
|
strokeWidth,
|
|
1093
|
-
pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
|
|
1131
|
+
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1094
1132
|
strokeLinecap: "butt"
|
|
1095
1133
|
}
|
|
1096
1134
|
}
|
|
@@ -1102,11 +1140,12 @@ function Polyline({
|
|
|
1102
1140
|
transform: endings.end.transform,
|
|
1103
1141
|
stroke: strokeColor,
|
|
1104
1142
|
fill: endings.end.filled ? color : "none",
|
|
1105
|
-
|
|
1143
|
+
onPointerDown: onClick,
|
|
1144
|
+
onTouchStart: onClick,
|
|
1106
1145
|
style: {
|
|
1107
1146
|
cursor: isSelected ? "move" : "pointer",
|
|
1108
1147
|
strokeWidth,
|
|
1109
|
-
pointerEvents: endings.end.filled ? "visible" : "visibleStroke",
|
|
1148
|
+
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1110
1149
|
strokeLinecap: "butt"
|
|
1111
1150
|
}
|
|
1112
1151
|
}
|
|
@@ -1157,14 +1196,15 @@ function Polygon({
|
|
|
1157
1196
|
"path",
|
|
1158
1197
|
{
|
|
1159
1198
|
d: pathData,
|
|
1160
|
-
|
|
1199
|
+
onPointerDown: onClick,
|
|
1200
|
+
onTouchStart: onClick,
|
|
1161
1201
|
opacity,
|
|
1162
1202
|
style: {
|
|
1163
1203
|
fill: color,
|
|
1164
1204
|
stroke: strokeColor ?? color,
|
|
1165
1205
|
strokeWidth,
|
|
1166
1206
|
cursor: isSelected ? "move" : "pointer",
|
|
1167
|
-
pointerEvents: color === "transparent" ? "visibleStroke" : "visible",
|
|
1207
|
+
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
1168
1208
|
strokeLinecap: "butt",
|
|
1169
1209
|
strokeLinejoin: "miter",
|
|
1170
1210
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
@@ -1252,7 +1292,7 @@ function FreeText({
|
|
|
1252
1292
|
const handleBlur = () => {
|
|
1253
1293
|
if (!annotationProvides) return;
|
|
1254
1294
|
if (!editorRef.current) return;
|
|
1255
|
-
annotationProvides.updateAnnotation(pageIndex, annotation.
|
|
1295
|
+
annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
|
|
1256
1296
|
contents: editorRef.current.innerText
|
|
1257
1297
|
});
|
|
1258
1298
|
};
|
|
@@ -1268,6 +1308,7 @@ function FreeText({
|
|
|
1268
1308
|
zIndex: 2
|
|
1269
1309
|
},
|
|
1270
1310
|
onPointerDown: onClick,
|
|
1311
|
+
onTouchStart: onClick,
|
|
1271
1312
|
children: /* @__PURE__ */ jsx(
|
|
1272
1313
|
"span",
|
|
1273
1314
|
{
|
|
@@ -1366,11 +1407,12 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
|
|
|
1366
1407
|
pointerEvents: isSelected ? "none" : "auto"
|
|
1367
1408
|
},
|
|
1368
1409
|
onPointerDown: onClick,
|
|
1369
|
-
|
|
1410
|
+
onTouchStart: onClick,
|
|
1411
|
+
children: /* @__PURE__ */ jsx(
|
|
1370
1412
|
RenderAnnotation,
|
|
1371
1413
|
{
|
|
1372
1414
|
pageIndex,
|
|
1373
|
-
annotation: { ...annotation.object, id: annotation.
|
|
1415
|
+
annotation: { ...annotation.object, id: annotation.object.id },
|
|
1374
1416
|
scaleFactor: scale
|
|
1375
1417
|
}
|
|
1376
1418
|
)
|
|
@@ -1408,7 +1450,7 @@ function Annotations(annotationsProps) {
|
|
|
1408
1450
|
(e, annotation) => {
|
|
1409
1451
|
e.stopPropagation();
|
|
1410
1452
|
if (annotationProvides && selectionProvides) {
|
|
1411
|
-
annotationProvides.selectAnnotation(pageIndex, annotation.
|
|
1453
|
+
annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
|
|
1412
1454
|
selectionProvides.clear();
|
|
1413
1455
|
setEditingId(null);
|
|
1414
1456
|
}
|
|
@@ -1419,8 +1461,8 @@ function Annotations(annotationsProps) {
|
|
|
1419
1461
|
return register(handlers);
|
|
1420
1462
|
}, [register, handlers]);
|
|
1421
1463
|
return /* @__PURE__ */ jsx(Fragment$1, { children: annotations.map((annotation) => {
|
|
1422
|
-
const isSelected = (selectionState == null ? void 0 : selectionState.
|
|
1423
|
-
const isEditing = editingId === annotation.
|
|
1464
|
+
const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
|
|
1465
|
+
const isEditing = editingId === annotation.object.id;
|
|
1424
1466
|
if (isInk(annotation)) {
|
|
1425
1467
|
return /* @__PURE__ */ jsx(
|
|
1426
1468
|
AnnotationContainer,
|
|
@@ -1438,7 +1480,7 @@ function Annotations(annotationsProps) {
|
|
|
1438
1480
|
children: (obj) => /* @__PURE__ */ jsx(
|
|
1439
1481
|
Ink,
|
|
1440
1482
|
{
|
|
1441
|
-
|
|
1483
|
+
isSelected,
|
|
1442
1484
|
color: obj.color,
|
|
1443
1485
|
opacity: obj.opacity,
|
|
1444
1486
|
strokeWidth: obj.strokeWidth,
|
|
@@ -1449,7 +1491,7 @@ function Annotations(annotationsProps) {
|
|
|
1449
1491
|
}
|
|
1450
1492
|
)
|
|
1451
1493
|
},
|
|
1452
|
-
annotation.
|
|
1494
|
+
annotation.object.id
|
|
1453
1495
|
);
|
|
1454
1496
|
}
|
|
1455
1497
|
if (isSquare(annotation)) {
|
|
@@ -1468,7 +1510,7 @@ function Annotations(annotationsProps) {
|
|
|
1468
1510
|
children: (obj) => /* @__PURE__ */ jsx(
|
|
1469
1511
|
Square,
|
|
1470
1512
|
{
|
|
1471
|
-
|
|
1513
|
+
isSelected,
|
|
1472
1514
|
rect: obj.rect,
|
|
1473
1515
|
color: obj.color,
|
|
1474
1516
|
opacity: obj.opacity,
|
|
@@ -1481,7 +1523,7 @@ function Annotations(annotationsProps) {
|
|
|
1481
1523
|
}
|
|
1482
1524
|
)
|
|
1483
1525
|
},
|
|
1484
|
-
annotation.
|
|
1526
|
+
annotation.object.id
|
|
1485
1527
|
);
|
|
1486
1528
|
}
|
|
1487
1529
|
if (isCircle(annotation)) {
|
|
@@ -1500,7 +1542,7 @@ function Annotations(annotationsProps) {
|
|
|
1500
1542
|
children: (obj) => /* @__PURE__ */ jsx(
|
|
1501
1543
|
Circle,
|
|
1502
1544
|
{
|
|
1503
|
-
|
|
1545
|
+
isSelected,
|
|
1504
1546
|
rect: obj.rect,
|
|
1505
1547
|
color: obj.color,
|
|
1506
1548
|
opacity: obj.opacity,
|
|
@@ -1513,7 +1555,7 @@ function Annotations(annotationsProps) {
|
|
|
1513
1555
|
}
|
|
1514
1556
|
)
|
|
1515
1557
|
},
|
|
1516
|
-
annotation.
|
|
1558
|
+
annotation.object.id
|
|
1517
1559
|
);
|
|
1518
1560
|
}
|
|
1519
1561
|
if (isUnderline(annotation)) {
|
|
@@ -1541,7 +1583,7 @@ function Annotations(annotationsProps) {
|
|
|
1541
1583
|
}
|
|
1542
1584
|
)
|
|
1543
1585
|
},
|
|
1544
|
-
annotation.
|
|
1586
|
+
annotation.object.id
|
|
1545
1587
|
);
|
|
1546
1588
|
}
|
|
1547
1589
|
if (isStrikeout(annotation)) {
|
|
@@ -1569,7 +1611,7 @@ function Annotations(annotationsProps) {
|
|
|
1569
1611
|
}
|
|
1570
1612
|
)
|
|
1571
1613
|
},
|
|
1572
|
-
annotation.
|
|
1614
|
+
annotation.object.id
|
|
1573
1615
|
);
|
|
1574
1616
|
}
|
|
1575
1617
|
if (isSquiggly(annotation)) {
|
|
@@ -1597,7 +1639,7 @@ function Annotations(annotationsProps) {
|
|
|
1597
1639
|
}
|
|
1598
1640
|
)
|
|
1599
1641
|
},
|
|
1600
|
-
annotation.
|
|
1642
|
+
annotation.object.id
|
|
1601
1643
|
);
|
|
1602
1644
|
}
|
|
1603
1645
|
if (isHighlight(annotation)) {
|
|
@@ -1625,7 +1667,7 @@ function Annotations(annotationsProps) {
|
|
|
1625
1667
|
}
|
|
1626
1668
|
)
|
|
1627
1669
|
},
|
|
1628
|
-
annotation.
|
|
1670
|
+
annotation.object.id
|
|
1629
1671
|
);
|
|
1630
1672
|
}
|
|
1631
1673
|
if (isLine(annotation)) {
|
|
@@ -1664,7 +1706,7 @@ function Annotations(annotationsProps) {
|
|
|
1664
1706
|
}
|
|
1665
1707
|
) })
|
|
1666
1708
|
},
|
|
1667
|
-
annotation.
|
|
1709
|
+
annotation.object.id
|
|
1668
1710
|
);
|
|
1669
1711
|
}
|
|
1670
1712
|
if (isPolyline(annotation)) {
|
|
@@ -1698,7 +1740,7 @@ function Annotations(annotationsProps) {
|
|
|
1698
1740
|
}
|
|
1699
1741
|
) })
|
|
1700
1742
|
},
|
|
1701
|
-
annotation.
|
|
1743
|
+
annotation.object.id
|
|
1702
1744
|
);
|
|
1703
1745
|
}
|
|
1704
1746
|
if (isPolygon(annotation)) {
|
|
@@ -1733,7 +1775,7 @@ function Annotations(annotationsProps) {
|
|
|
1733
1775
|
}
|
|
1734
1776
|
) })
|
|
1735
1777
|
},
|
|
1736
|
-
annotation.
|
|
1778
|
+
annotation.object.id
|
|
1737
1779
|
);
|
|
1738
1780
|
}
|
|
1739
1781
|
if (isFreeText(annotation)) {
|
|
@@ -1748,7 +1790,7 @@ function Annotations(annotationsProps) {
|
|
|
1748
1790
|
outlineOffset: 6,
|
|
1749
1791
|
onDoubleClick: (e) => {
|
|
1750
1792
|
e.stopPropagation();
|
|
1751
|
-
setEditingId(annotation.
|
|
1793
|
+
setEditingId(annotation.object.id);
|
|
1752
1794
|
},
|
|
1753
1795
|
style: {
|
|
1754
1796
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
@@ -1769,7 +1811,7 @@ function Annotations(annotationsProps) {
|
|
|
1769
1811
|
}
|
|
1770
1812
|
)
|
|
1771
1813
|
},
|
|
1772
|
-
annotation.
|
|
1814
|
+
annotation.object.id
|
|
1773
1815
|
);
|
|
1774
1816
|
}
|
|
1775
1817
|
if (isStamp(annotation)) {
|
|
@@ -1797,7 +1839,7 @@ function Annotations(annotationsProps) {
|
|
|
1797
1839
|
}
|
|
1798
1840
|
)
|
|
1799
1841
|
},
|
|
1800
|
-
annotation.
|
|
1842
|
+
annotation.object.id
|
|
1801
1843
|
);
|
|
1802
1844
|
}
|
|
1803
1845
|
return null;
|
|
@@ -1984,8 +2026,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
|
|
|
1984
2026
|
color: toolColor,
|
|
1985
2027
|
opacity: toolOpacity,
|
|
1986
2028
|
strokeWidth: toolStrokeWidth,
|
|
2029
|
+
created: /* @__PURE__ */ new Date(),
|
|
1987
2030
|
pageIndex,
|
|
1988
|
-
id:
|
|
2031
|
+
id: uuidV4()
|
|
1989
2032
|
};
|
|
1990
2033
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
1991
2034
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2142,8 +2185,9 @@ const CirclePaint = ({
|
|
|
2142
2185
|
strokeColor: toolStrokeColor,
|
|
2143
2186
|
strokeStyle: toolStrokeStyle,
|
|
2144
2187
|
strokeDashArray: toolStrokeDashArray,
|
|
2188
|
+
created: /* @__PURE__ */ new Date(),
|
|
2145
2189
|
pageIndex,
|
|
2146
|
-
id:
|
|
2190
|
+
id: uuidV4()
|
|
2147
2191
|
};
|
|
2148
2192
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2149
2193
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2297,7 +2341,8 @@ const SquarePaint = ({
|
|
|
2297
2341
|
strokeStyle: toolStrokeStyle,
|
|
2298
2342
|
strokeDashArray: toolStrokeDashArray,
|
|
2299
2343
|
pageIndex,
|
|
2300
|
-
id:
|
|
2344
|
+
id: uuidV4(),
|
|
2345
|
+
created: /* @__PURE__ */ new Date()
|
|
2301
2346
|
};
|
|
2302
2347
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2303
2348
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2420,7 +2465,8 @@ const PolylinePaint = ({
|
|
|
2420
2465
|
strokeDashArray: toolStrokeDashArray,
|
|
2421
2466
|
lineEndings: toolLineEndings,
|
|
2422
2467
|
pageIndex,
|
|
2423
|
-
id:
|
|
2468
|
+
id: uuidV4(),
|
|
2469
|
+
created: /* @__PURE__ */ new Date()
|
|
2424
2470
|
};
|
|
2425
2471
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2426
2472
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2528,7 +2574,8 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
|
|
|
2528
2574
|
lineEndings: toolLineEndings,
|
|
2529
2575
|
intent,
|
|
2530
2576
|
pageIndex,
|
|
2531
|
-
id:
|
|
2577
|
+
id: uuidV4(),
|
|
2578
|
+
created: /* @__PURE__ */ new Date()
|
|
2532
2579
|
};
|
|
2533
2580
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2534
2581
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2650,7 +2697,8 @@ const PolygonPaint = ({
|
|
|
2650
2697
|
strokeStyle: toolStrokeStyle,
|
|
2651
2698
|
strokeDashArray: toolStrokeDashArray,
|
|
2652
2699
|
pageIndex,
|
|
2653
|
-
id:
|
|
2700
|
+
id: uuidV4(),
|
|
2701
|
+
created: /* @__PURE__ */ new Date()
|
|
2654
2702
|
};
|
|
2655
2703
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2656
2704
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2841,7 +2889,8 @@ const FreeTextPaint = ({
|
|
|
2841
2889
|
textAlign: toolTextAlign,
|
|
2842
2890
|
verticalAlign: toolVerticalAlign,
|
|
2843
2891
|
pageIndex,
|
|
2844
|
-
id:
|
|
2892
|
+
id: uuidV4(),
|
|
2893
|
+
created: /* @__PURE__ */ new Date()
|
|
2845
2894
|
};
|
|
2846
2895
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2847
2896
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2987,7 +3036,8 @@ const StampPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
|
|
|
2987
3036
|
type: PdfAnnotationSubtype.STAMP,
|
|
2988
3037
|
flags: ["print"],
|
|
2989
3038
|
pageIndex,
|
|
2990
|
-
id:
|
|
3039
|
+
id: uuidV4(),
|
|
3040
|
+
created: /* @__PURE__ */ new Date(),
|
|
2991
3041
|
rect
|
|
2992
3042
|
};
|
|
2993
3043
|
annotationProvides.createAnnotation(pageIndex, anno, { imageData });
|