@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/preact/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 "preact/jsx-runtime";
|
|
5
5
|
import { createContext, Fragment as Fragment$1 } from "preact";
|
|
@@ -161,6 +161,8 @@ function AnnotationContainer({
|
|
|
161
161
|
blendMode,
|
|
162
162
|
vertexConfig,
|
|
163
163
|
selectionMenu,
|
|
164
|
+
structurallyLocked = false,
|
|
165
|
+
contentLocked = false,
|
|
164
166
|
outlineOffset = 1,
|
|
165
167
|
onDoubleClick,
|
|
166
168
|
onSelect,
|
|
@@ -681,7 +683,9 @@ function AnnotationContainer({
|
|
|
681
683
|
context: {
|
|
682
684
|
type: "annotation",
|
|
683
685
|
annotation: trackedAnnotation,
|
|
684
|
-
pageIndex
|
|
686
|
+
pageIndex,
|
|
687
|
+
structurallyLocked,
|
|
688
|
+
contentLocked
|
|
685
689
|
},
|
|
686
690
|
selected: isSelected,
|
|
687
691
|
placement: {
|
|
@@ -3420,7 +3424,7 @@ function Annotations(annotationsProps) {
|
|
|
3420
3424
|
const [allSelectedIds, setAllSelectedIds] = useState([]);
|
|
3421
3425
|
const [editingId, setEditingId] = useState(null);
|
|
3422
3426
|
const [appearanceMap, setAppearanceMap] = useState({});
|
|
3423
|
-
const [
|
|
3427
|
+
const [, setLockedMode] = useState({ type: LockModeType.None });
|
|
3424
3428
|
const prevScaleRef = useRef(scale);
|
|
3425
3429
|
const annotationProvides = useMemo(
|
|
3426
3430
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
@@ -3610,35 +3614,38 @@ function Annotations(annotationsProps) {
|
|
|
3610
3614
|
var _a, _b, _c;
|
|
3611
3615
|
const renderer = resolveRenderer(annotation);
|
|
3612
3616
|
if (!renderer) return null;
|
|
3617
|
+
if (hasNoViewFlag(annotation.object)) return null;
|
|
3618
|
+
if (hasHiddenFlag(annotation.object)) return null;
|
|
3613
3619
|
const tool = (annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object)) ?? null;
|
|
3614
|
-
const
|
|
3615
|
-
const
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
const
|
|
3619
|
-
const
|
|
3620
|
+
const nonInteractive = annotationProvides ? !annotationProvides.isAnnotationInteractive(annotation.object) : false;
|
|
3621
|
+
const structurallyLocked = annotationProvides ? annotationProvides.isAnnotationStructurallyLocked(annotation.object) : false;
|
|
3622
|
+
const contentLocked = annotationProvides ? annotationProvides.isAnnotationContentLocked(annotation.object) : false;
|
|
3623
|
+
if (nonInteractive && renderer.hiddenWhenLocked) return null;
|
|
3624
|
+
const hasRenderLocked = nonInteractive && !!renderer.renderLocked;
|
|
3625
|
+
const isSelected = nonInteractive ? false : allSelectedIds.includes(annotation.object.id);
|
|
3626
|
+
const isEditing = nonInteractive ? false : editingId === annotation.object.id;
|
|
3620
3627
|
const defaults = renderer.interactionDefaults;
|
|
3621
3628
|
const resolvedDraggable = resolveInteractionProp(
|
|
3622
3629
|
tool == null ? void 0 : tool.interaction.isDraggable,
|
|
3623
3630
|
annotation.object,
|
|
3624
3631
|
(defaults == null ? void 0 : defaults.isDraggable) ?? true
|
|
3625
3632
|
);
|
|
3626
|
-
const finalDraggable =
|
|
3633
|
+
const finalDraggable = structurallyLocked ? false : renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
|
|
3627
3634
|
const useAP = ((_a = tool == null ? void 0 : tool.behavior) == null ? void 0 : _a.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
|
|
3628
3635
|
const appearance = hasRenderLocked ? void 0 : useAP ? getAppearanceForAnnotation(annotation) : void 0;
|
|
3629
3636
|
const noopSelect = (e) => {
|
|
3630
3637
|
e.stopPropagation();
|
|
3631
3638
|
};
|
|
3632
|
-
const onSelect =
|
|
3639
|
+
const onSelect = nonInteractive ? noopSelect : renderer.selectOverride ? (e) => renderer.selectOverride(e, annotation, selectHelpers) : (e) => handleClick(e, annotation);
|
|
3633
3640
|
return /* @__PURE__ */ jsx(
|
|
3634
3641
|
AnnotationContainer,
|
|
3635
3642
|
{
|
|
3636
3643
|
trackedAnnotation: annotation,
|
|
3637
3644
|
isSelected,
|
|
3638
3645
|
isEditing,
|
|
3639
|
-
isMultiSelected:
|
|
3646
|
+
isMultiSelected: nonInteractive ? false : isMultiSelected,
|
|
3640
3647
|
isDraggable: finalDraggable,
|
|
3641
|
-
isResizable:
|
|
3648
|
+
isResizable: structurallyLocked ? false : resolveInteractionProp(
|
|
3642
3649
|
tool == null ? void 0 : tool.interaction.isResizable,
|
|
3643
3650
|
annotation.object,
|
|
3644
3651
|
(defaults == null ? void 0 : defaults.isResizable) ?? false
|
|
@@ -3648,15 +3655,17 @@ function Annotations(annotationsProps) {
|
|
|
3648
3655
|
annotation.object,
|
|
3649
3656
|
(defaults == null ? void 0 : defaults.lockAspectRatio) ?? false
|
|
3650
3657
|
),
|
|
3651
|
-
isRotatable:
|
|
3658
|
+
isRotatable: structurallyLocked ? false : resolveInteractionProp(
|
|
3652
3659
|
tool == null ? void 0 : tool.interaction.isRotatable,
|
|
3653
3660
|
annotation.object,
|
|
3654
3661
|
(defaults == null ? void 0 : defaults.isRotatable) ?? false
|
|
3655
3662
|
),
|
|
3656
|
-
vertexConfig:
|
|
3657
|
-
selectionMenu:
|
|
3663
|
+
vertexConfig: structurallyLocked ? void 0 : renderer.vertexConfig,
|
|
3664
|
+
selectionMenu: nonInteractive ? void 0 : ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
|
|
3665
|
+
structurallyLocked,
|
|
3666
|
+
contentLocked,
|
|
3658
3667
|
onSelect,
|
|
3659
|
-
onDoubleClick:
|
|
3668
|
+
onDoubleClick: nonInteractive || contentLocked ? void 0 : renderer.onDoubleClick ? (e) => {
|
|
3660
3669
|
e.stopPropagation();
|
|
3661
3670
|
renderer.onDoubleClick(annotation.object.id, setEditingId);
|
|
3662
3671
|
} : void 0,
|
|
@@ -3689,7 +3698,7 @@ function Annotations(annotationsProps) {
|
|
|
3689
3698
|
scale,
|
|
3690
3699
|
pageIndex,
|
|
3691
3700
|
documentId,
|
|
3692
|
-
onClick:
|
|
3701
|
+
onClick: nonInteractive ? void 0 : onSelect,
|
|
3693
3702
|
appearanceActive
|
|
3694
3703
|
});
|
|
3695
3704
|
}
|