@embedpdf/plugin-annotation 1.0.16 → 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.
@@ -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";
@@ -415,7 +415,7 @@ function AnnotationContainer({
415
415
  setCurrentRect,
416
416
  setCurrentVertices,
417
417
  setPreviewObject,
418
- commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.localId, patch)
418
+ commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch)
419
419
  });
420
420
  useLayoutEffect(() => {
421
421
  if (!rectEquals(trackedAnnotation.object.rect, currentRect)) {
@@ -474,7 +474,7 @@ function AnnotationContainer({
474
474
  rect: currentRect,
475
475
  vertices: v
476
476
  });
477
- annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.localId, patch);
477
+ annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch);
478
478
  }
479
479
  }
480
480
  }
@@ -984,7 +984,7 @@ function Line({
984
984
  onTouchStart: onClick,
985
985
  style: {
986
986
  cursor: isSelected ? "move" : "pointer",
987
- pointerEvents: "visibleStroke",
987
+ pointerEvents: isSelected ? "none" : "visibleStroke",
988
988
  stroke: strokeColor,
989
989
  strokeWidth,
990
990
  strokeLinecap: "butt",
@@ -1006,7 +1006,7 @@ function Line({
1006
1006
  cursor: isSelected ? "move" : "pointer",
1007
1007
  strokeWidth,
1008
1008
  strokeLinecap: "butt",
1009
- pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
1009
+ pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1010
1010
  ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1011
1011
  strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1012
1012
  }
@@ -1026,7 +1026,7 @@ function Line({
1026
1026
  cursor: isSelected ? "move" : "pointer",
1027
1027
  strokeWidth,
1028
1028
  strokeLinecap: "butt",
1029
- pointerEvents: endings.end.filled ? "visible" : "visibleStroke",
1029
+ pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1030
1030
  ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1031
1031
  strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1032
1032
  }
@@ -1110,7 +1110,7 @@ function Polyline({
1110
1110
  stroke: strokeColor ?? color,
1111
1111
  strokeWidth,
1112
1112
  cursor: isSelected ? "move" : "pointer",
1113
- pointerEvents: "visibleStroke",
1113
+ pointerEvents: isSelected ? "none" : "visibleStroke",
1114
1114
  strokeLinecap: "butt",
1115
1115
  strokeLinejoin: "miter"
1116
1116
  }
@@ -1128,7 +1128,7 @@ function Polyline({
1128
1128
  style: {
1129
1129
  cursor: isSelected ? "move" : "pointer",
1130
1130
  strokeWidth,
1131
- pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
1131
+ pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1132
1132
  strokeLinecap: "butt"
1133
1133
  }
1134
1134
  }
@@ -1292,7 +1292,7 @@ function FreeText({
1292
1292
  const handleBlur = () => {
1293
1293
  if (!annotationProvides) return;
1294
1294
  if (!editorRef.current) return;
1295
- annotationProvides.updateAnnotation(pageIndex, annotation.localId, {
1295
+ annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
1296
1296
  contents: editorRef.current.innerText
1297
1297
  });
1298
1298
  };
@@ -1408,11 +1408,11 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
1408
1408
  },
1409
1409
  onPointerDown: onClick,
1410
1410
  onTouchStart: onClick,
1411
- children: annotation.pdfId !== void 0 && /* @__PURE__ */ jsx(
1411
+ children: /* @__PURE__ */ jsx(
1412
1412
  RenderAnnotation,
1413
1413
  {
1414
1414
  pageIndex,
1415
- annotation: { ...annotation.object, id: annotation.pdfId },
1415
+ annotation: { ...annotation.object, id: annotation.object.id },
1416
1416
  scaleFactor: scale
1417
1417
  }
1418
1418
  )
@@ -1450,7 +1450,7 @@ function Annotations(annotationsProps) {
1450
1450
  (e, annotation) => {
1451
1451
  e.stopPropagation();
1452
1452
  if (annotationProvides && selectionProvides) {
1453
- annotationProvides.selectAnnotation(pageIndex, annotation.localId);
1453
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
1454
1454
  selectionProvides.clear();
1455
1455
  setEditingId(null);
1456
1456
  }
@@ -1461,8 +1461,8 @@ function Annotations(annotationsProps) {
1461
1461
  return register(handlers);
1462
1462
  }, [register, handlers]);
1463
1463
  return /* @__PURE__ */ jsx(Fragment$1, { children: annotations.map((annotation) => {
1464
- const isSelected = (selectionState == null ? void 0 : selectionState.localId) === annotation.localId;
1465
- const isEditing = editingId === annotation.localId;
1464
+ const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
1465
+ const isEditing = editingId === annotation.object.id;
1466
1466
  if (isInk(annotation)) {
1467
1467
  return /* @__PURE__ */ jsx(
1468
1468
  AnnotationContainer,
@@ -1491,7 +1491,7 @@ function Annotations(annotationsProps) {
1491
1491
  }
1492
1492
  )
1493
1493
  },
1494
- annotation.localId
1494
+ annotation.object.id
1495
1495
  );
1496
1496
  }
1497
1497
  if (isSquare(annotation)) {
@@ -1523,7 +1523,7 @@ function Annotations(annotationsProps) {
1523
1523
  }
1524
1524
  )
1525
1525
  },
1526
- annotation.localId
1526
+ annotation.object.id
1527
1527
  );
1528
1528
  }
1529
1529
  if (isCircle(annotation)) {
@@ -1555,7 +1555,7 @@ function Annotations(annotationsProps) {
1555
1555
  }
1556
1556
  )
1557
1557
  },
1558
- annotation.localId
1558
+ annotation.object.id
1559
1559
  );
1560
1560
  }
1561
1561
  if (isUnderline(annotation)) {
@@ -1583,7 +1583,7 @@ function Annotations(annotationsProps) {
1583
1583
  }
1584
1584
  )
1585
1585
  },
1586
- annotation.localId
1586
+ annotation.object.id
1587
1587
  );
1588
1588
  }
1589
1589
  if (isStrikeout(annotation)) {
@@ -1611,7 +1611,7 @@ function Annotations(annotationsProps) {
1611
1611
  }
1612
1612
  )
1613
1613
  },
1614
- annotation.localId
1614
+ annotation.object.id
1615
1615
  );
1616
1616
  }
