@embedpdf/plugin-annotation 1.0.16 → 1.0.18

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,11 +1,12 @@
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";
8
8
  import { useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from "preact/hooks";
9
+ import { clamp } from "@embedpdf/core";
9
10
  const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
10
11
  const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
11
12
  const mapDoubleClick = (handler) => handler ? { onDblClick: handler } : {};
@@ -163,7 +164,7 @@ function useDragResize({
163
164
  const dir = useRef("none");
164
165
  const startPos = useRef(null);
165
166
  const startRect = useRef(null);
166
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
167
+ const clamp2 = (v, min, max) => Math.max(min, Math.min(max, v));
167
168
  const pageW = pageWidth / scale;
168
169
  const pageH = pageHeight / scale;
169
170
  const applyDelta = (dx, dy) => {
@@ -206,10 +207,10 @@ function useDragResize({
206
207
  }
207
208
  }
208
209
  if (w < 1 || h < 1) return currentRect;
209
- w = clamp(w, 1, pageW);
210
- h = clamp(h, 1, pageH);
211
- ox = clamp(ox, 0, pageW - w);
212
- oy = clamp(oy, 0, pageH - h);
210
+ w = clamp2(w, 1, pageW);
211
+ h = clamp2(h, 1, pageH);
212
+ ox = clamp2(ox, 0, pageW - w);
213
+ oy = clamp2(oy, 0, pageH - h);
213
214
  return { origin: { x: ox, y: oy }, size: { width: w, height: h } };
214
215
  };
215
216
  const beginDrag = (kind, clientX, clientY) => {
@@ -416,7 +417,7 @@ function AnnotationContainer({
416
417
  setCurrentRect,
417
418
  setCurrentVertices,
418
419
  setPreviewObject,
419
- commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.localId, patch)
420
+ commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch)
420
421
  });
421
422
  useLayoutEffect(() => {
422
423
  if (!rectEquals(trackedAnnotation.object.rect, currentRect)) {
@@ -475,7 +476,7 @@ function AnnotationContainer({
475
476
  rect: currentRect,
476
477
  vertices: v
477
478
  });
478
- annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.localId, patch);
479
+ annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch);
479
480
  }
480
481
  }
481
482
  }
