@embedpdf/plugin-annotation 2.14.0 → 2.14.2
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 +73 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/annotation-plugin.d.ts +25 -0
- package/dist/lib/helpers.d.ts +8 -0
- package/dist/lib/types.d.ts +21 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +27 -18
- 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 +27 -18
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +13 -1
- package/dist/shared/components/types.d.ts +12 -0
- package/dist/shared-preact/components/annotation-container.d.ts +13 -1
- package/dist/shared-preact/components/types.d.ts +12 -0
- package/dist/shared-react/components/annotation-container.d.ts +13 -1
- package/dist/shared-react/components/types.d.ts +12 -0
- package/dist/svelte/components/types.d.ts +12 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +31 -20
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +12 -0
- package/dist/vue/components/annotation-container.vue.d.ts +12 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +57 -41
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +12 -0
- package/package.json +12 -12
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
-
import { AnnotationPlugin, initialDocumentState, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, LockModeType, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp,
|
|
2
|
+
import { AnnotationPlugin, initialDocumentState, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, LockModeType, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, hasNoViewFlag, hasHiddenFlag, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { createContext, useState, useCallback, useContext, useRef, useEffect, useMemo, Fragment as Fragment$1 } from "react";
|
|
@@ -162,6 +162,8 @@ function AnnotationContainer({
|
|
|
162
162
|
blendMode,
|
|
163
163
|
vertexConfig,
|
|
164
164
|
selectionMenu,
|
|
165
|
+
structurallyLocked = false,
|
|
166
|
+
contentLocked = false,
|
|
165
167
|
outlineOffset = 1,
|
|
166
168
|
onDoubleClick,
|
|
167
169
|
onSelect,
|
|
@@ -682,7 +684,9 @@ function AnnotationContainer({
|
|
|
682
684
|
context: {
|
|
683
685
|
type: "annotation",
|
|
684
686
|
annotation: trackedAnnotation,
|
|
685
|
-
pageIndex
|
|
687
|
+
pageIndex,
|
|
688
|
+
structurallyLocked,
|
|
689
|
+
contentLocked
|
|
686
690
|
},
|
|
687
691
|
selected: isSelected,
|
|
688
692
|
placement: {
|
|
@@ -3421,7 +3425,7 @@ function Annotations(annotationsProps) {
|
|
|
3421
3425
|
const [allSelectedIds, setAllSelectedIds] = useState([]);
|
|
3422
3426
|
const [editingId, setEditingId] = useState(null);
|
|
3423
3427
|
const [appearanceMap, setAppearanceMap] = useState({});
|
|
3424
|
-
const [
|
|
3428
|
+
const [, setLockedMode] = useState({ type: LockModeType.None });
|
|
3425
3429
|
const prevScaleRef = useRef(scale);
|
|
3426
3430
|
const annotationProvides = useMemo(
|
|
3427
3431
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
@@ -3611,35 +3615,38 @@ function Annotations(annotationsProps) {
|
|
|
3611
3615
|
var _a, _b, _c;
|
|
3612
3616
|
const renderer = resolveRenderer(annotation);
|
|
3613
3617
|
if (!renderer) return null;
|
|
3618
|
+
if (hasNoViewFlag(annotation.object)) return null;
|
|
3619
|
+
if (hasHiddenFlag(annotation.object)) return null;
|
|
3614
3620
|
const tool = (annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object)) ?? null;
|
|
3615
|
-
const
|
|
3616
|
-
const
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
const
|
|
3620
|
-
const
|
|
3621
|
+
const nonInteractive = annotationProvides ? !annotationProvides.isAnnotationInteractive(annotation.object) : false;
|
|
3622
|
+
const structurallyLocked = annotationProvides ? annotationProvides.isAnnotationStructurallyLocked(annotation.object) : false;
|
|
3623
|
+
const contentLocked = annotationProvides ? annotationProvides.isAnnotationContentLocked(annotation.object) : false;
|
|
3624
|
+
if (nonInteractive && renderer.hiddenWhenLocked) return null;
|
|
3625
|
+
const hasRenderLocked = nonInteractive && !!renderer.renderLocked;
|
|
3626
|
+
const isSelected = nonInteractive ? false : allSelectedIds.includes(annotation.object.id);
|
|
3627
|
+
const isEditing = nonInteractive ? false : editingId === annotation.object.id;
|
|
3621
3628
|
const defaults = renderer.interactionDefaults;
|
|
3622
3629
|
const resolvedDraggable = resolveInteractionProp(
|
|
3623
3630
|
tool == null ? void 0 : tool.interaction.isDraggable,
|
|
3624
3631
|
annotation.object,
|
|
3625
3632
|
(defaults == null ? void 0 : defaults.isDraggable) ?? true
|
|
3626
3633
|
);
|
|
3627
|
-
const finalDraggable =
|
|
3634
|
+
const finalDraggable = structurallyLocked ? false : renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
|
|
3628
3635
|
const useAP = ((_a = tool == null ? void 0 : tool.behavior) == null ? void 0 : _a.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
|
|
3629
3636
|
const appearance = hasRenderLocked ? void 0 : useAP ? getAppearanceForAnnotation(annotation) : void 0;
|
|
3630
3637
|
const noopSelect = (e) => {
|
|
3631
3638
|
e.stopPropagation();
|
|
3632
3639
|
};
|
|
3633
|
-
const onSelect =
|
|
3640
|
+
const onSelect = nonInteractive ? noopSelect : renderer.selectOverride ? (e) => renderer.selectOverride(e, annotation, selectHelpers) : (e) => handleClick(e, annotation);
|
|
3634
3641
|
return /* @__PURE__ */ jsx(
|
|
3635
3642
|
AnnotationContainer,
|
|
3636
3643
|
{
|
|
3637
3644
|
trackedAnnotation: annotation,
|
|
3638
3645
|
isSelected,
|
|
3639
3646
|
isEditing,
|
|
3640
|
-
isMultiSelected:
|
|
3647
|
+
isMultiSelected: nonInteractive ? false : isMultiSelected,
|
|
3641
3648
|
isDraggable: finalDraggable,
|
|
3642
|
-
isResizable:
|
|
3649
|
+
isResizable: structurallyLocked ? false : resolveInteractionProp(
|
|
3643
3650
|
tool == null ? void 0 : tool.interaction.isResizable,
|
|
3644
3651
|
annotation.object,
|
|
3645
3652
|
(defaults == null ? void 0 : defaults.isResizable) ?? false
|
|
@@ -3649,15 +3656,17 @@ function Annotations(annotationsProps) {
|
|
|
3649
3656
|
annotation.object,
|
|
3650
3657
|
(defaults == null ? void 0 : defaults.lockAspectRatio) ?? false
|
|
3651
3658
|
),
|
|
3652
|
-
isRotatable:
|
|
3659
|
+
isRotatable: structurallyLocked ? false : resolveInteractionProp(
|
|
3653
3660
|
tool == null ? void 0 : tool.interaction.isRotatable,
|
|
3654
3661
|
annotation.object,
|
|
3655
3662
|
(defaults == null ? void 0 : defaults.isRotatable) ?? false
|
|
3656
3663
|
),
|
|
3657
|
-
vertexConfig:
|
|
3658
|
-
selectionMenu:
|
|
3664
|
+
vertexConfig: structurallyLocked ? void 0 : renderer.vertexConfig,
|
|
3665
|
+
selectionMenu: nonInteractive ? void 0 : ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
|
|
3666
|
+
structurallyLocked,
|
|
3667
|
+
contentLocked,
|
|
3659
3668
|
onSelect,
|
|
3660
|
-
onDoubleClick:
|
|
3669
|
+
onDoubleClick: nonInteractive || contentLocked ? void 0 : renderer.onDoubleClick ? (e) => {
|
|
3661
3670
|
e.stopPropagation();
|
|
3662
3671
|
renderer.onDoubleClick(annotation.object.id, setEditingId);
|
|
3663
3672
|
} : void 0,
|
|
@@ -3690,7 +3699,7 @@ function Annotations(annotationsProps) {
|
|
|
3690
3699
|
scale,
|
|
3691
3700
|
pageIndex,
|
|
3692
3701
|
documentId,
|
|
3693
|
-
onClick:
|
|
3702
|
+
onClick: nonInteractive ? void 0 : onSelect,
|
|
3694
3703
|
appearanceActive
|
|
3695
3704
|
});
|
|
3696
3705
|
}
|