pdf-tsx 0.9.0 → 0.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/README.md +2 -0
- package/dist/cjs/components/PDFSidebar.cjs +1 -1
- package/dist/cjs/components/PDFSidebar.module.cjs +1 -1
- package/dist/cjs/components/PDFViewer.cjs +1 -1
- package/dist/cjs/components/PDFViewer.module.cjs +1 -1
- package/dist/cjs/components/features/PDFAnnotations.cjs +1 -1
- package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
- package/dist/cjs/components/features/PDFAttachments.cjs +1 -1
- package/dist/cjs/components/features/PDFAttachments.module.cjs +1 -1
- package/dist/cjs/components/features/PDFChangeFile.cjs +1 -1
- package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -1
- package/dist/cjs/components/features/PDFNavigation.cjs +1 -1
- package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -1
- package/dist/cjs/components/features/PDFOutline.cjs +1 -1
- package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
- package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
- package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
- package/dist/cjs/components/features/PDFRotationControl.cjs +1 -1
- package/dist/cjs/components/features/PDFSearch.cjs +1 -1
- package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
- package/dist/cjs/components/features/PDFSidebarToggle.cjs +1 -1
- package/dist/cjs/components/features/PDFSignatures.cjs +1 -1
- package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
- package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -1
- package/dist/cjs/components/features/PDFThumbnails.cjs +1 -1
- package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
- package/dist/cjs/components/features/PDFZoomControls.cjs +1 -1
- package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
- package/dist/cjs/components/ui/PDFToolbar.cjs +1 -1
- package/dist/cjs/components/ui/PDFToolbar.module.cjs +1 -1
- package/dist/cjs/components/ui/PDFToolbarItem.cjs +1 -1
- package/dist/cjs/components/ui/ToolbarButton.cjs +1 -1
- package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
- package/dist/cjs/components/ui/icons.cjs +1 -1
- package/dist/cjs/context/ThemeContext.cjs +1 -1
- package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -1
- package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -1
- package/dist/cjs/hooks/useOutline.cjs +1 -1
- package/dist/cjs/hooks/useOverlayRects.cjs +1 -1
- package/dist/cjs/hooks/usePDFLoader.cjs +1 -1
- package/dist/cjs/hooks/useScrollTracking.cjs +1 -1
- package/dist/cjs/hooks/useTextLayer.cjs +1 -1
- package/dist/cjs/hooks/useTextSearch.cjs +1 -1
- package/dist/cjs/hooks/useThumbnails.cjs +1 -1
- package/dist/cjs/pdf-tsx.css +1 -1
- package/dist/components/features/PDFSearch.d.ts +1 -1
- package/dist/components/features/PDFSidebarToggle.d.ts +1 -1
- package/dist/components/features/PDFZoomControls.d.ts +1 -1
- package/dist/context/ThemeContext.d.ts +1 -1
- package/dist/es/components/PDFSidebar.js +25 -39
- package/dist/es/components/PDFSidebar.module.js +9 -9
- package/dist/es/components/PDFViewer.js +213 -253
- package/dist/es/components/PDFViewer.module.js +15 -15
- package/dist/es/components/features/PDFAnnotations.js +54 -62
- package/dist/es/components/features/PDFAnnotations.module.js +12 -12
- package/dist/es/components/features/PDFAttachments.js +52 -70
- package/dist/es/components/features/PDFAttachments.module.js +8 -8
- package/dist/es/components/features/PDFChangeFile.js +13 -24
- package/dist/es/components/features/PDFDownloadButton.js +10 -13
- package/dist/es/components/features/PDFNavigation.js +38 -59
- package/dist/es/components/features/PDFNavigation.module.js +3 -3
- package/dist/es/components/features/PDFOutline.js +66 -83
- package/dist/es/components/features/PDFOutline.module.js +5 -5
- package/dist/es/components/features/PDFPageFit.js +18 -23
- package/dist/es/components/features/PDFPrintButton.js +14 -17
- package/dist/es/components/features/PDFRotationControl.js +7 -13
- package/dist/es/components/features/PDFSearch.js +60 -69
- package/dist/es/components/features/PDFSearch.module.js +5 -5
- package/dist/es/components/features/PDFSidebarToggle.js +8 -13
- package/dist/es/components/features/PDFSignatures.js +116 -139
- package/dist/es/components/features/PDFSignatures.module.js +16 -16
- package/dist/es/components/features/PDFThemeToggle.js +10 -11
- package/dist/es/components/features/PDFThumbnails.js +25 -34
- package/dist/es/components/features/PDFThumbnails.module.js +9 -9
- package/dist/es/components/features/PDFZoomControls.js +21 -36
- package/dist/es/components/features/PDFZoomControls.module.js +1 -1
- package/dist/es/components/ui/PDFToolbar.js +53 -83
- package/dist/es/components/ui/PDFToolbar.module.js +9 -9
- package/dist/es/components/ui/PDFToolbarItem.js +10 -19
- package/dist/es/components/ui/ToolbarButton.js +8 -11
- package/dist/es/components/ui/ToolbarButton.module.js +2 -2
- package/dist/es/components/ui/icons.js +5 -16
- package/dist/es/context/ThemeContext.js +28 -38
- package/dist/es/hooks/useAnnotationLayer.js +33 -42
- package/dist/es/hooks/useKeyboardShortcuts.js +25 -34
- package/dist/es/hooks/useOutline.js +18 -23
- package/dist/es/hooks/useOverlayRects.js +42 -51
- package/dist/es/hooks/usePDFLoader.js +13 -16
- package/dist/es/hooks/useScrollTracking.js +24 -25
- package/dist/es/hooks/useTextLayer.js +34 -43
- package/dist/es/hooks/useTextSearch.js +31 -38
- package/dist/es/hooks/useThumbnails.js +33 -44
- package/dist/es/pdf-tsx.css +1 -1
- package/dist/hooks/useAttachments.d.ts +1 -1
- package/dist/hooks/useOutline.d.ts +1 -1
- package/dist/hooks/useOverlayRects.d.ts +1 -1
- package/dist/hooks/usePDFRenderer.d.ts +1 -1
- package/dist/hooks/useSignatures.d.ts +1 -1
- package/dist/hooks/useThumbnails.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1,115 +1,85 @@
|
|
|
1
1
|
import { ToolbarButton as e } from "./ToolbarButton.js";
|
|
2
2
|
import t from "./PDFToolbar.module.js";
|
|
3
3
|
import { PDFToolbarDropdownContext as n } from "./PDFToolbarDropdownContext.js";
|
|
4
|
-
import {
|
|
5
|
-
import i, { useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
4
|
+
import r, { useCallback as i, useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
6
5
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
6
|
//#region src/components/ui/PDFToolbar.tsx
|
|
8
7
|
var d = 40;
|
|
9
|
-
function f(
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
let S = s(x), C;
|
|
13
|
-
f[1] === Symbol.for("react.memo_cache_sentinel") ? (C = [], f[1] = C) : C = f[1];
|
|
14
|
-
let w = s(C), [T, E] = c(null), [D, O] = c(!1), k = s(null), A;
|
|
15
|
-
f[2] === _ ? A = f[3] : (A = i.Children.toArray(_), f[2] = _, f[3] = A);
|
|
16
|
-
let j = A, M;
|
|
17
|
-
f[4] === Symbol.for("react.memo_cache_sentinel") ? (M = () => {
|
|
18
|
-
let e = b.current, t = w.current;
|
|
8
|
+
function f({ children: f, overflowIcon: p = "···" }) {
|
|
9
|
+
let m = s(null), h = s([]), g = s([]), [_, v] = c(null), [y, b] = c(!1), x = s(null), S = r.Children.toArray(f), C = i(() => {
|
|
10
|
+
let e = m.current, t = g.current;
|
|
19
11
|
if (!e || t.length === 0) return;
|
|
20
12
|
let n = e.offsetWidth;
|
|
21
|
-
if (t.reduce(
|
|
22
|
-
|
|
13
|
+
if (t.reduce((e, t) => e + t, 0) <= n) {
|
|
14
|
+
v(null);
|
|
23
15
|
return;
|
|
24
16
|
}
|
|
25
17
|
let r = 0, i = 0;
|
|
26
18
|
for (let e = 0; e < t.length && r + t[e] + d <= n; e++) r += t[e], i++;
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let F;
|
|
34
|
-
f[7] === Symbol.for("react.memo_cache_sentinel") ? (F = [], f[7] = F) : F = f[7], o(P, F);
|
|
35
|
-
let I, L;
|
|
36
|
-
f[8] === Symbol.for("react.memo_cache_sentinel") ? (I = () => {
|
|
37
|
-
let e = b.current;
|
|
19
|
+
v(i);
|
|
20
|
+
}, []);
|
|
21
|
+
o(() => {
|
|
22
|
+
g.current = h.current.slice(0, S.length).map((e) => e?.offsetWidth ?? 0), C();
|
|
23
|
+
}, []), a(() => {
|
|
24
|
+
let e = m.current;
|
|
38
25
|
if (!e) return;
|
|
39
|
-
let t = new ResizeObserver(() =>
|
|
26
|
+
let t = new ResizeObserver(() => C());
|
|
40
27
|
return t.observe(e), () => t.disconnect();
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
f[10] === D ? (R = f[11], z = f[12]) : (R = () => {
|
|
44
|
-
if (!D) return;
|
|
28
|
+
}, [C]), a(() => {
|
|
29
|
+
if (!y) return;
|
|
45
30
|
let e = (e) => {
|
|
46
|
-
|
|
31
|
+
x.current?.contains(e.target) || b(!1);
|
|
47
32
|
};
|
|
48
33
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
49
|
-
},
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
}, [y]);
|
|
35
|
+
let w = _ !== null && _ < S.length, T = w ? S.slice(_) : [];
|
|
36
|
+
return /* @__PURE__ */ u("div", {
|
|
37
|
+
ref: m,
|
|
38
|
+
className: t.toolbar,
|
|
39
|
+
children: [S.map((e, n) => /* @__PURE__ */ l("div", {
|
|
54
40
|
ref: (e) => {
|
|
55
|
-
|
|
41
|
+
h.current[n] = e;
|
|
56
42
|
},
|
|
57
43
|
className: t.item,
|
|
58
|
-
style:
|
|
44
|
+
style: _ !== null && n >= _ ? { display: "none" } : void 0,
|
|
59
45
|
children: e
|
|
60
|
-
}, n)),
|
|
61
|
-
ref:
|
|
46
|
+
}, n)), w && /* @__PURE__ */ u("div", {
|
|
47
|
+
ref: x,
|
|
62
48
|
className: t.overflowWrapper,
|
|
63
49
|
children: [/* @__PURE__ */ l(e, {
|
|
64
|
-
onClick: () =>
|
|
50
|
+
onClick: () => b((e) => !e),
|
|
65
51
|
"aria-label": "Altre opzioni",
|
|
66
|
-
"aria-expanded":
|
|
52
|
+
"aria-expanded": y,
|
|
67
53
|
"aria-haspopup": "true",
|
|
68
54
|
title: "Altre opzioni",
|
|
69
|
-
className:
|
|
70
|
-
children:
|
|
71
|
-
}),
|
|
55
|
+
className: y ? t.overflowBtnActive : void 0,
|
|
56
|
+
children: p
|
|
57
|
+
}), y && /* @__PURE__ */ l("div", {
|
|
72
58
|
className: t.dropdown,
|
|
73
59
|
role: "menu",
|
|
74
|
-
children:
|
|
60
|
+
children: T.map((e, i) => {
|
|
61
|
+
let a = r.isValidElement(e) ? e.type.toolbarLabel : void 0;
|
|
62
|
+
return /* @__PURE__ */ l("div", {
|
|
63
|
+
className: t.dropdownItem,
|
|
64
|
+
role: "menuitem",
|
|
65
|
+
children: a ? /* @__PURE__ */ u("div", {
|
|
66
|
+
className: t.labeledItem,
|
|
67
|
+
children: [/* @__PURE__ */ l("span", {
|
|
68
|
+
className: t.itemLabel,
|
|
69
|
+
children: a
|
|
70
|
+
}), /* @__PURE__ */ l("div", {
|
|
71
|
+
className: t.itemContent,
|
|
72
|
+
children: e
|
|
73
|
+
})]
|
|
74
|
+
}) : /* @__PURE__ */ l(n.Provider, {
|
|
75
|
+
value: !0,
|
|
76
|
+
children: e
|
|
77
|
+
})
|
|
78
|
+
}, i);
|
|
79
|
+
})
|
|
75
80
|
})]
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
let G;
|
|
79
|
-
return f[25] !== V || f[26] !== H || f[27] !== U || f[28] !== W ? (G = /* @__PURE__ */ u("div", {
|
|
80
|
-
ref: V,
|
|
81
|
-
className: H,
|
|
82
|
-
children: [U, W]
|
|
83
|
-
}), f[25] = V, f[26] = H, f[27] = U, f[28] = W, f[29] = G) : G = f[29], G;
|
|
84
|
-
}
|
|
85
|
-
function p(e, r) {
|
|
86
|
-
let a = i.isValidElement(e) ? e.type.toolbarLabel : void 0;
|
|
87
|
-
return /* @__PURE__ */ l("div", {
|
|
88
|
-
className: t.dropdownItem,
|
|
89
|
-
role: "menuitem",
|
|
90
|
-
children: a ? /* @__PURE__ */ u("div", {
|
|
91
|
-
className: t.labeledItem,
|
|
92
|
-
children: [/* @__PURE__ */ l("span", {
|
|
93
|
-
className: t.itemLabel,
|
|
94
|
-
children: a
|
|
95
|
-
}), /* @__PURE__ */ l("div", {
|
|
96
|
-
className: t.itemContent,
|
|
97
|
-
children: e
|
|
98
|
-
})]
|
|
99
|
-
}) : /* @__PURE__ */ l(n.Provider, {
|
|
100
|
-
value: !0,
|
|
101
|
-
children: e
|
|
102
|
-
})
|
|
103
|
-
}, r);
|
|
104
|
-
}
|
|
105
|
-
function m(e) {
|
|
106
|
-
return !e;
|
|
107
|
-
}
|
|
108
|
-
function h(e) {
|
|
109
|
-
return e?.offsetWidth ?? 0;
|
|
110
|
-
}
|
|
111
|
-
function g(e, t) {
|
|
112
|
-
return e + t;
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
113
83
|
}
|
|
114
84
|
//#endregion
|
|
115
85
|
export { f as PDFToolbar };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
toolbar: "
|
|
3
|
-
item: "
|
|
4
|
-
overflowWrapper: "
|
|
5
|
-
overflowBtnActive: "
|
|
6
|
-
dropdown: "
|
|
7
|
-
dropdownItem: "
|
|
8
|
-
labeledItem: "
|
|
9
|
-
itemContent: "
|
|
10
|
-
itemLabel: "
|
|
2
|
+
toolbar: "_toolbar_xoqxq_1",
|
|
3
|
+
item: "_item_xoqxq_9",
|
|
4
|
+
overflowWrapper: "_overflowWrapper_xoqxq_15",
|
|
5
|
+
overflowBtnActive: "_overflowBtnActive_xoqxq_21",
|
|
6
|
+
dropdown: "_dropdown_xoqxq_26",
|
|
7
|
+
dropdownItem: "_dropdownItem_xoqxq_41",
|
|
8
|
+
labeledItem: "_labeledItem_xoqxq_53",
|
|
9
|
+
itemContent: "_itemContent_xoqxq_60",
|
|
10
|
+
itemLabel: "_itemLabel_xoqxq_66"
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
export { e as default };
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import e from "./PDFToolbar.module.js";
|
|
2
2
|
import { PDFToolbarDropdownContext as t } from "./PDFToolbarDropdownContext.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as n } from "react";
|
|
4
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
5
|
//#region src/components/ui/PDFToolbarItem.tsx
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
if (!r(t) || !u) {
|
|
10
|
-
let e;
|
|
11
|
-
return c[0] === l ? e = c[1] : (e = /* @__PURE__ */ a(i, { children: l }), c[0] = l, c[1] = e), e;
|
|
12
|
-
}
|
|
13
|
-
let d;
|
|
14
|
-
c[2] === u ? d = c[3] : (d = /* @__PURE__ */ a("span", {
|
|
15
|
-
className: e.itemLabel,
|
|
16
|
-
children: u
|
|
17
|
-
}), c[2] = u, c[3] = d);
|
|
18
|
-
let f;
|
|
19
|
-
return c[4] !== l || c[5] !== d ? (f = /* @__PURE__ */ o("div", {
|
|
6
|
+
function o({ children: o, label: s }) {
|
|
7
|
+
return !n(t) || !s ? /* @__PURE__ */ i(r, { children: o }) : /* @__PURE__ */ a("div", {
|
|
20
8
|
className: e.labeledItem,
|
|
21
|
-
children: [
|
|
22
|
-
|
|
9
|
+
children: [/* @__PURE__ */ i("span", {
|
|
10
|
+
className: e.itemLabel,
|
|
11
|
+
children: s
|
|
12
|
+
}), o]
|
|
13
|
+
});
|
|
23
14
|
}
|
|
24
15
|
//#endregion
|
|
25
|
-
export {
|
|
16
|
+
export { o as PDFToolbarItem };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import e from "./ToolbarButton.module.js";
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
3
|
//#region src/components/ui/ToolbarButton.tsx
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...s
|
|
12
|
-
}), i[4] = s, i[5] = l, i[6] = u) : u = i[6], u;
|
|
4
|
+
function n({ $primary: n, className: r, ...i }) {
|
|
5
|
+
let a = n ? `${e.btn} ${e.primary}` : e.btn;
|
|
6
|
+
return /* @__PURE__ */ t("button", {
|
|
7
|
+
className: r ? `${a} ${r}` : a,
|
|
8
|
+
...i
|
|
9
|
+
});
|
|
13
10
|
}
|
|
14
11
|
//#endregion
|
|
15
|
-
export {
|
|
12
|
+
export { n as ToolbarButton };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { c as e } from "react/compiler-runtime";
|
|
2
1
|
import "react";
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
4
3
|
//#region src/components/ui/icons.tsx
|
|
5
|
-
var
|
|
4
|
+
var t = (t, n = 16) => /* @__PURE__ */ e("svg", {
|
|
6
5
|
xmlns: "http://www.w3.org/2000/svg",
|
|
7
6
|
width: n,
|
|
8
7
|
height: n,
|
|
@@ -12,17 +11,7 @@ var n = (e, n = 16) => /* @__PURE__ */ t("svg", {
|
|
|
12
11
|
strokeWidth: 2,
|
|
13
12
|
strokeLinecap: "round",
|
|
14
13
|
strokeLinejoin: "round",
|
|
15
|
-
children:
|
|
16
|
-
}), r = (
|
|
17
|
-
let i = e(3), { size: a } = r, o;
|
|
18
|
-
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("polyline", { points: "9 18 15 12 9 6" }), i[0] = o) : o = i[0];
|
|
19
|
-
let s;
|
|
20
|
-
return i[1] === a ? s = i[2] : (s = n(o, a), i[1] = a, i[2] = s), s;
|
|
21
|
-
}, i = (r) => {
|
|
22
|
-
let i = e(3), { size: a } = r, o;
|
|
23
|
-
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("polyline", { points: "6 9 12 15 18 9" }), i[0] = o) : o = i[0];
|
|
24
|
-
let s;
|
|
25
|
-
return i[1] === a ? s = i[2] : (s = n(o, a), i[1] = a, i[2] = s), s;
|
|
26
|
-
};
|
|
14
|
+
children: t
|
|
15
|
+
}), n = ({ size: n }) => t(/* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" }), n), r = ({ size: n }) => t(/* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }), n);
|
|
27
16
|
//#endregion
|
|
28
|
-
export {
|
|
17
|
+
export { r as IconChevronDown, n as IconChevronRight };
|
|
@@ -1,46 +1,36 @@
|
|
|
1
1
|
import { darkTheme as e, lightTheme as t, themeToCssVars as n } from "../theme.js";
|
|
2
2
|
import { ThemeContext as r } from "./themeContextValue.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as i, useMemo as a, useState as o } from "react";
|
|
4
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
6
5
|
//#region src/context/ThemeContext.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
l[0] !== p || l[1] !== d?.dark || l[2] !== d?.light ? (g = p ? {
|
|
6
|
+
function c({ children: c, themeOverrides: l, defaultTheme: u = "light" }) {
|
|
7
|
+
let [d, f] = o(u === "dark"), p = a(() => d ? {
|
|
10
8
|
...e,
|
|
11
|
-
...
|
|
9
|
+
...l?.dark
|
|
12
10
|
} : {
|
|
13
11
|
...t,
|
|
14
|
-
...
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
let C;
|
|
37
|
-
return l[14] !== y || l[15] !== S ? (C = /* @__PURE__ */ o(r.Provider, {
|
|
38
|
-
value: y,
|
|
39
|
-
children: S
|
|
40
|
-
}), l[14] = y, l[15] = S, l[16] = C) : C = l[16], C;
|
|
41
|
-
}
|
|
42
|
-
function c(e) {
|
|
43
|
-
return !e;
|
|
12
|
+
...l?.light
|
|
13
|
+
}, [d, l]), m = a(() => n(p), [p]), h = i(() => f((e) => !e), []), g = a(() => ({
|
|
14
|
+
isDark: d,
|
|
15
|
+
toggleTheme: h,
|
|
16
|
+
theme: p
|
|
17
|
+
}), [
|
|
18
|
+
d,
|
|
19
|
+
h,
|
|
20
|
+
p
|
|
21
|
+
]);
|
|
22
|
+
return /* @__PURE__ */ s(r.Provider, {
|
|
23
|
+
value: g,
|
|
24
|
+
children: /* @__PURE__ */ s("div", {
|
|
25
|
+
style: {
|
|
26
|
+
...m,
|
|
27
|
+
fontFamily: "var(--pdf-font-family)",
|
|
28
|
+
height: "100%",
|
|
29
|
+
width: "100%"
|
|
30
|
+
},
|
|
31
|
+
children: c
|
|
32
|
+
})
|
|
33
|
+
});
|
|
44
34
|
}
|
|
45
35
|
//#endregion
|
|
46
|
-
export {
|
|
36
|
+
export { c as ThemeProvider };
|
|
@@ -1,70 +1,61 @@
|
|
|
1
1
|
import { isSafeUrl as e } from "../utils/url.js";
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect as n, useState as r } from "react";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
4
3
|
import "pdfjs-dist";
|
|
5
4
|
//#region src/hooks/useAnnotationLayer.ts
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
a[1] !== l || a[2] !== o || a[3] !== c || a[4] !== s ? (m = () => {
|
|
11
|
-
if (!o) return;
|
|
5
|
+
function r({ pdf: r, zoom: i, rotation: a, mountedPages: o, goToPage: s }) {
|
|
6
|
+
let [c, l] = n([]);
|
|
7
|
+
t(() => {
|
|
8
|
+
if (!r) return;
|
|
12
9
|
let e = !1;
|
|
13
10
|
return (async () => {
|
|
14
11
|
let t = [];
|
|
15
|
-
for (let n of
|
|
12
|
+
for (let n of o) {
|
|
16
13
|
if (e) break;
|
|
17
|
-
let
|
|
18
|
-
scale:
|
|
19
|
-
rotation:
|
|
20
|
-
}),
|
|
21
|
-
for (let e of
|
|
14
|
+
let o = await r.getPage(n), s = o.getViewport({
|
|
15
|
+
scale: i,
|
|
16
|
+
rotation: a
|
|
17
|
+
}), c = await o.getAnnotations();
|
|
18
|
+
for (let e of c) {
|
|
22
19
|
if (e.subtype !== "Link" || !e.rect) continue;
|
|
23
|
-
let r = e.rect, [a, o,
|
|
20
|
+
let r = e.rect, [i, a, o, c] = s.convertToViewportRectangle(r);
|
|
24
21
|
t.push({
|
|
25
22
|
page: n,
|
|
26
|
-
x: Math.min(
|
|
27
|
-
y: Math.min(
|
|
28
|
-
width: Math.abs(
|
|
29
|
-
height: Math.abs(c -
|
|
23
|
+
x: Math.min(i, o),
|
|
24
|
+
y: Math.min(a, c),
|
|
25
|
+
width: Math.abs(o - i),
|
|
26
|
+
height: Math.abs(c - a),
|
|
30
27
|
url: e.url,
|
|
31
28
|
dest: e.dest,
|
|
32
29
|
newWindow: e.newWindow
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
e ||
|
|
33
|
+
e || l(t);
|
|
37
34
|
})(), () => {
|
|
38
35
|
e = !0;
|
|
39
36
|
};
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
]
|
|
46
|
-
let
|
|
47
|
-
a[7] !== u || a[8] !== o ? (g = async (t) => {
|
|
37
|
+
}, [
|
|
38
|
+
r,
|
|
39
|
+
i,
|
|
40
|
+
a,
|
|
41
|
+
o
|
|
42
|
+
]);
|
|
43
|
+
let u = async (t) => {
|
|
48
44
|
if (t.url) {
|
|
49
45
|
if (!e(t.url)) return;
|
|
50
46
|
window.open(t.url, "_blank", "noopener,noreferrer");
|
|
51
47
|
return;
|
|
52
48
|
}
|
|
53
|
-
if (t.dest &&
|
|
49
|
+
if (t.dest && r) {
|
|
54
50
|
let e = null;
|
|
55
|
-
if (typeof t.dest == "string" ? e = await
|
|
56
|
-
|
|
51
|
+
if (typeof t.dest == "string" ? e = await r.getDestination(t.dest) : Array.isArray(t.dest) && (e = t.dest), !e) return;
|
|
52
|
+
s(await r.getPageIndex(e[0]) + 1);
|
|
57
53
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
...e,
|
|
64
|
-
_handleClick: _.bind(null, e)
|
|
65
|
-
}), a[13] = _, a[14] = e), v = f.map(e), a[10] = _, a[11] = f, a[12] = v;
|
|
66
|
-
} else v = a[12];
|
|
67
|
-
return v;
|
|
54
|
+
};
|
|
55
|
+
return c.map((e) => ({
|
|
56
|
+
...e,
|
|
57
|
+
_handleClick: u.bind(null, e)
|
|
58
|
+
}));
|
|
68
59
|
}
|
|
69
60
|
//#endregion
|
|
70
|
-
export {
|
|
61
|
+
export { r as useAnnotationLayer };
|
|
@@ -1,51 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect as t } from "react";
|
|
1
|
+
import { useEffect as e } from "react";
|
|
3
2
|
import "pdfjs-dist";
|
|
4
3
|
//#region src/hooks/useKeyboardShortcuts.ts
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!s) return;
|
|
4
|
+
function t({ pdf: t, currentPage: n, goToPage: r, setZoom: i, setRotation: a, setFitMode: o }) {
|
|
5
|
+
e(() => {
|
|
6
|
+
if (!t) return;
|
|
9
7
|
let e = (e) => {
|
|
10
8
|
let t = e.target.tagName;
|
|
11
|
-
if (!(t === "INPUT" || t === "TEXTAREA"))
|
|
9
|
+
if (!(t === "INPUT" || t === "TEXTAREA")) switch (e.key) {
|
|
12
10
|
case "ArrowLeft":
|
|
13
11
|
case "ArrowUp":
|
|
14
|
-
e.preventDefault(),
|
|
15
|
-
break
|
|
12
|
+
e.preventDefault(), r(n - 1);
|
|
13
|
+
break;
|
|
16
14
|
case "ArrowRight":
|
|
17
15
|
case "ArrowDown":
|
|
18
|
-
e.preventDefault(),
|
|
19
|
-
break
|
|
16
|
+
e.preventDefault(), r(n + 1);
|
|
17
|
+
break;
|
|
20
18
|
case "+":
|
|
21
19
|
case "=":
|
|
22
|
-
e.preventDefault(),
|
|
23
|
-
break
|
|
20
|
+
e.preventDefault(), o(null), i((e) => Math.min(e + .2, 3));
|
|
21
|
+
break;
|
|
24
22
|
case "-":
|
|
25
|
-
e.preventDefault(),
|
|
26
|
-
break
|
|
23
|
+
e.preventDefault(), o(null), i((e) => Math.max(e - .2, .2));
|
|
24
|
+
break;
|
|
27
25
|
case "r":
|
|
28
|
-
case "R":
|
|
26
|
+
case "R":
|
|
27
|
+
e.preventDefault(), a((e) => (e + 90) % 360);
|
|
28
|
+
break;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
function r(e) {
|
|
42
|
-
return (e + 90) % 360;
|
|
43
|
-
}
|
|
44
|
-
function i(e) {
|
|
45
|
-
return Math.max(e - .2, .2);
|
|
46
|
-
}
|
|
47
|
-
function a(e) {
|
|
48
|
-
return Math.min(e + .2, 3);
|
|
32
|
+
}, [
|
|
33
|
+
t,
|
|
34
|
+
n,
|
|
35
|
+
r,
|
|
36
|
+
i,
|
|
37
|
+
a,
|
|
38
|
+
o
|
|
39
|
+
]);
|
|
49
40
|
}
|
|
50
41
|
//#endregion
|
|
51
|
-
export {
|
|
42
|
+
export { t as useKeyboardShortcuts };
|
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect as t, useState as n } from "react";
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
3
2
|
import "pdfjs-dist";
|
|
4
3
|
//#region src/hooks/useOutline.ts
|
|
5
|
-
function
|
|
6
|
-
let i =
|
|
7
|
-
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = {
|
|
4
|
+
function n({ pdf: n }) {
|
|
5
|
+
let [r, i] = t({
|
|
8
6
|
pdf: null,
|
|
9
7
|
outline: []
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!a) return;
|
|
8
|
+
});
|
|
9
|
+
e(() => {
|
|
10
|
+
if (!n) return;
|
|
14
11
|
let e = !1;
|
|
15
|
-
return
|
|
16
|
-
e ||
|
|
17
|
-
pdf:
|
|
12
|
+
return n.getOutline().then((t) => {
|
|
13
|
+
e || i({
|
|
14
|
+
pdf: n,
|
|
18
15
|
outline: t ?? []
|
|
19
16
|
});
|
|
20
17
|
}).catch(() => {
|
|
21
|
-
e ||
|
|
22
|
-
pdf:
|
|
18
|
+
e || i({
|
|
19
|
+
pdf: n,
|
|
23
20
|
outline: []
|
|
24
21
|
});
|
|
25
22
|
}), () => {
|
|
26
23
|
e = !0;
|
|
27
24
|
};
|
|
28
|
-
},
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
loading: d
|
|
35
|
-
}, i[7] = d, i[8] = f, i[9] = p) : p = i[9], p;
|
|
25
|
+
}, [n]);
|
|
26
|
+
let a = n !== null && r.pdf !== n;
|
|
27
|
+
return {
|
|
28
|
+
outline: a ? [] : r.outline,
|
|
29
|
+
loading: a
|
|
30
|
+
};
|
|
36
31
|
}
|
|
37
32
|
//#endregion
|
|
38
|
-
export {
|
|
33
|
+
export { n as useOutline };
|