@@ -985,7 +986,7 @@ function Line({
985
986
  onTouchStart: onClick,
986
987
  style: {
987
988
  cursor: isSelected ? "move" : "pointer",
988
- pointerEvents: "visibleStroke",
989
+ pointerEvents: isSelected ? "none" : "visibleStroke",
989
990
  stroke: strokeColor,
990
991
  strokeWidth,
991
992
  strokeLinecap: "butt",
@@ -1007,7 +1008,7 @@ function Line({
1007
1008
  cursor: isSelected ? "move" : "pointer",
1008
1009
  strokeWidth,
1009
1010
  strokeLinecap: "butt",
1010
- pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
1011
+ pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1011
1012
  ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1012
1013
  strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1013
1014
  }
@@ -1027,7 +1028,7 @@ function Line({
1027
1028
  cursor: isSelected ? "move" : "pointer",
1028
1029
  strokeWidth,
1029
1030
  strokeLinecap: "butt",
1030
- pointerEvents: endings.end.filled ? "visible" : "visibleStroke",
1031
+ pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1031
1032
  ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1032
1033
  strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1033
1034
  }
@@ -1111,7 +1112,7 @@ function Polyline({
1111
1112
  stroke: strokeColor ?? color,
1112
1113
  strokeWidth,
1113
1114
  cursor: isSelected ? "move" : "pointer",
1114
- pointerEvents: "visibleStroke",
1115
+ pointerEvents: isSelected ? "none" : "visibleStroke",
1115
1116
  strokeLinecap: "butt",
1116
1117
  strokeLinejoin: "miter"
1117
1118
  }
@@ -1129,7 +1130,7 @@ function Polyline({
1129
1130
  style: {
1130
1131
  cursor: isSelected ? "move" : "pointer",
1131
1132
  strokeWidth,
1132
- pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
1133
+ pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1133
1134
  strokeLinecap: "butt"
1134
1135
  }
1135
1136
  }
@@ -1293,7 +1294,7 @@ function FreeText({
1293
1294
  const handleBlur = () => {
1294
1295
  if (!annotationProvides) return;
1295
1296
  if (!editorRef.current) return;
1296
- annotationProvides.updateAnnotation(pageIndex, annotation.localId, {
1297
+ annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
1297
1298
  contents: editorRef.current.innerText
1298
1299
  });
1299
1300
  };
@@ -1332,7 +1333,6 @@ function FreeText({
1332
1333
  cursor: isEditing ? "text" : "pointer"
1333
1334
  },
1334
1335
  contentEditable: isEditing,
1335
- suppressContentEditableWarning: true,
1336
1336
  children: annotation.object.contents
1337
1337
  }
1338
1338
  )
@@ -1409,11 +1409,11 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
1409
1409
  },
1410
1410
  onPointerDown: onClick,
1411
1411
  onTouchStart: onClick,
1412
- children: annotation.pdfId !== void 0 && /* @__PURE__ */ jsx(
1412
+ children: /* @__PURE__ */ jsx(
1413
1413
  RenderAnnotation,
1414
1414
  {
1415
1415
  pageIndex,
1416
- annotation: { ...annotation.object, id: annotation.pdfId },
1416
+ annotation: { ...annotation.object, id: annotation.object.id },
1417
1417
  scaleFactor: scale
1418
1418
  }
1419
1419
  )
@@ -1451,7 +1451,7 @@ function Annotations(annotationsProps) {
1451
1451
  (e, annotation) => {
1452
1452
  e.stopPropagation();
1453
1453
  if (annotationProvides && selectionProvides) {
1454
- annotationProvides.selectAnnotation(pageIndex, annotation.localId);
1454
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
1455
1455
  selectionProvides.clear();
1456
1456
  setEditingId(null);
1457
1457
  }
@@ -1462,8 +1462,8 @@ function Annotations(annotationsProps) {
1462
1462
  return register(handlers);
1463
1463
  }, [register, handlers]);
1464
1464
  return /* @__PURE__ */ jsx(Fragment$1, { children: annotations.map((annotation) => {
1465
- const isSelected = (selectionState == null ? void 0 : selectionState.localId) === annotation.localId;
1466
- const isEditing = editingId === annotation.localId;
1465
+ const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
1466
+ const isEditing = editingId === annotation.object.id;
1467
1467
  if (isInk(annotation)) {
1468
1468
  return /* @__PURE__ */ jsx(
1469
1469
  AnnotationContainer,
@@ -1492,7 +1492,7 @@ function Annotations(annotationsProps) {
1492
1492
  }
1493
1493
  )
1494
1494
  },
1495
- annotation.localId
1495
+ annotation.object.id
1496
1496
  );
1497
1497
  }
1498
1498
  if (isSquare(annotation)) {
@@ -1524,7 +1524,7 @@ function Annotations(annotationsProps) {
1524
1524
  }
1525
1525
  )
1526
1526
  },
1527
- annotation.localId
1527
+ annotation.object.id
1528
1528
  );
1529
1529
  }
1530
1530
  if (isCircle(annotation)) {
@@ -1556,7 +1556,7 @@ function Annotations(annotationsProps) {
1556
1556
  }
1557
1557
  )
1558
1558
  },
1559
- annotation.localId
1559
+ annotation.object.id
1560
1560
  );
1561
1561
  }
1562
1562
  if (isUnderline(annotation)) {
@@ -1584,7 +1584,7 @@ function Annotations(annotationsProps) {
1584
1584
  }
1585
1585
  )
1586
1586
  },
1587
- annotation.localId
1587
+ annotation.object.id
1588
1588
  );
1589
1589
  }
1590
1590
  if (isStrikeout(annotation)) {
@@ -1612,7 +1612,7 @@ function Annotations(annotationsProps) {
1612
1612
  }
1613
1613
  )
1614
1614
  },
1615
- annotation.localId
1615
+ annotation.object.id
1616
1616
  );
