@embedpdf/plugin-annotation 1.2.0 → 1.3.0
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 +115 -53
- package/dist/index.js.map +1 -1
- package/dist/lib/tools/default-tools.d.ts +42 -14
- package/dist/lib/tools/types.d.ts +5 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +78 -41
- 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 +78 -41
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/annotation-container.d.ts +4 -2
- package/dist/shared-preact/components/annotation-layer.d.ts +5 -2
- package/dist/shared-preact/components/annotations.d.ts +3 -1
- package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -3
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -3
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -3
- package/dist/shared-preact/components/text-markup/underline.d.ts +3 -3
- package/dist/shared-preact/types.d.ts +17 -0
- package/dist/shared-react/components/annotation-container.d.ts +4 -2
- package/dist/shared-react/components/annotation-layer.d.ts +5 -2
- package/dist/shared-react/components/annotations.d.ts +3 -1
- package/dist/shared-react/components/text-markup/highlight.d.ts +3 -3
- package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -3
- package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -3
- package/dist/shared-react/components/text-markup/underline.d.ts +3 -3
- package/dist/shared-react/types.d.ts +17 -0
- package/package.json +12 -11
package/dist/preact/index.js
CHANGED
|
@@ -28,10 +28,12 @@ function AnnotationContainer({
|
|
|
28
28
|
selectionMenu,
|
|
29
29
|
outlineOffset = 1,
|
|
30
30
|
onDoubleClick,
|
|
31
|
+
onSelect,
|
|
31
32
|
zIndex = 1,
|
|
32
33
|
resizeUI,
|
|
33
34
|
vertexUI,
|
|
34
35
|
selectionOutlineColor = "#007ACC",
|
|
36
|
+
customAnnotationRenderer,
|
|
35
37
|
...props
|
|
36
38
|
}) {
|
|
37
39
|
const [preview, setPreview] = useState(trackedAnnotation.object);
|
|
@@ -120,7 +122,22 @@ function AnnotationContainer({
|
|
|
120
122
|
},
|
|
121
123
|
...props,
|
|
122
124
|
children: [
|
|
123
|
-
|
|
125
|
+
(() => {
|
|
126
|
+
const customRender = customAnnotationRenderer == null ? void 0 : customAnnotationRenderer({
|
|
127
|
+
annotation: currentObject,
|
|
128
|
+
isSelected,
|
|
129
|
+
scale,
|
|
130
|
+
rotation,
|
|
131
|
+
pageWidth,
|
|
132
|
+
pageHeight,
|
|
133
|
+
pageIndex,
|
|
134
|
+
onSelect
|
|
135
|
+
});
|
|
136
|
+
if (customRender !== null && customRender !== void 0) {
|
|
137
|
+
return customRender;
|
|
138
|
+
}
|
|
139
|
+
return typeof children === "function" ? children(currentObject) : children;
|
|
140
|
+
})(),
|
|
124
141
|
isSelected && isResizable && resize.map(
|
|
125
142
|
({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
|
|
126
143
|
key,
|
|
@@ -183,8 +200,7 @@ function Highlight({
|
|
|
183
200
|
rect,
|
|
184
201
|
scale,
|
|
185
202
|
onClick,
|
|
186
|
-
style
|
|
187
|
-
...props
|
|
203
|
+
style
|
|
188
204
|
}) {
|
|
189
205
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
|
|
190
206
|
"div",
|
|
@@ -203,8 +219,7 @@ function Highlight({
|
|
|
203
219
|
cursor: onClick ? "pointer" : "default",
|
|
204
220
|
zIndex: onClick ? 1 : void 0,
|
|
205
221
|
...style
|
|
206
|
-
}
|
|
207
|
-
...props
|
|
222
|
+
}
|
|
208
223
|
},
|
|
209
224
|
i
|
|
210
225
|
)) });
|
|
@@ -216,8 +231,7 @@ function Underline({
|
|
|
216
231
|
rect,
|
|
217
232
|
scale,
|
|
218
233
|
onClick,
|
|
219
|
-
style
|
|
220
|
-
...props
|
|
234
|
+
style
|
|
221
235
|
}) {
|
|
222
236
|
const thickness = 2 * scale;
|
|
223
237
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
|
|
@@ -237,7 +251,6 @@ function Underline({
|
|
|
237
251
|
zIndex: onClick ? 1 : 0,
|
|
238
252
|
...style
|
|
239
253
|
},
|
|
240
|
-
...props,
|
|
241
254
|
children: /* @__PURE__ */ jsx(
|
|
242
255
|
"div",
|
|
243
256
|
{
|
|
@@ -264,8 +277,7 @@ function Strikeout({
|
|
|
264
277
|
rect,
|
|
265
278
|
scale,
|
|
266
279
|
onClick,
|
|
267
|
-
style
|
|
268
|
-
...props
|
|
280
|
+
style
|
|
269
281
|
}) {
|
|
270
282
|
const thickness = 2 * scale;
|
|
271
283
|
return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
|
|
@@ -285,7 +297,6 @@ function Strikeout({
|
|
|
285
297
|
zIndex: onClick ? 1 : 0,
|
|
286
298
|
...style
|
|
287
299
|
},
|
|
288
|
-
...props,
|
|
289
300
|
children: /* @__PURE__ */ jsx(
|
|
290
301
|
"div",
|
|
291
302
|
{
|
|
@@ -313,8 +324,7 @@ function Squiggly({
|
|
|
313
324
|
rect,
|
|
314
325
|
scale,
|
|
315
326
|
onClick,
|
|
316
|
-
style
|
|
317
|
-
...props
|
|
327
|
+
style
|
|
318
328
|
}) {
|
|
319
329
|
const amplitude = 2 * scale;
|
|
320
330
|
const period = 6 * scale;
|
|
@@ -340,7 +350,6 @@ function Squiggly({
|
|
|
340
350
|
zIndex: onClick ? 1 : 0,
|
|
341
351
|
...style
|
|
342
352
|
},
|
|
343
|
-
...props,
|
|
344
353
|
children: /* @__PURE__ */ jsx(
|
|
345
354
|
"div",
|
|
346
355
|
{
|
|
@@ -1021,6 +1030,7 @@ function RenderAnnotation({
|
|
|
1021
1030
|
style: {
|
|
1022
1031
|
width: "100%",
|
|
1023
1032
|
height: "100%",
|
|
1033
|
+
display: "block",
|
|
1024
1034
|
...style || {}
|
|
1025
1035
|
}
|
|
1026
1036
|
}
|
|
@@ -1035,7 +1045,8 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
|
|
|
1035
1045
|
width: "100%",
|
|
1036
1046
|
height: "100%",
|
|
1037
1047
|
zIndex: 2,
|
|
1038
|
-
pointerEvents: isSelected ? "none" : "auto"
|
|
1048
|
+
pointerEvents: isSelected ? "none" : "auto",
|
|
1049
|
+
cursor: "pointer"
|
|
1039
1050
|
},
|
|
1040
1051
|
onPointerDown: onClick,
|
|
1041
1052
|
onTouchStart: onClick,
|
|
@@ -1096,15 +1107,18 @@ function Annotations(annotationsProps) {
|
|
|
1096
1107
|
return /* @__PURE__ */ jsx(Fragment, { children: annotations.map((annotation) => {
|
|
1097
1108
|
const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
|
|
1098
1109
|
const isEditing = editingId === annotation.object.id;
|
|
1110
|
+
const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
|
|
1099
1111
|
if (isInk(annotation)) {
|
|
1100
1112
|
return /* @__PURE__ */ jsx(
|
|
1101
1113
|
AnnotationContainer,
|
|
1102
1114
|
{
|
|
1103
1115
|
trackedAnnotation: annotation,
|
|
1104
1116
|
isSelected,
|
|
1105
|
-
isDraggable: true,
|
|
1106
|
-
isResizable: true,
|
|
1117
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1118
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1119
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1107
1120
|
selectionMenu,
|
|
1121
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1108
1122
|
style: {
|
|
1109
1123
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1110
1124
|
},
|
|
@@ -1128,9 +1142,11 @@ function Annotations(annotationsProps) {
|
|
|
1128
1142
|
{
|
|
1129
1143
|
trackedAnnotation: annotation,
|
|
1130
1144
|
isSelected,
|
|
1131
|
-
isDraggable: true,
|
|
1132
|
-
isResizable: true,
|
|
1145
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1146
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1147
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1133
1148
|
selectionMenu,
|
|
1149
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1134
1150
|
style: {
|
|
1135
1151
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1136
1152
|
},
|
|
@@ -1154,9 +1170,11 @@ function Annotations(annotationsProps) {
|
|
|
1154
1170
|
{
|
|
1155
1171
|
trackedAnnotation: annotation,
|
|
1156
1172
|
isSelected,
|
|
1157
|
-
isDraggable: true,
|
|
1158
|
-
isResizable: true,
|
|
1173
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1174
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1175
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1159
1176
|
selectionMenu,
|
|
1177
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1160
1178
|
style: {
|
|
1161
1179
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1162
1180
|
},
|
|
@@ -1180,9 +1198,11 @@ function Annotations(annotationsProps) {
|
|
|
1180
1198
|
{
|
|
1181
1199
|
trackedAnnotation: annotation,
|
|
1182
1200
|
isSelected,
|
|
1183
|
-
isDraggable: false,
|
|
1184
|
-
isResizable: false,
|
|
1201
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1202
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1203
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1185
1204
|
selectionMenu,
|
|
1205
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1186
1206
|
zIndex: 0,
|
|
1187
1207
|
style: {
|
|
1188
1208
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
@@ -1199,9 +1219,11 @@ function Annotations(annotationsProps) {
|
|
|
1199
1219
|
{
|
|
1200
1220
|
trackedAnnotation: annotation,
|
|
1201
1221
|
isSelected,
|
|
1202
|
-
isDraggable: false,
|
|
1203
|
-
isResizable: false,
|
|
1222
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1223
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1224
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1204
1225
|
selectionMenu,
|
|
1226
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1205
1227
|
zIndex: 0,
|
|
1206
1228
|
style: {
|
|
1207
1229
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
@@ -1218,9 +1240,11 @@ function Annotations(annotationsProps) {
|
|
|
1218
1240
|
{
|
|
1219
1241
|
trackedAnnotation: annotation,
|
|
1220
1242
|
isSelected,
|
|
1221
|
-
isDraggable: false,
|
|
1222
|
-
isResizable: false,
|
|
1243
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1244
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1245
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1223
1246
|
selectionMenu,
|
|
1247
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1224
1248
|
zIndex: 0,
|
|
1225
1249
|
style: {
|
|
1226
1250
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
@@ -1237,9 +1261,11 @@ function Annotations(annotationsProps) {
|
|
|
1237
1261
|
{
|
|
1238
1262
|
trackedAnnotation: annotation,
|
|
1239
1263
|
isSelected,
|
|
1240
|
-
isDraggable: false,
|
|
1241
|
-
isResizable: false,
|
|
1264
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? false,
|
|
1265
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1266
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1242
1267
|
selectionMenu,
|
|
1268
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1243
1269
|
zIndex: 0,
|
|
1244
1270
|
style: {
|
|
1245
1271
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
|
|
@@ -1256,9 +1282,11 @@ function Annotations(annotationsProps) {
|
|
|
1256
1282
|
{
|
|
1257
1283
|
trackedAnnotation: annotation,
|
|
1258
1284
|
isSelected,
|
|
1259
|
-
isDraggable: true,
|
|
1260
|
-
isResizable: false,
|
|
1285
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1286
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1287
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1261
1288
|
selectionMenu,
|
|
1289
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1262
1290
|
vertexConfig: {
|
|
1263
1291
|
extractVertices: (annotation2) => [
|
|
1264
1292
|
annotation2.linePoints.start,
|
|
@@ -1297,9 +1325,11 @@ function Annotations(annotationsProps) {
|
|
|
1297
1325
|
{
|
|
1298
1326
|
trackedAnnotation: annotation,
|
|
1299
1327
|
isSelected,
|
|
1300
|
-
isDraggable: true,
|
|
1301
|
-
isResizable: false,
|
|
1328
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1329
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1330
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1302
1331
|
selectionMenu,
|
|
1332
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1303
1333
|
vertexConfig: {
|
|
1304
1334
|
extractVertices: (annotation2) => annotation2.vertices,
|
|
1305
1335
|
transformAnnotation: (annotation2, vertices) => {
|
|
@@ -1332,9 +1362,11 @@ function Annotations(annotationsProps) {
|
|
|
1332
1362
|
{
|
|
1333
1363
|
trackedAnnotation: annotation,
|
|
1334
1364
|
isSelected,
|
|
1335
|
-
isDraggable: true,
|
|
1336
|
-
isResizable: false,
|
|
1365
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1366
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? false,
|
|
1367
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1337
1368
|
selectionMenu,
|
|
1369
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1338
1370
|
vertexConfig: {
|
|
1339
1371
|
extractVertices: (annotation2) => annotation2.vertices,
|
|
1340
1372
|
transformAnnotation: (annotation2, vertices) => {
|
|
@@ -1367,9 +1399,11 @@ function Annotations(annotationsProps) {
|
|
|
1367
1399
|
{
|
|
1368
1400
|
trackedAnnotation: annotation,
|
|
1369
1401
|
isSelected,
|
|
1370
|
-
isDraggable: !isEditing,
|
|
1371
|
-
isResizable: true,
|
|
1402
|
+
isDraggable: ((tool == null ? void 0 : tool.interaction.isDraggable) ?? true) && !isEditing,
|
|
1403
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1404
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1372
1405
|
selectionMenu,
|
|
1406
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1373
1407
|
style: {
|
|
1374
1408
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1375
1409
|
},
|
|
@@ -1402,10 +1436,11 @@ function Annotations(annotationsProps) {
|
|
|
1402
1436
|
{
|
|
1403
1437
|
trackedAnnotation: annotation,
|
|
1404
1438
|
isSelected,
|
|
1405
|
-
isDraggable: true,
|
|
1406
|
-
isResizable: true,
|
|
1439
|
+
isDraggable: (tool == null ? void 0 : tool.interaction.isDraggable) ?? true,
|
|
1440
|
+
isResizable: (tool == null ? void 0 : tool.interaction.isResizable) ?? true,
|
|
1441
|
+
lockAspectRatio: (tool == null ? void 0 : tool.interaction.lockAspectRatio) ?? false,
|
|
1407
1442
|
selectionMenu,
|
|
1408
|
-
|
|
1443
|
+
onSelect: (e) => handleClick(e, annotation),
|
|
1409
1444
|
style: {
|
|
1410
1445
|
mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
|
|
1411
1446
|
},
|
|
@@ -1663,6 +1698,7 @@ function AnnotationLayer({
|
|
|
1663
1698
|
pageHeight,
|
|
1664
1699
|
rotation,
|
|
1665
1700
|
selectionOutlineColor,
|
|
1701
|
+
customAnnotationRenderer,
|
|
1666
1702
|
...props
|
|
1667
1703
|
}) {
|
|
1668
1704
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1684,7 +1720,8 @@ function AnnotationLayer({
|
|
|
1684
1720
|
pageHeight,
|
|
1685
1721
|
resizeUI,
|
|
1686
1722
|
vertexUI,
|
|
1687
|
-
selectionOutlineColor
|
|
1723
|
+
selectionOutlineColor,
|
|
1724
|
+
customAnnotationRenderer
|
|
1688
1725
|
}
|
|
1689
1726
|
),
|
|
1690
1727
|
/* @__PURE__ */ jsx(TextMarkup, { pageIndex, scale }),
|