@embedpdf/plugin-annotation 2.9.1 → 2.10.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 +3072 -2652
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +25 -6
- package/dist/lib/annotation-plugin.d.ts +15 -12
- package/dist/lib/handlers/index.d.ts +1 -0
- package/dist/lib/handlers/link.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +9 -1
- package/dist/lib/helpers.d.ts +12 -5
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/reducer.d.ts +1 -1
- package/dist/lib/tools/default-tools.d.ts +147 -301
- package/dist/lib/tools/tools-utils.d.ts +448 -22
- package/dist/lib/tools/types.d.ts +35 -2
- package/dist/lib/types.d.ts +105 -24
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +192 -87
- 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 +192 -87
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared/components/annotations/stamp.d.ts +1 -1
- package/dist/shared/components/preview-renderer.d.ts +4 -3
- package/dist/shared/components/types.d.ts +21 -4
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-annotation.d.ts +2 -2
- package/dist/shared/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/shared-preact/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-preact/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-preact/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-preact/components/preview-renderer.d.ts +4 -3
- package/dist/shared-preact/components/types.d.ts +21 -4
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-preact/hooks/use-ios-zoom-prevention.d.ts +15 -0
- package/dist/shared-react/components/annotation-navigation-handler.d.ts +1 -0
- package/dist/shared-react/components/annotations/link-locked.d.ts +3 -0
- package/dist/shared-react/components/annotations/stamp.d.ts +1 -1
- package/dist/shared-react/components/preview-renderer.d.ts +4 -3
- package/dist/shared-react/components/types.d.ts +21 -4
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-annotation.d.ts +2 -2
- package/dist/shared-react/hooks/use-ios-zoom-prevention.d.ts +16 -0
- package/dist/svelte/components/AnnotationNavigationHandler.svelte.d.ts +3 -0
- package/dist/svelte/components/PreviewRenderer.svelte.d.ts +3 -2
- package/dist/svelte/components/annotations/LinkLockedMode.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/LinkPreview.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/context/renderer-registry.svelte.d.ts +1 -1
- package/dist/svelte/context/types.d.ts +20 -3
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-annotation.svelte.d.ts +1 -1
- package/dist/svelte/hooks/use-ios-zoom-prevention.svelte.d.ts +6 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +401 -228
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-navigation-handler.vue.d.ts +3 -0
- package/dist/vue/components/annotations/link-locked.vue.d.ts +5 -0
- package/dist/vue/components/annotations/link-preview.vue.d.ts +10 -0
- package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
- package/dist/vue/components/preview-renderer.vue.d.ts +3 -2
- package/dist/vue/context/renderer-registry.d.ts +1 -1
- package/dist/vue/context/types.d.ts +20 -3
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-annotation.d.ts +24 -2
- package/dist/vue/hooks/use-ios-zoom-prevention.d.ts +7 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +402 -262
- package/dist/vue/index.js.map +1 -1
- package/package.json +12 -10
package/dist/react/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
-
import {
|
|
2
|
+
import { AnnotationPlugin, initialDocumentState, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, LockModeType, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, getAnnotationCategories, hasLockedFlag, isCategoryLocked, 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
|
-
import { createContext, useState, useCallback, useContext, useRef, useEffect, useMemo,
|
|
5
|
+
import { createContext, useState, useCallback, useContext, useRef, useEffect, useMemo, Fragment as Fragment$1 } from "react";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
|
-
import {
|
|
7
|
+
import { usePlugin, useCapability, useDocumentPermissions, useDocumentState } from "@embedpdf/core/react";
|
|
8
8
|
import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, getContrastStrokeColor, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfBlendMode, PdfAnnotationSubtype, blendModeToCss } from "@embedpdf/models";
|
|
9
9
|
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
|
|
10
10
|
import { useSelectionCapability } from "@embedpdf/plugin-selection/react";
|
|
@@ -61,6 +61,50 @@ const useAnnotation = (documentId) => {
|
|
|
61
61
|
provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
+
function AnnotationNavigationHandler() {
|
|
65
|
+
const { plugin } = useAnnotationPlugin();
|
|
66
|
+
const { provides } = useAnnotationCapability();
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!provides || !plugin) return;
|
|
69
|
+
return provides.onNavigate((event) => {
|
|
70
|
+
if (event.result.outcome === "uri" && plugin.config.autoOpenLinks !== false) {
|
|
71
|
+
window.open(event.result.uri, "_blank", "noopener,noreferrer");
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}, [provides, plugin]);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const MIN_IOS_FOCUS_FONT_PX = 16;
|
|
78
|
+
function detectIOS() {
|
|
79
|
+
try {
|
|
80
|
+
const nav = navigator;
|
|
81
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && (nav == null ? void 0 : nav.maxTouchPoints) > 1;
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let _isIOS;
|
|
87
|
+
function getIsIOS() {
|
|
88
|
+
if (_isIOS === void 0) {
|
|
89
|
+
_isIOS = detectIOS();
|
|
90
|
+
}
|
|
91
|
+
return _isIOS;
|
|
92
|
+
}
|
|
93
|
+
function useIOSZoomPrevention(computedFontPx, active) {
|
|
94
|
+
const isIOS = getIsIOS();
|
|
95
|
+
return useMemo(() => {
|
|
96
|
+
const needsComp = isIOS && active && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;
|
|
97
|
+
const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;
|
|
98
|
+
const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;
|
|
99
|
+
const wrapperStyle = needsComp ? {
|
|
100
|
+
width: `${100 / scaleComp}%`,
|
|
101
|
+
height: `${100 / scaleComp}%`,
|
|
102
|
+
transform: `scale(${scaleComp})`,
|
|
103
|
+
transformOrigin: "top left"
|
|
104
|
+
} : void 0;
|
|
105
|
+
return { needsComp, adjustedFontPx, scaleComp, wrapperStyle };
|
|
106
|
+
}, [isIOS, active, computedFontPx]);
|
|
107
|
+
}
|
|
64
108
|
function AppearanceImage({ appearance, style }) {
|
|
65
109
|
const [imageUrl, setImageUrl] = useState(null);
|
|
66
110
|
const urlRef = useRef(null);
|
|
@@ -1215,6 +1259,7 @@ function createRenderer(entry) {
|
|
|
1215
1259
|
id: entry.id,
|
|
1216
1260
|
matches: (annotation) => entry.matches(annotation),
|
|
1217
1261
|
render: (props) => entry.render(props),
|
|
1262
|
+
renderPreview: entry.renderPreview ? (props) => entry.renderPreview(props) : void 0,
|
|
1218
1263
|
vertexConfig: entry.vertexConfig,
|
|
1219
1264
|
zIndex: entry.zIndex,
|
|
1220
1265
|
defaultBlendMode: entry.defaultBlendMode,
|
|
@@ -1224,7 +1269,9 @@ function createRenderer(entry) {
|
|
|
1224
1269
|
isDraggable: entry.isDraggable,
|
|
1225
1270
|
onDoubleClick: entry.onDoubleClick,
|
|
1226
1271
|
selectOverride: entry.selectOverride,
|
|
1227
|
-
hideSelectionMenu: entry.hideSelectionMenu
|
|
1272
|
+
hideSelectionMenu: entry.hideSelectionMenu,
|
|
1273
|
+
hiddenWhenLocked: entry.hiddenWhenLocked,
|
|
1274
|
+
renderLocked: entry.renderLocked ? (props) => entry.renderLocked(props) : void 0
|
|
1228
1275
|
};
|
|
1229
1276
|
}
|
|
1230
1277
|
const MIN_HIT_AREA_SCREEN_PX$5 = 20;
|
|
@@ -1278,8 +1325,8 @@ function Ink({
|
|
|
1278
1325
|
strokeWidth: hitStrokeWidth,
|
|
1279
1326
|
onPointerDown: onClick,
|
|
1280
1327
|
style: {
|
|
1281
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1282
|
-
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
1328
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1329
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "visibleStroke",
|
|
1283
1330
|
strokeLinecap: "round",
|
|
1284
1331
|
strokeLinejoin: "round"
|
|
1285
1332
|
}
|
|
@@ -1371,8 +1418,8 @@ function Square({
|
|
|
1371
1418
|
strokeWidth: hitStrokeWidth,
|
|
1372
1419
|
onPointerDown: onClick,
|
|
1373
1420
|
style: {
|
|
1374
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1375
|
-
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1421
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1422
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1376
1423
|
}
|
|
1377
1424
|
}
|
|
1378
1425
|
) : /* @__PURE__ */ jsx(
|
|
@@ -1387,8 +1434,8 @@ function Square({
|
|
|
1387
1434
|
strokeWidth: hitStrokeWidth,
|
|
1388
1435
|
onPointerDown: onClick,
|
|
1389
1436
|
style: {
|
|
1390
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1391
|
-
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1437
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1438
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1392
1439
|
}
|
|
1393
1440
|
}
|
|
1394
1441
|
),
|
|
@@ -1495,8 +1542,8 @@ function Circle({
|
|
|
1495
1542
|
strokeWidth: hitStrokeWidth,
|
|
1496
1543
|
onPointerDown: onClick,
|
|
1497
1544
|
style: {
|
|
1498
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1499
|
-
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1545
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1546
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1500
1547
|
}
|
|
1501
1548
|
}
|
|
1502
1549
|
) : /* @__PURE__ */ jsx(
|
|
@@ -1511,8 +1558,8 @@ function Circle({
|
|
|
1511
1558
|
strokeWidth: hitStrokeWidth,
|
|
1512
1559
|
onPointerDown: onClick,
|
|
1513
1560
|
style: {
|
|
1514
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1515
|
-
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1561
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1562
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
|
|
1516
1563
|
}
|
|
1517
1564
|
}
|
|
1518
1565
|
),
|
|
@@ -1612,8 +1659,8 @@ function Line({
|
|
|
1612
1659
|
strokeWidth: hitStrokeWidth,
|
|
1613
1660
|
onPointerDown: onClick,
|
|
1614
1661
|
style: {
|
|
1615
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1616
|
-
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
1662
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1663
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "visibleStroke",
|
|
1617
1664
|
strokeLinecap: "butt"
|
|
1618
1665
|
}
|
|
1619
1666
|
}
|
|
@@ -1628,8 +1675,8 @@ function Line({
|
|
|
1628
1675
|
strokeWidth: hitStrokeWidth,
|
|
1629
1676
|
onPointerDown: onClick,
|
|
1630
1677
|
style: {
|
|
1631
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1632
|
-
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1678
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1679
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1633
1680
|
strokeLinecap: "butt"
|
|
1634
1681
|
}
|
|
1635
1682
|
}
|
|
@@ -1644,8 +1691,8 @@ function Line({
|
|
|
1644
1691
|
strokeWidth: hitStrokeWidth,
|
|
1645
1692
|
onPointerDown: onClick,
|
|
1646
1693
|
style: {
|
|
1647
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1648
|
-
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1694
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1695
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1649
1696
|
strokeLinecap: "butt"
|
|
1650
1697
|
}
|
|
1651
1698
|
}
|
|
@@ -1782,8 +1829,8 @@ function Polyline({
|
|
|
1782
1829
|
strokeWidth: hitStrokeWidth,
|
|
1783
1830
|
onPointerDown: onClick,
|
|
1784
1831
|
style: {
|
|
1785
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1786
|
-
pointerEvents: isSelected ? "none" : "visibleStroke",
|
|
1832
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1833
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "visibleStroke",
|
|
1787
1834
|
strokeLinecap: "butt",
|
|
1788
1835
|
strokeLinejoin: "miter"
|
|
1789
1836
|
}
|
|
@@ -1799,8 +1846,8 @@ function Polyline({
|
|
|
1799
1846
|
strokeWidth: hitStrokeWidth,
|
|
1800
1847
|
onPointerDown: onClick,
|
|
1801
1848
|
style: {
|
|
1802
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1803
|
-
pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1849
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1850
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
|
|
1804
1851
|
strokeLinecap: "butt"
|
|
1805
1852
|
}
|
|
1806
1853
|
}
|
|
@@ -1815,8 +1862,8 @@ function Polyline({
|
|
|
1815
1862
|
strokeWidth: hitStrokeWidth,
|
|
1816
1863
|
onPointerDown: onClick,
|
|
1817
1864
|
style: {
|
|
1818
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1819
|
-
pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1865
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1866
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
|
|
1820
1867
|
strokeLinecap: "butt"
|
|
1821
1868
|
}
|
|
1822
1869
|
}
|
|
@@ -1941,8 +1988,8 @@ function Polygon({
|
|
|
1941
1988
|
strokeWidth: hitStrokeWidth,
|
|
1942
1989
|
onPointerDown: onClick,
|
|
1943
1990
|
style: {
|
|
1944
|
-
cursor: isSelected ? "move" : "pointer",
|
|
1945
|
-
pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
1991
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
1992
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
|
|
1946
1993
|
strokeLinecap: "butt",
|
|
1947
1994
|
strokeLinejoin: "miter"
|
|
1948
1995
|
}
|
|
@@ -2028,8 +2075,8 @@ function Text({
|
|
|
2028
2075
|
position: "absolute",
|
|
2029
2076
|
inset: 0,
|
|
2030
2077
|
zIndex: 2,
|
|
2031
|
-
pointerEvents: isSelected ? "none" : "auto",
|
|
2032
|
-
cursor: isSelected ? "move" : "pointer"
|
|
2078
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "auto",
|
|
2079
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default"
|
|
2033
2080
|
},
|
|
2034
2081
|
onPointerDown: onClick,
|
|
2035
2082
|
children: !appearanceActive && /* @__PURE__ */ jsxs(
|
|
@@ -2078,7 +2125,10 @@ function FreeText({
|
|
|
2078
2125
|
const editingRef = useRef(false);
|
|
2079
2126
|
const { provides: annotationCapability } = useAnnotationCapability();
|
|
2080
2127
|
const annotationProvides = (annotationCapability == null ? void 0 : annotationCapability.forDocument(documentId)) ?? null;
|
|
2081
|
-
const
|
|
2128
|
+
const { adjustedFontPx, wrapperStyle } = useIOSZoomPrevention(
|
|
2129
|
+
annotation.object.fontSize * scale,
|
|
2130
|
+
isEditing
|
|
2131
|
+
);
|
|
2082
2132
|
useEffect(() => {
|
|
2083
2133
|
var _a;
|
|
2084
2134
|
if (isEditing && editorRef.current) {
|
|
@@ -2099,15 +2149,6 @@ function FreeText({
|
|
|
2099
2149
|
}
|
|
2100
2150
|
}
|
|
2101
2151
|
}, [isEditing]);
|
|
2102
|
-
useLayoutEffect(() => {
|
|
2103
|
-
try {
|
|
2104
|
-
const nav = navigator;
|
|
2105
|
-
const ios = /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && (nav == null ? void 0 : nav.maxTouchPoints) > 1;
|
|
2106
|
-
setIsIOS(ios);
|
|
2107
|
-
} catch {
|
|
2108
|
-
setIsIOS(false);
|
|
2109
|
-
}
|
|
2110
|
-
}, []);
|
|
2111
2152
|
const handleBlur = () => {
|
|
2112
2153
|
if (!editingRef.current) return;
|
|
2113
2154
|
editingRef.current = false;
|
|
@@ -2117,12 +2158,6 @@ function FreeText({
|
|
|
2117
2158
|
contents: editorRef.current.innerText.replace(/\u00A0/g, " ")
|
|
2118
2159
|
});
|
|
2119
2160
|
};
|
|
2120
|
-
const computedFontPx = annotation.object.fontSize * scale;
|
|
2121
|
-
const MIN_IOS_FOCUS_FONT_PX = 16;
|
|
2122
|
-
const needsComp = isIOS && isEditing && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;
|
|
2123
|
-
const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;
|
|
2124
|
-
const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;
|
|
2125
|
-
const invScalePercent = needsComp ? 100 / scaleComp : 100;
|
|
2126
2161
|
return /* @__PURE__ */ jsx(
|
|
2127
2162
|
"div",
|
|
2128
2163
|
{
|
|
@@ -2131,7 +2166,7 @@ function FreeText({
|
|
|
2131
2166
|
width: annotation.object.rect.size.width * scale,
|
|
2132
2167
|
height: annotation.object.rect.size.height * scale,
|
|
2133
2168
|
cursor: isSelected && !isEditing ? "move" : "default",
|
|
2134
|
-
pointerEvents: isSelected && !isEditing ? "none" : "auto",
|
|
2169
|
+
pointerEvents: !onClick ? "none" : isSelected && !isEditing ? "none" : "auto",
|
|
2135
2170
|
zIndex: 2,
|
|
2136
2171
|
opacity: appearanceActive ? 0 : 1
|
|
2137
2172
|
},
|
|
@@ -2152,14 +2187,13 @@ function FreeText({
|
|
|
2152
2187
|
display: "flex",
|
|
2153
2188
|
backgroundColor: annotation.object.color ?? annotation.object.backgroundColor,
|
|
2154
2189
|
opacity: annotation.object.opacity,
|
|
2155
|
-
width:
|
|
2156
|
-
height:
|
|
2190
|
+
width: "100%",
|
|
2191
|
+
height: "100%",
|
|
2157
2192
|
lineHeight: "1.18",
|
|
2158
2193
|
overflow: "hidden",
|
|
2159
|
-
cursor: isEditing ? "text" : "pointer",
|
|
2194
|
+
cursor: isEditing ? "text" : onClick ? "pointer" : "default",
|
|
2160
2195
|
outline: "none",
|
|
2161
|
-
|
|
2162
|
-
transformOrigin: "top left"
|
|
2196
|
+
...wrapperStyle
|
|
2163
2197
|
},
|
|
2164
2198
|
contentEditable: isEditing,
|
|
2165
2199
|
...suppressContentEditableWarningProps,
|
|
@@ -2258,8 +2292,8 @@ function Stamp({
|
|
|
2258
2292
|
width: "100%",
|
|
2259
2293
|
height: "100%",
|
|
2260
2294
|
zIndex: 2,
|
|
2261
|
-
pointerEvents: isSelected ? "none" : "auto",
|
|
2262
|
-
cursor: "pointer"
|
|
2295
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "auto",
|
|
2296
|
+
cursor: onClick ? "pointer" : "default"
|
|
2263
2297
|
},
|
|
2264
2298
|
onPointerDown: onClick,
|
|
2265
2299
|
children: /* @__PURE__ */ jsx(
|
|
@@ -2325,8 +2359,8 @@ function Link({
|
|
|
2325
2359
|
fill: "transparent",
|
|
2326
2360
|
onPointerDown: hasIRT ? void 0 : onClick,
|
|
2327
2361
|
style: {
|
|
2328
|
-
cursor: hasIRT ? "default" : isSelected ? "move" : "pointer",
|
|
2329
|
-
pointerEvents: hasIRT ? "none" : isSelected ? "none" : "visible"
|
|
2362
|
+
cursor: hasIRT || !onClick ? "default" : isSelected ? "move" : "pointer",
|
|
2363
|
+
pointerEvents: hasIRT || !onClick ? "none" : isSelected ? "none" : "visible"
|
|
2330
2364
|
}
|
|
2331
2365
|
}
|
|
2332
2366
|
),
|
|
@@ -2599,8 +2633,8 @@ function Caret({
|
|
|
2599
2633
|
strokeWidth: 4,
|
|
2600
2634
|
onPointerDown: onClick,
|
|
2601
2635
|
style: {
|
|
2602
|
-
cursor: isSelected ? "move" : "pointer",
|
|
2603
|
-
pointerEvents: isSelected ? "none" : "visible"
|
|
2636
|
+
cursor: isSelected ? "move" : onClick ? "pointer" : "default",
|
|
2637
|
+
pointerEvents: !onClick ? "none" : isSelected ? "none" : "visible"
|
|
2604
2638
|
}
|
|
2605
2639
|
}
|
|
2606
2640
|
),
|
|
@@ -2620,6 +2654,29 @@ function Caret({
|
|
|
2620
2654
|
}
|
|
2621
2655
|
);
|
|
2622
2656
|
}
|
|
2657
|
+
function LinkLockedMode({
|
|
2658
|
+
annotation,
|
|
2659
|
+
documentId
|
|
2660
|
+
}) {
|
|
2661
|
+
const { provides } = useAnnotationCapability();
|
|
2662
|
+
const handleClick = useCallback(() => {
|
|
2663
|
+
const target = annotation.object.target;
|
|
2664
|
+
if (!target || !provides) return;
|
|
2665
|
+
provides.forDocument(documentId).navigateTarget(target);
|
|
2666
|
+
}, [annotation.object.target, provides, documentId]);
|
|
2667
|
+
return /* @__PURE__ */ jsx(
|
|
2668
|
+
"div",
|
|
2669
|
+
{
|
|
2670
|
+
onClick: handleClick,
|
|
2671
|
+
style: {
|
|
2672
|
+
width: "100%",
|
|
2673
|
+
height: "100%",
|
|
2674
|
+
cursor: "pointer",
|
|
2675
|
+
pointerEvents: "auto"
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
);
|
|
2679
|
+
}
|
|
2623
2680
|
const builtInRenderers = [
|
|
2624
2681
|
// --- Drawing ---
|
|
2625
2682
|
createRenderer({
|
|
@@ -2886,9 +2943,24 @@ const builtInRenderers = [
|
|
|
2886
2943
|
hasIRT: !!currentObject.inReplyToId
|
|
2887
2944
|
}
|
|
2888
2945
|
),
|
|
2946
|
+
renderPreview: ({ data, bounds, scale }) => /* @__PURE__ */ jsx(
|
|
2947
|
+
"div",
|
|
2948
|
+
{
|
|
2949
|
+
style: {
|
|
2950
|
+
position: "absolute",
|
|
2951
|
+
left: 0,
|
|
2952
|
+
top: 0,
|
|
2953
|
+
width: bounds.size.width * scale,
|
|
2954
|
+
height: bounds.size.height * scale,
|
|
2955
|
+
borderBottom: `${data.strokeWidth * scale}px solid ${data.strokeColor}`,
|
|
2956
|
+
backgroundColor: "rgba(0, 0, 255, 0.05)",
|
|
2957
|
+
boxSizing: "border-box"
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
),
|
|
2889
2961
|
interactionDefaults: {
|
|
2890
|
-
isDraggable:
|
|
2891
|
-
isResizable:
|
|
2962
|
+
isDraggable: true,
|
|
2963
|
+
isResizable: true,
|
|
2892
2964
|
isRotatable: false
|
|
2893
2965
|
},
|
|
2894
2966
|
useAppearanceStream: false,
|
|
@@ -2906,7 +2978,8 @@ const builtInRenderers = [
|
|
|
2906
2978
|
}
|
|
2907
2979
|
helpers.selectAnnotation(helpers.pageIndex, annotation.object.id);
|
|
2908
2980
|
},
|
|
2909
|
-
hideSelectionMenu: (a) => !!a.inReplyToId
|
|
2981
|
+
hideSelectionMenu: (a) => !!a.inReplyToId,
|
|
2982
|
+
renderLocked: (props) => /* @__PURE__ */ jsx(LinkLockedMode, { ...props })
|
|
2910
2983
|
})
|
|
2911
2984
|
];
|
|
2912
2985
|
function Annotations(annotationsProps) {
|
|
@@ -2918,6 +2991,7 @@ function Annotations(annotationsProps) {
|
|
|
2918
2991
|
const [allSelectedIds, setAllSelectedIds] = useState([]);
|
|
2919
2992
|
const [editingId, setEditingId] = useState(null);
|
|
2920
2993
|
const [appearanceMap, setAppearanceMap] = useState({});
|
|
2994
|
+
const [lockedMode, setLockedMode] = useState({ type: LockModeType.None });
|
|
2921
2995
|
const prevScaleRef = useRef(scale);
|
|
2922
2996
|
const annotationProvides = useMemo(
|
|
2923
2997
|
() => annotationCapability ? annotationCapability.forDocument(documentId) : null,
|
|
@@ -2929,9 +3003,11 @@ function Annotations(annotationsProps) {
|
|
|
2929
3003
|
const currentState = annotationProvides.getState();
|
|
2930
3004
|
setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
|
|
2931
3005
|
setAllSelectedIds(getSelectedAnnotationIds(currentState));
|
|
3006
|
+
setLockedMode(currentState.locked);
|
|
2932
3007
|
return annotationProvides.onStateChange((state) => {
|
|
2933
3008
|
setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
|
|
2934
3009
|
setAllSelectedIds(getSelectedAnnotationIds(state));
|
|
3010
|
+
setLockedMode(state.locked);
|
|
2935
3011
|
});
|
|
2936
3012
|
}
|
|
2937
3013
|
}, [annotationProvides, pageIndex]);
|
|
@@ -3105,27 +3181,35 @@ function Annotations(annotationsProps) {
|
|
|
3105
3181
|
var _a, _b, _c;
|
|
3106
3182
|
const renderer = resolveRenderer(annotation);
|
|
3107
3183
|
if (!renderer) return null;
|
|
3108
|
-
const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
|
|
3109
|
-
const
|
|
3110
|
-
const
|
|
3184
|
+
const tool = (annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object)) ?? null;
|
|
3185
|
+
const categories = getAnnotationCategories(tool);
|
|
3186
|
+
const locked = hasLockedFlag(annotation.object) || isCategoryLocked(categories, lockedMode);
|
|
3187
|
+
if (locked && renderer.hiddenWhenLocked) return null;
|
|
3188
|
+
const hasRenderLocked = locked && !!renderer.renderLocked;
|
|
3189
|
+
const isSelected = locked ? false : allSelectedIds.includes(annotation.object.id);
|
|
3190
|
+
const isEditing = locked ? false : editingId === annotation.object.id;
|
|
3111
3191
|
const defaults = renderer.interactionDefaults;
|
|
3112
3192
|
const resolvedDraggable = resolveInteractionProp(
|
|
3113
3193
|
tool == null ? void 0 : tool.interaction.isDraggable,
|
|
3114
3194
|
annotation.object,
|
|
3115
3195
|
(defaults == null ? void 0 : defaults.isDraggable) ?? true
|
|
3116
3196
|
);
|
|
3117
|
-
const finalDraggable = renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
|
|
3197
|
+
const finalDraggable = locked ? false : renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
|
|
3118
3198
|
const useAP = ((_a = tool == null ? void 0 : tool.behavior) == null ? void 0 : _a.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
|
|
3119
|
-
const
|
|
3199
|
+
const appearance = hasRenderLocked ? void 0 : useAP ? getAppearanceForAnnotation(annotation) : void 0;
|
|
3200
|
+
const noopSelect = (e) => {
|
|
3201
|
+
e.stopPropagation();
|
|
3202
|
+
};
|
|
3203
|
+
const onSelect = locked ? noopSelect : renderer.selectOverride ? (e) => renderer.selectOverride(e, annotation, selectHelpers) : (e) => handleClick(e, annotation);
|
|
3120
3204
|
return /* @__PURE__ */ jsx(
|
|
3121
3205
|
AnnotationContainer,
|
|
3122
3206
|
{
|
|
3123
3207
|
trackedAnnotation: annotation,
|
|
3124
3208
|
isSelected,
|
|
3125
3209
|
isEditing,
|
|
3126
|
-
isMultiSelected,
|
|
3210
|
+
isMultiSelected: locked ? false : isMultiSelected,
|
|
3127
3211
|
isDraggable: finalDraggable,
|
|
3128
|
-
isResizable: resolveInteractionProp(
|
|
3212
|
+
isResizable: locked ? false : resolveInteractionProp(
|
|
3129
3213
|
tool == null ? void 0 : tool.interaction.isResizable,
|
|
3130
3214
|
annotation.object,
|
|
3131
3215
|
(defaults == null ? void 0 : defaults.isResizable) ?? false
|
|
@@ -3135,15 +3219,15 @@ function Annotations(annotationsProps) {
|
|
|
3135
3219
|
annotation.object,
|
|
3136
3220
|
(defaults == null ? void 0 : defaults.lockAspectRatio) ?? false
|
|
3137
3221
|
),
|
|
3138
|
-
isRotatable: resolveInteractionProp(
|
|
3222
|
+
isRotatable: locked ? false : resolveInteractionProp(
|
|
3139
3223
|
tool == null ? void 0 : tool.interaction.isRotatable,
|
|
3140
3224
|
annotation.object,
|
|
3141
3225
|
(defaults == null ? void 0 : defaults.isRotatable) ?? false
|
|
3142
3226
|
),
|
|
3143
|
-
vertexConfig: renderer.vertexConfig,
|
|
3144
|
-
selectionMenu: ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
|
|
3227
|
+
vertexConfig: locked ? void 0 : renderer.vertexConfig,
|
|
3228
|
+
selectionMenu: locked ? void 0 : ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
|
|
3145
3229
|
onSelect,
|
|
3146
|
-
onDoubleClick: renderer.onDoubleClick ? (e) => {
|
|
3230
|
+
onDoubleClick: locked ? void 0 : renderer.onDoubleClick ? (e) => {
|
|
3147
3231
|
e.stopPropagation();
|
|
3148
3232
|
renderer.onDoubleClick(annotation.object.id, setEditingId);
|
|
3149
3233
|
} : void 0,
|
|
@@ -3152,19 +3236,34 @@ function Annotations(annotationsProps) {
|
|
|
3152
3236
|
annotation.object.blendMode ?? renderer.defaultBlendMode ?? PdfBlendMode.Normal
|
|
3153
3237
|
),
|
|
3154
3238
|
style: (_c = renderer.containerStyle) == null ? void 0 : _c.call(renderer, annotation.object),
|
|
3155
|
-
appearance
|
|
3239
|
+
appearance,
|
|
3156
3240
|
...annotationsProps,
|
|
3157
|
-
children: (currentObject, { appearanceActive }) =>
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3241
|
+
children: (currentObject, { appearanceActive }) => {
|
|
3242
|
+
if (hasRenderLocked) {
|
|
3243
|
+
return renderer.renderLocked({
|
|
3244
|
+
annotation,
|
|
3245
|
+
currentObject,
|
|
3246
|
+
isSelected: false,
|
|
3247
|
+
isEditing: false,
|
|
3248
|
+
scale,
|
|
3249
|
+
pageIndex,
|
|
3250
|
+
documentId,
|
|
3251
|
+
onClick: void 0,
|
|
3252
|
+
appearanceActive
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
return renderer.render({
|
|
3256
|
+
annotation,
|
|
3257
|
+
currentObject,
|
|
3258
|
+
isSelected,
|
|
3259
|
+
isEditing,
|
|
3260
|
+
scale,
|
|
3261
|
+
pageIndex,
|
|
3262
|
+
documentId,
|
|
3263
|
+
onClick: locked ? void 0 : onSelect,
|
|
3264
|
+
appearanceActive
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3168
3267
|
},
|
|
3169
3268
|
annotation.object.id
|
|
3170
3269
|
);
|
|
@@ -3304,8 +3403,9 @@ function TextMarkup({ documentId, pageIndex, scale }) {
|
|
|
3304
3403
|
return null;
|
|
3305
3404
|
}
|
|
3306
3405
|
}
|
|
3307
|
-
function PreviewRenderer({ preview, scale }) {
|
|
3406
|
+
function PreviewRenderer({ toolId, preview, scale }) {
|
|
3308
3407
|
const { bounds } = preview;
|
|
3408
|
+
const registeredRenderers = useRegisteredRenderers();
|
|
3309
3409
|
const style = {
|
|
3310
3410
|
position: "absolute",
|
|
3311
3411
|
left: bounds.origin.x * scale,
|
|
@@ -3355,6 +3455,10 @@ function PreviewRenderer({ preview, scale }) {
|
|
|
3355
3455
|
}
|
|
3356
3456
|
) });
|
|
3357
3457
|
}
|
|
3458
|
+
const match = registeredRenderers.find((r) => r.id === toolId && r.renderPreview);
|
|
3459
|
+
if (match == null ? void 0 : match.renderPreview) {
|
|
3460
|
+
return /* @__PURE__ */ jsx("div", { style, children: match.renderPreview({ data: preview.data, bounds: preview.bounds, scale }) });
|
|
3461
|
+
}
|
|
3358
3462
|
return null;
|
|
3359
3463
|
}
|
|
3360
3464
|
function AnnotationPaintLayer({ documentId, pageIndex, scale }) {
|
|
@@ -3424,7 +3528,7 @@ function AnnotationPaintLayer({ documentId, pageIndex, scale }) {
|
|
|
3424
3528
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3425
3529
|
/* @__PURE__ */ jsx("input", { ref: fileInputRef, type: "file", style: { display: "none" } }),
|
|
3426
3530
|
/* @__PURE__ */ jsx("canvas", { ref: canvasRef, style: { display: "none" } }),
|
|
3427
|
-
Array.from(previews.entries()).map(([toolId, preview]) => /* @__PURE__ */ jsx(PreviewRenderer, { preview, scale }, toolId))
|
|
3531
|
+
Array.from(previews.entries()).map(([toolId, preview]) => /* @__PURE__ */ jsx(PreviewRenderer, { toolId, preview, scale }, toolId))
|
|
3428
3532
|
] });
|
|
3429
3533
|
}
|
|
3430
3534
|
function AnnotationLayer({
|
|
@@ -3505,7 +3609,7 @@ function AnnotationLayer({
|
|
|
3505
3609
|
}
|
|
3506
3610
|
);
|
|
3507
3611
|
}
|
|
3508
|
-
const AnnotationPluginPackage = createPluginPackage(AnnotationPluginPackage$1).addWrapper(AnnotationRendererProvider).build();
|
|
3612
|
+
const AnnotationPluginPackage = createPluginPackage(AnnotationPluginPackage$1).addWrapper(AnnotationRendererProvider).addUtility(AnnotationNavigationHandler).build();
|
|
3509
3613
|
export {
|
|
3510
3614
|
AnnotationLayer,
|
|
3511
3615
|
AnnotationPluginPackage,
|
|
@@ -3515,6 +3619,7 @@ export {
|
|
|
3515
3619
|
useAnnotation,
|
|
3516
3620
|
useAnnotationCapability,
|
|
3517
3621
|
useAnnotationPlugin,
|
|
3622
|
+
useIOSZoomPrevention,
|
|
3518
3623
|
useRegisterRenderers,
|
|
3519
3624
|
useRegisteredRenderers,
|
|
3520
3625
|
useRendererRegistry
|