1617
1617
  }
1618
1618
  if (isSquiggly(annotation)) {
@@ -1640,7 +1640,7 @@ function Annotations(annotationsProps) {
1640
1640
  }
1641
1641
  )
1642
1642
  },
1643
- annotation.localId
1643
+ annotation.object.id
1644
1644
  );
1645
1645
  }
1646
1646
  if (isHighlight(annotation)) {
@@ -1668,7 +1668,7 @@ function Annotations(annotationsProps) {
1668
1668
  }
1669
1669
  )
1670
1670
  },
1671
- annotation.localId
1671
+ annotation.object.id
1672
1672
  );
1673
1673
  }
1674
1674
  if (isLine(annotation)) {
@@ -1707,7 +1707,7 @@ function Annotations(annotationsProps) {
1707
1707
  }
1708
1708
  ) })
1709
1709
  },
1710
- annotation.localId
1710
+ annotation.object.id
1711
1711
  );
1712
1712
  }
1713
1713
  if (isPolyline(annotation)) {
@@ -1741,7 +1741,7 @@ function Annotations(annotationsProps) {
1741
1741
  }
1742
1742
  ) })
1743
1743
  },
1744
- annotation.localId
1744
+ annotation.object.id
1745
1745
  );
1746
1746
  }
1747
1747
  if (isPolygon(annotation)) {
@@ -1776,7 +1776,7 @@ function Annotations(annotationsProps) {
1776
1776
  }
1777
1777
  ) })
1778
1778
  },
1779
- annotation.localId
1779
+ annotation.object.id
1780
1780
  );
1781
1781
  }
1782
1782
  if (isFreeText(annotation)) {
@@ -1791,7 +1791,7 @@ function Annotations(annotationsProps) {
1791
1791
  outlineOffset: 6,
1792
1792
  onDoubleClick: (e) => {
1793
1793
  e.stopPropagation();
1794
- setEditingId(annotation.localId);
1794
+ setEditingId(annotation.object.id);
1795
1795
  },
1796
1796
  style: {
1797
1797
  mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
@@ -1812,7 +1812,7 @@ function Annotations(annotationsProps) {
1812
1812
  }
1813
1813
  )
1814
1814
  },
1815
- annotation.localId
1815
+ annotation.object.id
1816
1816
  );
1817
1817
  }
1818
1818
  if (isStamp(annotation)) {
@@ -1840,7 +1840,7 @@ function Annotations(annotationsProps) {
1840
1840
  }
1841
1841
  )
1842
1842
  },
1843
- annotation.localId
1843
+ annotation.object.id
1844
1844
  );
1845
1845
  }
1846
1846
  return null;
@@ -1974,7 +1974,6 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
1974
1974
  const toolBlendMode = ((_d = activeTool.defaults) == null ? void 0 : _d.blendMode) ?? PdfBlendMode.Normal;
1975
1975
  const intent = (_e = activeTool.defaults) == null ? void 0 : _e.intent;
1976
1976
  const { register } = usePointerHandlers({ modeId: "ink", pageIndex });
1977
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
1978
1977
  const [currentStrokes, setCurrentStrokes] = useState([]);
1979
1978
  const [isDrawing, setIsDrawing] = useState(false);
1980
1979
  const timerRef = useRef(null);
