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