1617
1617
  if (isSquiggly(annotation)) {
@@ -1639,7 +1639,7 @@ function Annotations(annotationsProps) {
1639
1639
  }
1640
1640
  )
1641
1641
  },
1642
- annotation.localId
1642
+ annotation.object.id
1643
1643
  );
1644
1644
  }
1645
1645
  if (isHighlight(annotation)) {
@@ -1667,7 +1667,7 @@ function Annotations(annotationsProps) {
1667
1667
  }
1668
1668
  )
1669
1669
  },
1670
- annotation.localId
1670
+ annotation.object.id
1671
1671
  );
1672
1672
  }
1673
1673
  if (isLine(annotation)) {
@@ -1706,7 +1706,7 @@ function Annotations(annotationsProps) {
1706
1706
  }
1707
1707
  ) })
1708
1708
  },
1709
- annotation.localId
1709
+ annotation.object.id
1710
1710
  );
1711
1711
  }
1712
1712
  if (isPolyline(annotation)) {
@@ -1740,7 +1740,7 @@ function Annotations(annotationsProps) {
1740
1740
  }
1741
1741
  ) })
1742
1742
  },
1743
- annotation.localId
1743
+ annotation.object.id
1744
1744
  );
1745
1745
  }
1746
1746
  if (isPolygon(annotation)) {
@@ -1775,7 +1775,7 @@ function Annotations(annotationsProps) {
1775
1775
  }
1776
1776
  ) })
1777
1777
  },
1778
- annotation.localId
1778
+ annotation.object.id
1779
1779
  );
1780
1780
  }
1781
1781
  if (isFreeText(annotation)) {
@@ -1790,7 +1790,7 @@ function Annotations(annotationsProps) {
1790
1790
  outlineOffset: 6,
1791
1791
  onDoubleClick: (e) => {
1792
1792
  e.stopPropagation();
1793
- setEditingId(annotation.localId);
1793
+ setEditingId(annotation.object.id);
1794
1794
  },
1795
1795
  style: {
1796
1796
  mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
@@ -1811,7 +1811,7 @@ function Annotations(annotationsProps) {
1811
1811
  }
1812
1812
  )
1813
1813
  },
1814
- annotation.localId
1814
+ annotation.object.id
1815
1815
  );
1816
1816
  }
1817
1817
  if (isStamp(annotation)) {
@@ -1839,7 +1839,7 @@ function Annotations(annotationsProps) {
1839
1839
  }
1840
1840
  )