@@ -1983,7 +1982,7 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
1983
1982
  const handlers = useMemo(
1984
1983
  () => ({
1985
1984
  onPointerDown: (pos, evt) => {
1986
- var _a2, _b2;
1985
+ var _a2;
1987
1986
  const curX = clamp(pos.x, 0, pageWidthPDF);
1988
1987
  const curY = clamp(pos.y, 0, pageHeightPDF);
1989
1988
  setIsDrawing(true);
@@ -1994,7 +1993,7 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
1994
1993
  } else {
1995
1994
  setCurrentStrokes([{ points: [{ x: curX, y: curY }] }]);
1996
1995
  }
1997
- (_b2 = (_a2 = evt.target) == null ? void 0 : _a2.setPointerCapture) == null ? void 0 : _b2.call(_a2, evt.pointerId);
1996
+ (_a2 = evt.setPointerCapture) == null ? void 0 : _a2.call(evt);
1998
1997
  },
1999
1998
  onPointerMove: (pos) => {
2000
1999
  if (!isDrawing) return;
@@ -2008,9 +2007,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
2008
2007
  });
2009
2008
  },
2010
2009
  onPointerUp: (_, evt) => {
2011
- var _a2, _b2;
2010
+ var _a2;
2012
2011
  setIsDrawing(false);
2013
- (_b2 = (_a2 = evt.target) == null ? void 0 : _a2.releasePointerCapture) == null ? void 0 : _b2.call(_a2, evt.pointerId);
2012
+ (_a2 = evt.releasePointerCapture) == null ? void 0 : _a2.call(evt);
2014
2013
  if (timerRef.current) clearTimeout(timerRef.current);
2015
2014
  timerRef.current = setTimeout(() => {
2016
2015
  if (currentStrokes.length && annotationProvides) {
@@ -2027,8 +2026,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
2027
2026
  color: toolColor,
2028
2027
  opacity: toolOpacity,
2029
2028
  strokeWidth: toolStrokeWidth,
2029
+ created: /* @__PURE__ */ new Date(),
2030
2030
  pageIndex,
2031
- id: Date.now() + Math.random()
2031
+ id: uuidV4()
2032
2032
  };
2033
2033
  annotationProvides.createAnnotation(pageIndex, anno);
2034
2034
  annotationProvides.setActiveVariant(null);
@@ -2039,9 +2039,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
2039
2039
  }, 3e3);
2040
2040
  },
