@embedpdf/plugin-annotation 2.1.2 → 2.2.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 +37 -2
- package/dist/index.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +13 -6
- 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 +13 -6
- package/dist/react/index.js.map +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +10 -6
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +19 -6
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/react";
|
|
1
|
+
import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/react";
|
|
2
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 { useState, useEffect, useRef, useMemo, useLayoutEffect, Fragment as Fragment$1, useCallback } from "react";
|
|
@@ -59,7 +59,10 @@ function AnnotationContainer({
|
|
|
59
59
|
}) {
|
|
60
60
|
const [preview, setPreview] = useState(trackedAnnotation.object);
|
|
61
61
|
const { provides: annotationCapability } = useAnnotationCapability();
|
|
62
|
+
const { canModifyAnnotations } = useDocumentPermissions(documentId);
|
|
62
63
|
const gestureBaseRef = useRef(null);
|
|
64
|
+
const effectiveIsDraggable = canModifyAnnotations && isDraggable;
|
|
65
|
+
const effectiveIsResizable = canModifyAnnotations && isResizable;
|
|
63
66
|
const annotationProvides = useMemo(
|
|
64
67
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
65
68
|
[annotationCapability, documentId]
|
|
@@ -121,7 +124,11 @@ function AnnotationContainer({
|
|
|
121
124
|
},
|
|
122
125
|
includeVertices: vertexConfig ? true : false
|
|
123
126
|
});
|
|
124
|
-
const
|
|
127
|
+
const guardedOnDoubleClick = useMemo(() => {
|
|
128
|
+
if (!canModifyAnnotations || !onDoubleClick) return void 0;
|
|
129
|
+
return onDoubleClick;
|
|
130
|
+
}, [canModifyAnnotations, onDoubleClick]);
|
|
131
|
+
const doubleProps = useDoublePressProps(guardedOnDoubleClick);
|
|
125
132
|
useEffect(() => {
|
|
126
133
|
setPreview(trackedAnnotation.object);
|
|
127
134
|
}, [trackedAnnotation.object]);
|
|
@@ -129,7 +136,7 @@ function AnnotationContainer({
|
|
|
129
136
|
/* @__PURE__ */ jsxs(
|
|
130
137
|
"div",
|
|
131
138
|
{
|
|
132
|
-
...
|
|
139
|
+
...effectiveIsDraggable && isSelected ? dragProps : {},
|
|
133
140
|
...doubleProps,
|
|
134
141
|
style: {
|
|
135
142
|
position: "absolute",
|
|
@@ -141,7 +148,7 @@ function AnnotationContainer({
|
|
|
141
148
|
outlineOffset: isSelected ? `${outlineOffset}px` : "0px",
|
|
142
149
|
pointerEvents: isSelected ? "auto" : "none",
|
|
143
150
|
touchAction: "none",
|
|
144
|
-
cursor: isSelected &&
|
|
151
|
+
cursor: isSelected && effectiveIsDraggable ? "move" : "default",
|
|
145
152
|
zIndex,
|
|
146
153
|
...style
|
|
147
154
|
},
|
|
@@ -165,7 +172,7 @@ function AnnotationContainer({
|
|
|
165
172
|
}
|
|
166
173
|
return childrenRender;
|
|
167
174
|
})(),
|
|
168
|
-
isSelected &&
|
|
175
|
+
isSelected && effectiveIsResizable && resize.map(
|
|
169
176
|
({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
|
|
170
177
|
key,
|
|
171
178
|
...hProps,
|
|
@@ -179,7 +186,7 @@ function AnnotationContainer({
|
|
|
179
186
|
key
|
|
180
187
|
)
|
|
181
188
|
),
|
|
182
|
-
isSelected && vertices.map(
|
|
189
|
+
isSelected && canModifyAnnotations && vertices.map(
|
|
183
190
|
({ key, ...vProps }) => (vertexUI == null ? void 0 : vertexUI.component) ? vertexUI.component({
|
|
184
191
|
key,
|
|
185
192
|
...vProps,
|