1841
1841
  },
1842
- annotation.localId
1842
+ annotation.object.id
1843
1843
  );
1844
1844
  }
1845
1845
  return null;
@@ -2026,8 +2026,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
2026
2026
  color: toolColor,
2027
2027
  opacity: toolOpacity,
2028
2028
  strokeWidth: toolStrokeWidth,
2029
+ created: /* @__PURE__ */ new Date(),
2029
2030
  pageIndex,
2030
- id: Date.now() + Math.random()
2031
+ id: uuidV4()
2031
2032
  };
2032
2033
  annotationProvides.createAnnotation(pageIndex, anno);
2033
2034
  annotationProvides.setActiveVariant(null);
@@ -2184,8 +2185,9 @@ const CirclePaint = ({
2184
2185
  strokeColor: toolStrokeColor,
2185
2186
  strokeStyle: toolStrokeStyle,
2186
2187
  strokeDashArray: toolStrokeDashArray,
2188
+ created: /* @__PURE__ */ new Date(),
2187
2189
  pageIndex,
2188
- id: Date.now() + Math.random()
2190
+ id: uuidV4()
2189
2191
  };
2190
2192
  annotationProvides.createAnnotation(pageIndex, anno);
2191
2193
  annotationProvides.setActiveVariant(null);
@@ -2339,7 +2341,8 @@ const SquarePaint = ({
2339
2341
  strokeStyle: toolStrokeStyle,
2340
2342
  strokeDashArray: toolStrokeDashArray,
2341
2343
  pageIndex,
2342
- id: Date.now() + Math.random()
2344
+ id: uuidV4(),
2345
+ created: /* @__PURE__ */ new Date()
2343
2346
  };
2344
2347
  annotationProvides.createAnnotation(pageIndex, anno);
2345
2348
  annotationProvides.setActiveVariant(null);
@@ -2462,7 +2465,8 @@ const PolylinePaint = ({
2462
2465
  strokeDashArray: toolStrokeDashArray,
2463
2466
  lineEndings: toolLineEndings,
2464
2467
  pageIndex,
2465
- id: Date.now() + Math.random()
2468
+ id: uuidV4(),
2469
+ created: /* @__PURE__ */ new Date()
2466
2470
  };
2467
2471
  annotationProvides.createAnnotation(pageIndex, anno);
2468
2472
  annotationProvides.setActiveVariant(null);
@@ -2570,7 +2574,8 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
2570
2574
  lineEndings: toolLineEndings,
2571
2575
  intent,
2572
2576
  pageIndex,
2573
- id: Date.now() + Math.random()
2577
+ id: uuidV4(),
2578
+ created: /* @__PURE__ */ new Date()
2574
2579
  };
2575
2580
  annotationProvides.createAnnotation(pageIndex, anno);
2576
2581
  annotationProvides.setActiveVariant(null);
@@ -2692,7 +2697,8 @@ const PolygonPaint = ({
2692
2697
  strokeStyle: toolStrokeStyle,
2693
2698
  strokeDashArray: toolStrokeDashArray,
2694
2699
  pageIndex,
2695
- id: Date.now() + Math.random()
2700
+ id: uuidV4(),
2701
+ created: /* @__PURE__ */ new Date()
2696
2702
  };
2697
2703
  annotationProvides.createAnnotation(pageIndex, anno);
2698
2704
  annotationProvides.setActiveVariant(null);
@@ -2883,7 +2889,8 @@ const FreeTextPaint = ({
2883
2889
  textAlign: toolTextAlign,
2884
2890
  verticalAlign: toolVerticalAlign,
2885
2891
  pageIndex,
2886
- id: Date.now() + Math.random()
2892
+ id: uuidV4(),
2893
+ created: /* @__PURE__ */ new Date()
2887
2894
  };
2888
2895
  annotationProvides.createAnnotation(pageIndex, anno);
2889
2896
  annotationProvides.setActiveVariant(null);
@@ -3029,7 +3036,8 @@ const StampPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
3029
3036
  type: PdfAnnotationSubtype.STAMP,
3030
3037
  flags: ["print"],
3031
3038
  pageIndex,
3032
- id: Date.now() + Math.random(),
3039
+ id: uuidV4(),
3040
+ created: /* @__PURE__ */ new Date(),
3033
3041
  rect
3034
3042
  };
3035
3043
  annotationProvides.createAnnotation(pageIndex, anno, { imageData });