2041
2041
  onPointerCancel: (_, evt) => {
2042
- var _a2, _b2;
2042
+ var _a2;
2043
2043
  setIsDrawing(false);
2044
- (_b2 = (_a2 = evt.target) == null ? void 0 : _a2.releasePointerCapture) == null ? void 0 : _b2.call(_a2, evt.pointerId);
2044
+ (_a2 = evt.releasePointerCapture) == null ? void 0 : _a2.call(evt);
2045
2045
  setCurrentStrokes([]);
2046
2046
  if (timerRef.current) {
2047
2047
  clearTimeout(timerRef.current);
@@ -2138,7 +2138,6 @@ const CirclePaint = ({
2138
2138
  const toolStrokeStyle = activeTool.defaults.strokeStyle ?? PdfAnnotationBorderStyle.SOLID;
2139
2139
  const toolStrokeDashArray = activeTool.defaults.strokeDashArray ?? [];
2140
2140
  const { register } = usePointerHandlers({ modeId: "circle", pageIndex });
2141
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2142
2141
  const pageWidthPDF = pageWidth / scale;
2143
2142
  const pageHeightPDF = pageHeight / scale;
2144
2143
  const [start, setStart] = useState(null);
@@ -2146,12 +2145,12 @@ const CirclePaint = ({
2146
2145
  const handlers = useMemo(
2147
2146
  () => ({
2148
2147
  onPointerDown: (pos, evt) => {
2149
- var _a, _b;
2148
+ var _a;
2150
2149
  const x = clamp(pos.x, 0, pageWidthPDF);
2151
2150
  const y = clamp(pos.y, 0, pageHeightPDF);
2152
2151
  setStart({ x, y });
2153
2152
  setCurrent({ x, y });
2154
- (_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2153
+ (_a = evt.setPointerCapture) == null ? void 0 : _a.call(evt);
2155
2154
  },
2156
2155
  onPointerMove: (pos) => {
2157
2156
  if (!start) return;
@@ -2160,7 +2159,7 @@ const CirclePaint = ({
2160
2159
  setCurrent({ x, y });
2161
2160
  },
2162
2161
  onPointerUp: (_, evt) => {
2163
- var _a, _b;
2162
+ var _a;
2164
2163
  if (start && current && annotationProvides) {
2165
2164
  const minX2 = Math.min(start.x, current.x);
2166
2165
  const minY2 = Math.min(start.y, current.y);
@@ -2185,21 +2184,22 @@ const CirclePaint = ({
2185
2184
  strokeColor: toolStrokeColor,
2186
2185
  strokeStyle: toolStrokeStyle,
2187
2186
  strokeDashArray: toolStrokeDashArray,
2187
+ created: /* @__PURE__ */ new Date(),
2188
2188
  pageIndex,
2189
- id: Date.now() + Math.random()
2189
+ id: uuidV4()
2190
2190
  };
2191
2191
  annotationProvides.createAnnotation(pageIndex, anno);
2192
2192
  annotationProvides.setActiveVariant(null);
2193
2193
  annotationProvides.selectAnnotation(pageIndex, anno.id);
2194
2194
  }
2195
2195
  }
2196
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2196
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2197
2197
  setStart(null);
2198
2198
  setCurrent(null);
2199
2199
  },
2200
2200
  onPointerCancel: (_, evt) => {
2201
- var _a, _b;
2202
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2201
+ var _a;
2202
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2203
2203
  setStart(null);
2204
2204
  setCurrent(null);
2205
2205
  }
@@ -2292,7 +2292,6 @@ const SquarePaint = ({
2292
2292
  const toolStrokeStyle = activeTool.defaults.strokeStyle ?? PdfAnnotationBorderStyle.SOLID;
2293
2293
  const toolStrokeDashArray = activeTool.defaults.strokeDashArray ?? [];
2294
2294
  const { register } = usePointerHandlers({ modeId: "square", pageIndex });
2295
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2296
2295
  const pageWidthPDF = pageWidth / scale;
2297
2296
  const pageHeightPDF = pageHeight / scale;
2298
2297
  const [start, setStart] = useState(null);
@@ -2340,7 +2339,8 @@ const SquarePaint = ({
2340
2339
  strokeStyle: toolStrokeStyle,
2341
2340
  strokeDashArray: toolStrokeDashArray,
2342
2341
  pageIndex,
2343
- id: Date.now() + Math.random()
2342
+ id: uuidV4(),
2343
+ created: /* @__PURE__ */ new Date()
2344
2344
  };
2345
2345
  annotationProvides.createAnnotation(pageIndex, anno);
2346
2346
  annotationProvides.setActiveVariant(null);
@@ -2443,7 +2443,6 @@ const PolylinePaint = ({
2443
2443
  const toolStrokeStyle = activeTool.defaults.strokeStyle ?? PdfAnnotationBorderStyle.SOLID;
2444
2444
  const toolStrokeDashArray = activeTool.defaults.strokeDashArray;
2445
2445
  const { register } = usePointerHandlers({ modeId: "polyline", pageIndex });
2446
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2447
2446
  const pageWidthPDF = pageWidth / scale;
2448
2447
  const pageHeightPDF = pageHeight / scale;
2449
2448
  const [vertices, setVertices] = useState([]);
@@ -2463,7 +2462,8 @@ const PolylinePaint = ({
2463
2462
  strokeDashArray: toolStrokeDashArray,
2464
2463
  lineEndings: toolLineEndings,
2465
2464
  pageIndex,
2466
- id: Date.now() + Math.random()
2465
+ id: uuidV4(),
2466
+ created: /* @__PURE__ */ new Date()
2467
2467
  };
2468
2468
  annotationProvides.createAnnotation(pageIndex, anno);
2469
2469
  annotationProvides.setActiveVariant(null);
@@ -2550,7 +2550,6 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
2550
2550
  const toolLineEndings = activeTool.defaults.lineEndings;
2551
2551
  const intent = activeTool.defaults.intent;
2552
2552
  const { register } = usePointerHandlers({ modeId: ["line", "lineArrow"], pageIndex });
2553
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2554
2553
  const pageWidthPDF = pageWidth / scale;
2555
2554
  const pageHeightPDF = pageHeight / scale;
2556
2555
  const [start, setStart] = useState(null);
@@ -2571,7 +2570,8 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
2571
2570
  lineEndings: toolLineEndings,
2572
2571
  intent,
2573
2572
  pageIndex,
2574
- id: Date.now() + Math.random()
2573
+ id: uuidV4(),
2574
+ created: /* @__PURE__ */ new Date()
2575
2575
  };
2576
2576
  annotationProvides.createAnnotation(pageIndex, anno);
2577
2577
  annotationProvides.setActiveVariant(null);
@@ -2580,12 +2580,12 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
2580
2580
  const handlers = useMemo(
2581
2581
  () => ({
2582
2582
  onPointerDown: (pos, evt) => {
2583
- var _a, _b;
2583
+ var _a;
2584
2584
  const x = clamp(pos.x, 0, pageWidthPDF);
2585
2585
  const y = clamp(pos.y, 0, pageHeightPDF);
2586
2586
  setStart({ x, y });
2587
2587
  setCurrent({ x, y });
2588
- (_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2588
+ (_a = evt.setPointerCapture) == null ? void 0 : _a.call(evt);
2589
2589
  },
2590
2590
  onPointerMove: (pos) => {
2591
2591
  if (!start) return;
@@ -2594,17 +2594,17 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
2594
2594
  setCurrent({ x, y });
2595
2595
  },
2596
2596
  onPointerUp: (_, evt) => {
2597
- var _a, _b;
2597
+ var _a;
2598
2598
  if (start && current && annotationProvides) {
2599
2599
  commitLine(start, current);
2600
2600
  }
2601
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2601
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2602
2602
  setStart(null);
2603
2603
  setCurrent(null);
2604
2604
  },
2605
2605
  onPointerCancel: (_, evt) => {
2606
- var _a, _b;
2607
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2606
+ var _a;
2607
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2608
2608
  setStart(null);
2609
2609
  setCurrent(null);
2610
2610
  }
@@ -2667,7 +2667,6 @@ const PolygonPaint = ({
2667
2667
  const toolStrokeStyle = activeTool.defaults.strokeStyle ?? PdfAnnotationBorderStyle.SOLID;
2668
2668
  const toolStrokeDashArray = activeTool.defaults.strokeDashArray;
2669
2669
  const { register } = usePointerHandlers({ modeId: "polygon", pageIndex });
2670
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2671
2670
  const pageWidthPDF = pageWidth / scale;
2672
2671
  const pageHeightPDF = pageHeight / scale;
2673
2672
  const [vertices, setVertices] = useState([]);
@@ -2693,7 +2692,8 @@ const PolygonPaint = ({
2693
2692
  strokeStyle: toolStrokeStyle,
2694
2693
  strokeDashArray: toolStrokeDashArray,
2695
2694
  pageIndex,
2696
- id: Date.now() + Math.random()
2695
+ id: uuidV4(),
2696
+ created: /* @__PURE__ */ new Date()
2697
2697
  };
2698
2698
  annotationProvides.createAnnotation(pageIndex, anno);
2699
2699
  annotationProvides.setActiveVariant(null);
@@ -2855,7 +2855,7 @@ const FreeTextPaint = ({
2855
2855
  const toolVerticalAlign = activeTool.defaults.verticalAlign;
2856
2856
  const toolContent = activeTool.defaults.content ?? "Insert text here";
2857
2857
  const { register } = usePointerHandlers({ modeId: "freeText", pageIndex });
2858
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2858
+ const clamp2 = (v, min, max) => Math.max(min, Math.min(max, v));
2859
2859
  const pageWidthPDF = pageWidth / scale;
2860
2860
  const pageHeightPDF = pageHeight / scale;
2861
2861
  const [start, setStart] = useState(null);
@@ -2884,7 +2884,8 @@ const FreeTextPaint = ({
2884
2884
  textAlign: toolTextAlign,
2885
2885
  verticalAlign: toolVerticalAlign,
2886
2886
  pageIndex,
2887
- id: Date.now() + Math.random()
2887
+ id: uuidV4(),
2888
+ created: /* @__PURE__ */ new Date()
2888
2889
  };
2889
2890
  annotationProvides.createAnnotation(pageIndex, anno);
2890
2891
  annotationProvides.setActiveVariant(null);
@@ -2893,31 +2894,31 @@ const FreeTextPaint = ({
2893
2894
  const handlers = useMemo(
2894
2895
  () => ({
2895
2896
  onPointerDown: (pos, evt) => {
2896
- var _a, _b;
2897
- const x = clamp(pos.x, 0, pageWidthPDF);
2898
- const y = clamp(pos.y, 0, pageHeightPDF);
2897
+ var _a;
2898
+ const x = clamp2(pos.x, 0, pageWidthPDF);
2899
+ const y = clamp2(pos.y, 0, pageHeightPDF);
2899
2900
  setStart({ x, y });
2900
2901
  setCurrent({ x, y });
2901
- (_b = (_a = evt.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2902
+ (_a = evt.setPointerCapture) == null ? void 0 : _a.call(evt);
2902
2903
  },
2903
2904
  onPointerMove: (pos) => {
2904
2905
  if (!start) return;
2905
- const x = clamp(pos.x, 0, pageWidthPDF);
2906
- const y = clamp(pos.y, 0, pageHeightPDF);
2906
+ const x = clamp2(pos.x, 0, pageWidthPDF);
2907
+ const y = clamp2(pos.y, 0, pageHeightPDF);
2907
2908
  setCurrent({ x, y });
2908
2909
  },
2909
2910
  onPointerUp: (_, evt) => {
2910
- var _a, _b;
2911
+ var _a;
2911
2912
  if (start && current && annotationProvides) {
2912
2913
  commitFreeText(start, current);
2913
2914
  }
2914
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2915
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2915
2916
  setStart(null);
2916
2917
  setCurrent(null);
2917
2918
  },
2918
2919
  onPointerCancel: (_, evt) => {
2919
- var _a, _b;
2920
- (_b = (_a = evt.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, evt.pointerId);
2920
+ var _a;
2921
+ (_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
2921
2922
  setStart(null);
2922
2923
  setCurrent(null);
2923
2924
  }
@@ -2980,7 +2981,6 @@ const StampPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
2980
2981
  const { register } = usePointerHandlers({ modeId: "stamp", pageIndex });
2981
2982
  const pageWidthPDF = pageWidth / scale;
2982
2983
  const pageHeightPDF = pageHeight / scale;
2983
- const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
2984
2984
  const [start, setStart] = useState(null);
2985
2985
  const handlers = useMemo(
2986
2986
  () => ({
@@ -3030,7 +3030,8 @@ const StampPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
3030
3030
  type: PdfAnnotationSubtype.STAMP,
3031
3031
  flags: ["print"],
3032
3032
  pageIndex,
3033
- id: Date.now() + Math.random(),
3033
+ id: uuidV4(),
3034
+ created: /* @__PURE__ */ new Date(),
3034
3035
  rect
3035
3036
  };
3036
3037
  annotationProvides.createAnnotation(pageIndex, anno, { imageData });