@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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +189 -189
- 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/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +43 -35
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +43 -35
- package/dist/react/index.js.map +1 -1
- package/package.json +9 -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";
|
|
@@ -416,7 +416,7 @@ function AnnotationContainer({
|
|
|
416
416
|
setCurrentRect,
|
|
417
417
|
setCurrentVertices,
|
|
418
418
|
setPreviewObject,
|
|
419
|
-
commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.
|
|
419
|
+
commit: (patch) => annotationProvides == null ? void 0 : annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch)
|
|
420
420
|
});
|
|
421
421
|
useLayoutEffect(() => {
|
|
422
422
|
if (!rectEquals(trackedAnnotation.object.rect, currentRect)) {
|
|
@@ -475,7 +475,7 @@ function AnnotationContainer({
|
|
|
475
475
|
rect: currentRect,
|
|
476
476
|
vertices: v
|
|
477
477
|
});
|
|
478
|
-
annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.
|
|
478
|
+
annotationProvides.updateAnnotation(pageIndex, trackedAnnotation.object.id, patch);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
}
|
|
@@ -985,7 +985,7 @@ function Line({
|
|
|
985
985
|
onTouchStart: onClick,
|
|
986
986
|
style: {
|
|
987
987
|
cursor: isSelected ? "move" : "pointer",
|
|
988
|
-
pointerEvents: "visibleStroke",
|
|
988
|
+
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
989
989
|
stroke: strokeColor,
|
|
990
990
|
strokeWidth,
|
|
991
991
|
strokeLinecap: "butt",
|
|
@@ -1007,7 +1007,7 @@ function Line({
|
|
|
1007
1007
|
cursor: isSelected ? "move" : "pointer",
|
|
1008
1008
|
strokeWidth,
|
|
1009
1009
|
strokeLinecap: "butt",
|
|
1010
|
-
pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
|
|
1010
|
+
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1011
1011
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
1012
1012
|
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
1013
1013
|
}
|
|
@@ -1027,7 +1027,7 @@ function Line({
|
|
|
1027
1027
|
cursor: isSelected ? "move" : "pointer",
|
|
1028
1028
|
strokeWidth,
|
|
1029
1029
|
strokeLinecap: "butt",
|
|
1030
|
-
pointerEvents: endings.end.filled ? "visible" : "visibleStroke",
|
|
1030
|
+
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1031
1031
|
...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
|
|
1032
1032
|
strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
|
|
1033
1033
|
}
|
|
@@ -1111,7 +1111,7 @@ function Polyline({
|
|
|
1111
1111
|
stroke: strokeColor ?? color,
|
|
1112
1112
|
strokeWidth,
|
|
1113
1113
|
cursor: isSelected ? "move" : "pointer",
|
|
1114
|
-
pointerEvents: "visibleStroke",
|
|
1114
|
+
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
1115
1115
|
strokeLinecap: "butt",
|
|
1116
1116
|
strokeLinejoin: "miter"
|
|
1117
1117
|
}
|
|
@@ -1129,7 +1129,7 @@ function Polyline({
|
|
|
1129
1129
|
style: {
|
|
1130
1130
|
cursor: isSelected ? "move" : "pointer",
|
|
1131
1131
|
strokeWidth,
|
|
1132
|
-
pointerEvents: endings.start.filled ? "visible" : "visibleStroke",
|
|
1132
|
+
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1133
1133
|
strokeLinecap: "butt"
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
@@ -1293,7 +1293,7 @@ function FreeText({
|
|
|
1293
1293
|
const handleBlur = () => {
|
|
1294
1294
|
if (!annotationProvides) return;
|
|
1295
1295
|
if (!editorRef.current) return;
|
|
1296
|
-
annotationProvides.updateAnnotation(pageIndex, annotation.
|
|
1296
|
+
annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
|
|
1297
1297
|
contents: editorRef.current.innerText
|
|
1298
1298
|
});
|
|
1299
1299
|
};
|
|
@@ -1409,11 +1409,11 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
|
|
|
1409
1409
|
},
|
|
1410
1410
|
onPointerDown: onClick,
|
|
1411
1411
|
onTouchStart: onClick,
|
|
1412
|
-
children:
|
|
1412
|
+
children: /* @__PURE__ */ jsx(
|
|
1413
1413
|
RenderAnnotation,
|
|
1414
1414
|
{
|
|
1415
1415
|
pageIndex,
|
|
1416
|
-
annotation: { ...annotation.object, id: annotation.
|
|
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.
|
|
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.
|
|
1466
|
-
const isEditing = editingId === annotation.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
1843
|
+
annotation.object.id
|
|
1844
1844
|
);
|
|
1845
1845
|
}
|
|
1846
1846
|
return null;
|
|
@@ -2027,8 +2027,9 @@ const InkPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
|
|
|
2027
2027
|
color: toolColor,
|
|
2028
2028
|
opacity: toolOpacity,
|
|
2029
2029
|
strokeWidth: toolStrokeWidth,
|
|
2030
|
+
created: /* @__PURE__ */ new Date(),
|
|
2030
2031
|
pageIndex,
|
|
2031
|
-
id:
|
|
2032
|
+
id: uuidV4()
|
|
2032
2033
|
};
|
|
2033
2034
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2034
2035
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2185,8 +2186,9 @@ const CirclePaint = ({
|
|
|
2185
2186
|
strokeColor: toolStrokeColor,
|
|
2186
2187
|
strokeStyle: toolStrokeStyle,
|
|
2187
2188
|
strokeDashArray: toolStrokeDashArray,
|
|
2189
|
+
created: /* @__PURE__ */ new Date(),
|
|
2188
2190
|
pageIndex,
|
|
2189
|
-
id:
|
|
2191
|
+
id: uuidV4()
|
|
2190
2192
|
};
|
|
2191
2193
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2192
2194
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2340,7 +2342,8 @@ const SquarePaint = ({
|
|
|
2340
2342
|
strokeStyle: toolStrokeStyle,
|
|
2341
2343
|
strokeDashArray: toolStrokeDashArray,
|
|
2342
2344
|
pageIndex,
|
|
2343
|
-
id:
|
|
2345
|
+
id: uuidV4(),
|
|
2346
|
+
created: /* @__PURE__ */ new Date()
|
|
2344
2347
|
};
|
|
2345
2348
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2346
2349
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2463,7 +2466,8 @@ const PolylinePaint = ({
|
|
|
2463
2466
|
strokeDashArray: toolStrokeDashArray,
|
|
2464
2467
|
lineEndings: toolLineEndings,
|
|
2465
2468
|
pageIndex,
|
|
2466
|
-
id:
|
|
2469
|
+
id: uuidV4(),
|
|
2470
|
+
created: /* @__PURE__ */ new Date()
|
|
2467
2471
|
};
|
|
2468
2472
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2469
2473
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2571,7 +2575,8 @@ const LinePaint = ({ pageIndex, scale, pageWidth, pageHeight, cursor }) => {
|
|
|
2571
2575
|
lineEndings: toolLineEndings,
|
|
2572
2576
|
intent,
|
|
2573
2577
|
pageIndex,
|
|
2574
|
-
id:
|
|
2578
|
+
id: uuidV4(),
|
|
2579
|
+
created: /* @__PURE__ */ new Date()
|
|
2575
2580
|
};
|
|
2576
2581
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2577
2582
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2693,7 +2698,8 @@ const PolygonPaint = ({
|
|
|
2693
2698
|
strokeStyle: toolStrokeStyle,
|
|
2694
2699
|
strokeDashArray: toolStrokeDashArray,
|
|
2695
2700
|
pageIndex,
|
|
2696
|
-
id:
|
|
2701
|
+
id: uuidV4(),
|
|
2702
|
+
created: /* @__PURE__ */ new Date()
|
|
2697
2703
|
};
|
|
2698
2704
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2699
2705
|
annotationProvides.setActiveVariant(null);
|
|
@@ -2884,7 +2890,8 @@ const FreeTextPaint = ({
|
|
|
2884
2890
|
textAlign: toolTextAlign,
|
|
2885
2891
|
verticalAlign: toolVerticalAlign,
|
|
2886
2892
|
pageIndex,
|
|
2887
|
-
id:
|
|
2893
|
+
id: uuidV4(),
|
|
2894
|
+
created: /* @__PURE__ */ new Date()
|
|
2888
2895
|
};
|
|
2889
2896
|
annotationProvides.createAnnotation(pageIndex, anno);
|
|
2890
2897
|
annotationProvides.setActiveVariant(null);
|
|
@@ -3030,7 +3037,8 @@ const StampPaint = ({ pageIndex, scale, pageWidth, pageHeight }) => {
|
|
|
3030
3037
|
type: PdfAnnotationSubtype.STAMP,
|
|
3031
3038
|
flags: ["print"],
|
|
3032
3039
|
pageIndex,
|
|
3033
|
-
id:
|
|
3040
|
+
id: uuidV4(),
|
|
3041
|
+
created: /* @__PURE__ */ new Date(),
|
|
3034
3042
|
rect
|
|
3035
3043
|
};
|
|
3036
3044
|
annotationProvides.createAnnotation(pageIndex, anno, { imageData });
|