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