@embedpdf/plugin-annotation 1.4.1 → 2.0.0-next.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 +1760 -1444
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +58 -19
- package/dist/lib/annotation-plugin.d.ts +14 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/reducer.d.ts +2 -1
- package/dist/lib/selectors.d.ts +10 -8
- package/dist/lib/types.d.ts +53 -10
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +96 -48
- 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 +96 -48
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +4 -3
- package/dist/shared/components/annotation-layer.d.ts +7 -7
- package/dist/shared/components/annotation-paint-layer.d.ts +2 -1
- package/dist/shared/components/annotations/stamp.d.ts +2 -1
- package/dist/shared/components/annotations.d.ts +3 -2
- package/dist/shared/components/render-annotation.d.ts +2 -1
- package/dist/shared/components/text-markup.d.ts +2 -1
- package/dist/shared/components/types.d.ts +7 -7
- package/dist/shared/hooks/use-annotation.d.ts +8 -4
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared-preact/components/annotation-container.d.ts +4 -3
- package/dist/shared-preact/components/annotation-layer.d.ts +7 -7
- package/dist/shared-preact/components/annotation-paint-layer.d.ts +2 -1
- package/dist/shared-preact/components/annotations/stamp.d.ts +2 -1
- package/dist/shared-preact/components/annotations.d.ts +3 -2
- package/dist/shared-preact/components/render-annotation.d.ts +2 -1
- package/dist/shared-preact/components/text-markup.d.ts +2 -1
- package/dist/shared-preact/components/types.d.ts +7 -7
- package/dist/shared-preact/hooks/use-annotation.d.ts +8 -4
- package/dist/shared-preact/index.d.ts +1 -0
- package/dist/shared-react/components/annotation-container.d.ts +4 -3
- package/dist/shared-react/components/annotation-layer.d.ts +7 -7
- package/dist/shared-react/components/annotation-paint-layer.d.ts +2 -1
- package/dist/shared-react/components/annotations/stamp.d.ts +2 -1
- package/dist/shared-react/components/annotations.d.ts +3 -2
- package/dist/shared-react/components/render-annotation.d.ts +2 -1
- package/dist/shared-react/components/text-markup.d.ts +2 -1
- package/dist/shared-react/components/types.d.ts +7 -7
- package/dist/shared-react/hooks/use-annotation.d.ts +8 -4
- package/dist/shared-react/index.d.ts +1 -0
- package/dist/svelte/components/AnnotationContainer.svelte.d.ts +26 -0
- package/dist/svelte/components/AnnotationLayer.svelte.d.ts +27 -0
- package/dist/svelte/components/AnnotationPaintLayer.svelte.d.ts +8 -0
- package/dist/svelte/components/Annotations.svelte.d.ts +22 -0
- package/dist/svelte/components/PreviewRenderer.svelte.d.ts +8 -0
- package/dist/svelte/components/RenderAnnotation.svelte.d.ts +13 -0
- package/dist/svelte/components/TextMarkup.svelte.d.ts +8 -0
- package/dist/svelte/components/annotations/Circle.svelte.d.ts +26 -0
- package/dist/svelte/components/annotations/FreeText.svelte.d.ts +15 -0
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +14 -0
- package/dist/svelte/components/annotations/Line.svelte.d.ts +18 -0
- package/dist/svelte/components/annotations/Polygon.svelte.d.ts +19 -0
- package/dist/svelte/components/annotations/Polyline.svelte.d.ts +17 -0
- package/dist/svelte/components/annotations/Square.svelte.d.ts +16 -0
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +13 -0
- package/dist/svelte/components/annotations/index.d.ts +8 -0
- package/dist/svelte/components/index.d.ts +9 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +13 -0
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +13 -0
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +13 -0
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +13 -0
- package/dist/svelte/components/text-markup/index.d.ts +4 -0
- package/dist/svelte/components/types.d.ts +32 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-annotation.svelte.d.ts +21 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +3083 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/types.d.ts +54 -0
- package/dist/vue/components/annotation-container.vue.d.ts +10 -5
- package/dist/vue/components/annotation-layer.vue.d.ts +13 -7
- package/dist/vue/components/annotation-paint-layer.vue.d.ts +3 -1
- package/dist/vue/components/annotations/circle.vue.d.ts +2 -1
- package/dist/vue/components/annotations/free-text.vue.d.ts +2 -1
- package/dist/vue/components/annotations/ink.vue.d.ts +2 -1
- package/dist/vue/components/annotations/line.vue.d.ts +2 -1
- package/dist/vue/components/annotations/polygon.vue.d.ts +2 -1
- package/dist/vue/components/annotations/polyline.vue.d.ts +2 -1
- package/dist/vue/components/annotations/square.vue.d.ts +2 -1
- package/dist/vue/components/annotations/stamp.vue.d.ts +3 -1
- package/dist/vue/components/annotations.vue.d.ts +7 -3
- package/dist/vue/components/preview-renderer.vue.d.ts +2 -1
- package/dist/vue/components/render-annotation.vue.d.ts +3 -1
- package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -1
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -1
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -1
- package/dist/vue/components/text-markup/underline.vue.d.ts +2 -1
- package/dist/vue/components/text-markup.vue.d.ts +3 -1
- package/dist/vue/hooks/use-annotation.d.ts +21 -2682
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +354 -250
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +23 -0
- package/package.json +20 -12
package/dist/preact/index.js
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { usePlugin, useCapability } from "@embedpdf/core/preact";
|
|
2
|
-
import { AnnotationPlugin,
|
|
1
|
+
import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/preact";
|
|
2
|
+
import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
4
|
import { Fragment as Fragment$1 } from "preact";
|
|
5
5
|
import { useState, useEffect, useRef, useMemo, useLayoutEffect, useCallback } from "preact/hooks";
|
|
6
6
|
import { jsxs, jsx, Fragment } from "preact/jsx-runtime";
|
|
7
|
-
import { PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype } from "@embedpdf/models";
|
|
7
|
+
import { PdfAnnotationBorderStyle, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
|
|
8
8
|
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
|
|
9
9
|
import { useSelectionCapability } from "@embedpdf/plugin-selection/preact";
|
|
10
10
|
import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/preact";
|
|
11
11
|
const suppressContentEditableWarningProps = {};
|
|
12
12
|
const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
|
|
13
13
|
const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
|
|
14
|
-
const useAnnotation = () => {
|
|
14
|
+
const useAnnotation = (documentId) => {
|
|
15
|
+
var _a;
|
|
15
16
|
const { provides } = useAnnotationCapability();
|
|
16
|
-
const [state, setState] = useState(
|
|
17
|
+
const [state, setState] = useState(
|
|
18
|
+
((_a = provides == null ? void 0 : provides.forDocument(documentId)) == null ? void 0 : _a.getState()) ?? initialDocumentState()
|
|
19
|
+
);
|
|
17
20
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
if (!provides) return;
|
|
22
|
+
const scope = provides.forDocument(documentId);
|
|
23
|
+
setState(scope.getState());
|
|
24
|
+
return scope.onStateChange((newState) => {
|
|
25
|
+
setState(newState);
|
|
20
26
|
});
|
|
21
|
-
}, [provides]);
|
|
27
|
+
}, [provides, documentId]);
|
|
22
28
|
return {
|
|
23
29
|
state,
|
|
24
|
-
provides
|
|
30
|
+
provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
|
|
25
31
|
};
|
|
26
32
|
};
|
|
27
33
|
function AnnotationContainer({
|
|
28
34
|
scale,
|
|
35
|
+
documentId,
|
|
29
36
|
pageIndex,
|
|
30
37
|
rotation,
|
|
31
38
|
pageWidth,
|
|
@@ -50,8 +57,12 @@ function AnnotationContainer({
|
|
|
50
57
|
...props
|
|
51
58
|
}) {
|
|
52
59
|
const [preview, setPreview] = useState(trackedAnnotation.object);
|
|
53
|
-
const { provides:
|
|
60
|
+
const { provides: annotationCapability } = useAnnotationCapability();
|
|
54
61
|
const gestureBaseRef = useRef(null);
|
|
62
|
+
const annotationProvides = useMemo(
|
|
63
|
+
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
64
|
+
[annotationCapability, documentId]
|
|
65
|
+
);
|
|
55
66
|
const currentObject = preview ? { ...trackedAnnotation.object, ...preview } : trackedAnnotation.object;
|
|
56
67
|
const HANDLE_COLOR = (resizeUI == null ? void 0 : resizeUI.color) ?? "#007ACC";
|
|
57
68
|
const VERTEX_COLOR = (vertexUI == null ? void 0 : vertexUI.color) ?? "#007ACC";
|
|
@@ -64,7 +75,7 @@ function AnnotationContainer({
|
|
|
64
75
|
constraints: {
|
|
65
76
|
minWidth: 10,
|
|
66
77
|
minHeight: 10,
|
|
67
|
-
boundingBox: { width: pageWidth
|
|
78
|
+
boundingBox: { width: pageWidth, height: pageHeight }
|
|
68
79
|
},
|
|
69
80
|
maintainAspectRatio: lockAspectRatio,
|
|
70
81
|
pageRotation: rotation,
|
|
@@ -79,7 +90,7 @@ function AnnotationContainer({
|
|
|
79
90
|
const transformType = event.transformData.type;
|
|
80
91
|
const base = gestureBaseRef.current ?? currentObject;
|
|
81
92
|
const changes = event.transformData.changes.vertices ? vertexConfig == null ? void 0 : vertexConfig.transformAnnotation(base, event.transformData.changes.vertices) : { rect: event.transformData.changes.rect };
|
|
82
|
-
const patched =
|
|
93
|
+
const patched = annotationCapability == null ? void 0 : annotationCapability.transformAnnotation(base, {
|
|
83
94
|
type: transformType,
|
|
84
95
|
changes,
|
|
85
96
|
metadata: event.transformData.metadata
|
|
@@ -184,7 +195,7 @@ function AnnotationContainer({
|
|
|
184
195
|
]
|
|
185
196
|
}
|
|
186
197
|
),
|
|
187
|
-
/* @__PURE__ */ jsx(
|
|
198
|
+
selectionMenu && /* @__PURE__ */ jsx(
|
|
188
199
|
CounterRotate,
|
|
189
200
|
{
|
|
190
201
|
rect: {
|
|
@@ -198,11 +209,17 @@ function AnnotationContainer({
|
|
|
198
209
|
}
|
|
199
210
|
},
|
|
200
211
|
rotation,
|
|
201
|
-
children: (
|
|
202
|
-
|
|
212
|
+
children: (props2) => selectionMenu({
|
|
213
|
+
...props2,
|
|
214
|
+
context: {
|
|
215
|
+
type: "annotation",
|
|
216
|
+
annotation: trackedAnnotation,
|
|
217
|
+
pageIndex
|
|
218
|
+
},
|
|
203
219
|
selected: isSelected,
|
|
204
|
-
|
|
205
|
-
|
|
220
|
+
placement: {
|
|
221
|
+
suggestTop: false
|
|
222
|
+
}
|
|
206
223
|
})
|
|
207
224
|
}
|
|
208
225
|
)
|
|
@@ -992,6 +1009,7 @@ function FreeText({
|
|
|
992
1009
|
);
|
|
993
1010
|
}
|
|
994
1011
|
function RenderAnnotation({
|
|
1012
|
+
documentId,
|
|
995
1013
|
pageIndex,
|
|
996
1014
|
annotation,
|
|
997
1015
|
scaleFactor = 1,
|
|
@@ -1004,7 +1022,7 @@ function RenderAnnotation({
|
|
|
1004
1022
|
const { width, height } = annotation.rect.size;
|
|
1005
1023
|
useEffect(() => {
|
|
1006
1024
|
if (annotationProvides) {
|
|
1007
|
-
const task = annotationProvides.renderAnnotation({
|
|
1025
|
+
const task = annotationProvides.forDocument(documentId).renderAnnotation({
|
|
1008
1026
|
pageIndex,
|
|
1009
1027
|
annotation,
|
|
1010
1028
|
options: {
|
|
@@ -1029,7 +1047,7 @@ function RenderAnnotation({
|
|
|
1029
1047
|
}
|
|
1030
1048
|
};
|
|
1031
1049
|
}
|
|
1032
|
-
}, [pageIndex, scaleFactor, annotationProvides, annotation.id, width, height]);
|
|
1050
|
+
}, [pageIndex, scaleFactor, annotationProvides, documentId, annotation.id, width, height]);
|
|
1033
1051
|
const handleImageLoad = () => {
|
|
1034
1052
|
if (urlRef.current) {
|
|
1035
1053
|
URL.revokeObjectURL(urlRef.current);
|
|
@@ -1051,7 +1069,14 @@ function RenderAnnotation({
|
|
|
1051
1069
|
}
|
|
1052
1070
|
) });
|
|
1053
1071
|
}
|
|
1054
|
-
function Stamp({
|
|
1072
|
+
function Stamp({
|
|
1073
|
+
isSelected,
|
|
1074
|
+
annotation,
|
|
1075
|
+
documentId,
|
|
1076
|
+
pageIndex,
|
|
1077
|
+
scale,
|
|
1078
|
+
onClick
|
|
1079
|
+
}) {
|
|
1055
1080
|
return /* @__PURE__ */ jsx(
|
|
1056
1081
|
"div",
|
|
1057
1082
|
{
|
|
@@ -1068,6 +1093,7 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
|
|
|
1068
1093
|
children: /* @__PURE__ */ jsx(
|
|
1069
1094
|
RenderAnnotation,
|
|
1070
1095
|
{
|
|
1096
|
+
documentId,
|
|
1071
1097
|
pageIndex,
|
|
1072
1098
|
annotation: { ...annotation.object, id: annotation.object.id },
|
|
1073
1099
|
scaleFactor: scale
|
|
@@ -1077,21 +1103,28 @@ function Stamp({ isSelected, annotation, pageIndex, scale, onClick }) {
|
|
|
1077
1103
|
);
|
|
1078
1104
|
}
|
|
1079
1105
|
function Annotations(annotationsProps) {
|
|
1080
|
-
const { pageIndex, scale, selectionMenu } = annotationsProps;
|
|
1081
|
-
const { provides:
|
|
1106
|
+
const { documentId, pageIndex, scale, selectionMenu } = annotationsProps;
|
|
1107
|
+
const { provides: annotationCapability } = useAnnotationCapability();
|
|
1082
1108
|
const { provides: selectionProvides } = useSelectionCapability();
|
|
1083
1109
|
const [annotations, setAnnotations] = useState([]);
|
|
1084
|
-
const { register } = usePointerHandlers({ pageIndex });
|
|
1110
|
+
const { register } = usePointerHandlers({ documentId, pageIndex });
|
|
1085
1111
|
const [selectionState, setSelectionState] = useState(null);
|
|
1086
1112
|
const [editingId, setEditingId] = useState(null);
|
|
1113
|
+
const annotationProvides = useMemo(
|
|
1114
|
+
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
1115
|
+
[annotationCapability, documentId]
|
|
1116
|
+
);
|
|
1087
1117
|
useEffect(() => {
|
|
1088
1118
|
if (annotationProvides) {
|
|
1089
|
-
annotationProvides.
|
|
1119
|
+
const currentState = annotationProvides.getState();
|
|
1120
|
+
setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
|
|
1121
|
+
setSelectionState(getSelectedAnnotationByPageIndex(currentState, pageIndex));
|
|
1122
|
+
return annotationProvides.onStateChange((state) => {
|
|
1090
1123
|
setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
|
|
1091
1124
|
setSelectionState(getSelectedAnnotationByPageIndex(state, pageIndex));
|
|
1092
1125
|
});
|
|
1093
1126
|
}
|
|
1094
|
-
}, [annotationProvides]);
|
|
1127
|
+
}, [annotationProvides, pageIndex]);
|
|
1095
1128
|
const handlers = useMemo(
|
|
1096
1129
|
() => ({
|
|
1097
1130
|
onPointerDown: (_, pe) => {
|
|
@@ -1117,7 +1150,9 @@ function Annotations(annotationsProps) {
|
|
|
1117
1150
|
[annotationProvides, selectionProvides, editingId, pageIndex]
|
|
1118
1151
|
);
|
|
1119
1152
|
useEffect(() => {
|
|
1120
|
-
return register(handlers
|
|
1153
|
+
return register(handlers, {
|
|
1154
|
+
documentId
|
|
1155
|
+
});
|
|
1121
1156
|
}, [register, handlers]);
|
|
1122
1157
|
return /* @__PURE__ */ jsx(Fragment, { children: annotations.map((annotation) => {
|
|
1123
1158
|
const isSelected = (selectionState == null ? void 0 : selectionState.object.id) === annotation.object.id;
|
|
@@ -1465,6 +1500,7 @@ function Annotations(annotationsProps) {
|
|
|
1465
1500
|
{
|
|
1466
1501
|
isSelected,
|
|
1467
1502
|
annotation,
|
|
1503
|
+
documentId,
|
|
1468
1504
|
pageIndex,
|
|
1469
1505
|
scale,
|
|
1470
1506
|
onClick: (e) => handleClick(e, annotation)
|
|
@@ -1477,7 +1513,7 @@ function Annotations(annotationsProps) {
|
|
|
1477
1513
|
return null;
|
|
1478
1514
|
}) });
|
|
1479
1515
|
}
|
|
1480
|
-
function TextMarkup({ pageIndex, scale }) {
|
|
1516
|
+
function TextMarkup({ documentId, pageIndex, scale }) {
|
|
1481
1517
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1482
1518
|
const { provides: selectionProvides } = useSelectionCapability();
|
|
1483
1519
|
const { provides: annotationProvides } = useAnnotationCapability();
|
|
@@ -1486,17 +1522,16 @@ function TextMarkup({ pageIndex, scale }) {
|
|
|
1486
1522
|
const [activeTool, setActiveTool] = useState(null);
|
|
1487
1523
|
useEffect(() => {
|
|
1488
1524
|
if (!selectionProvides) return;
|
|
1489
|
-
|
|
1490
|
-
setRects(selectionProvides.getHighlightRectsForPage(pageIndex));
|
|
1491
|
-
setBoundingRect(selectionProvides.getBoundingRectForPage(pageIndex));
|
|
1525
|
+
return selectionProvides.forDocument(documentId).onSelectionChange(() => {
|
|
1526
|
+
setRects(selectionProvides.forDocument(documentId).getHighlightRectsForPage(pageIndex));
|
|
1527
|
+
setBoundingRect(selectionProvides.forDocument(documentId).getBoundingRectForPage(pageIndex));
|
|
1492
1528
|
});
|
|
1493
|
-
|
|
1494
|
-
}, [selectionProvides, pageIndex]);
|
|
1529
|
+
}, [selectionProvides, documentId, pageIndex]);
|
|
1495
1530
|
useEffect(() => {
|
|
1496
1531
|
if (!annotationProvides) return;
|
|
1497
|
-
|
|
1498
|
-
return
|
|
1499
|
-
}, [annotationProvides]);
|
|
1532
|
+
setActiveTool(annotationProvides.forDocument(documentId).getActiveTool());
|
|
1533
|
+
return annotationProvides.forDocument(documentId).onActiveToolChange((event) => setActiveTool(event));
|
|
1534
|
+
}, [annotationProvides, documentId]);
|
|
1500
1535
|
if (!boundingRect) return null;
|
|
1501
1536
|
if (!activeTool || !activeTool.defaults) return null;
|
|
1502
1537
|
switch (activeTool.defaults.type) {
|
|
@@ -1632,7 +1667,7 @@ function PreviewRenderer({ preview, scale }) {
|
|
|
1632
1667
|
}
|
|
1633
1668
|
return null;
|
|
1634
1669
|
}
|
|
1635
|
-
function AnnotationPaintLayer({ pageIndex, scale }) {
|
|
1670
|
+
function AnnotationPaintLayer({ documentId, pageIndex, scale }) {
|
|
1636
1671
|
const { plugin: annotationPlugin } = useAnnotationPlugin();
|
|
1637
1672
|
const [previews, setPreviews] = useState(/* @__PURE__ */ new Map());
|
|
1638
1673
|
const fileInputRef = useRef(null);
|
|
@@ -1681,7 +1716,7 @@ function AnnotationPaintLayer({ pageIndex, scale }) {
|
|
|
1681
1716
|
);
|
|
1682
1717
|
useEffect(() => {
|
|
1683
1718
|
if (!annotationPlugin) return;
|
|
1684
|
-
return annotationPlugin.registerPageHandlers(pageIndex, scale, {
|
|
1719
|
+
return annotationPlugin.registerPageHandlers(documentId, pageIndex, scale, {
|
|
1685
1720
|
services,
|
|
1686
1721
|
onPreview: (toolId, state) => {
|
|
1687
1722
|
setPreviews((prev) => {
|
|
@@ -1695,7 +1730,7 @@ function AnnotationPaintLayer({ pageIndex, scale }) {
|
|
|
1695
1730
|
});
|
|
1696
1731
|
}
|
|
1697
1732
|
});
|
|
1698
|
-
}, [pageIndex, scale, annotationPlugin, services]);
|
|
1733
|
+
}, [documentId, pageIndex, scale, annotationPlugin, services]);
|
|
1699
1734
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1700
1735
|
/* @__PURE__ */ jsx("input", { ref: fileInputRef, type: "file", style: { display: "none" } }),
|
|
1701
1736
|
/* @__PURE__ */ jsx("canvas", { ref: canvasRef, style: { display: "none" } }),
|
|
@@ -1704,18 +1739,30 @@ function AnnotationPaintLayer({ pageIndex, scale }) {
|
|
|
1704
1739
|
}
|
|
1705
1740
|
function AnnotationLayer({
|
|
1706
1741
|
style,
|
|
1742
|
+
documentId,
|
|
1707
1743
|
pageIndex,
|
|
1708
|
-
scale,
|
|
1744
|
+
scale: overrideScale,
|
|
1745
|
+
rotation: overrideRotation,
|
|
1709
1746
|
selectionMenu,
|
|
1710
1747
|
resizeUI,
|
|
1711
1748
|
vertexUI,
|
|
1712
|
-
pageWidth,
|
|
1713
|
-
pageHeight,
|
|
1714
|
-
rotation,
|
|
1715
1749
|
selectionOutlineColor,
|
|
1716
1750
|
customAnnotationRenderer,
|
|
1717
1751
|
...props
|
|
1718
1752
|
}) {
|
|
1753
|
+
var _a, _b, _c, _d;
|
|
1754
|
+
const documentState = useDocumentState(documentId);
|
|
1755
|
+
const page = (_b = (_a = documentState == null ? void 0 : documentState.document) == null ? void 0 : _a.pages) == null ? void 0 : _b[pageIndex];
|
|
1756
|
+
const width = ((_c = page == null ? void 0 : page.size) == null ? void 0 : _c.width) ?? 0;
|
|
1757
|
+
const height = ((_d = page == null ? void 0 : page.size) == null ? void 0 : _d.height) ?? 0;
|
|
1758
|
+
const actualScale = useMemo(() => {
|
|
1759
|
+
if (overrideScale !== void 0) return overrideScale;
|
|
1760
|
+
return (documentState == null ? void 0 : documentState.scale) ?? 1;
|
|
1761
|
+
}, [overrideScale, documentState == null ? void 0 : documentState.scale]);
|
|
1762
|
+
const actualRotation = useMemo(() => {
|
|
1763
|
+
if (overrideRotation !== void 0) return overrideRotation;
|
|
1764
|
+
return (documentState == null ? void 0 : documentState.rotation) ?? Rotation.Degree0;
|
|
1765
|
+
}, [overrideRotation, documentState == null ? void 0 : documentState.rotation]);
|
|
1719
1766
|
return /* @__PURE__ */ jsxs(
|
|
1720
1767
|
"div",
|
|
1721
1768
|
{
|
|
@@ -1727,20 +1774,21 @@ function AnnotationLayer({
|
|
|
1727
1774
|
/* @__PURE__ */ jsx(
|
|
1728
1775
|
Annotations,
|
|
1729
1776
|
{
|
|
1777
|
+
documentId,
|
|
1730
1778
|
selectionMenu,
|
|
1731
1779
|
pageIndex,
|
|
1732
|
-
scale,
|
|
1733
|
-
rotation,
|
|
1734
|
-
pageWidth,
|
|
1735
|
-
pageHeight,
|
|
1780
|
+
scale: actualScale,
|
|
1781
|
+
rotation: actualRotation,
|
|
1782
|
+
pageWidth: width,
|
|
1783
|
+
pageHeight: height,
|
|
1736
1784
|
resizeUI,
|
|
1737
1785
|
vertexUI,
|
|
1738
1786
|
selectionOutlineColor,
|
|
1739
1787
|
customAnnotationRenderer
|
|
1740
1788
|
}
|
|
1741
1789
|
),
|
|
1742
|
-
/* @__PURE__ */ jsx(TextMarkup, { pageIndex, scale }),
|
|
1743
|
-
/* @__PURE__ */ jsx(AnnotationPaintLayer, { pageIndex, scale })
|
|
1790
|
+
/* @__PURE__ */ jsx(TextMarkup, { documentId, pageIndex, scale: actualScale }),
|
|
1791
|
+
/* @__PURE__ */ jsx(AnnotationPaintLayer, { documentId, pageIndex, scale: actualScale })
|
|
1744
1792
|
]
|
|
1745
1793
|
}
|
|
1746
1794
|
);
|