pdf-tsx 0.16.1 → 0.16.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/cjs/components/PDFViewer.cjs +1 -1
- package/dist/cjs/hooks/usePDFLoader.cjs +1 -1
- package/dist/components/PDFViewer.d.ts +1 -0
- package/dist/es/components/PDFViewer.js +216 -216
- package/dist/es/hooks/usePDFLoader.js +12 -17
- package/dist/hooks/usePDFLoader.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/node_modules/pdfjs-dist/wasm/jbig2.cjs +0 -1
- package/dist/cjs/node_modules/pdfjs-dist/wasm/openjpeg.cjs +0 -1
- package/dist/cjs/node_modules/pdfjs-dist/wasm/qcms_bg.cjs +0 -1
- package/dist/cjs/node_modules/pdfjs-dist/wasm/quickjs-eval.cjs +0 -1
- package/dist/es/node_modules/pdfjs-dist/wasm/jbig2.js +0 -4
- package/dist/es/node_modules/pdfjs-dist/wasm/openjpeg.js +0 -4
- package/dist/es/node_modules/pdfjs-dist/wasm/qcms_bg.js +0 -4
- package/dist/es/node_modules/pdfjs-dist/wasm/quickjs-eval.js +0 -4
|
@@ -3,262 +3,262 @@ import { useScrollTracking as t } from "../hooks/useScrollTracking.js";
|
|
|
3
3
|
import { useKeyboardShortcuts as n } from "../hooks/useKeyboardShortcuts.js";
|
|
4
4
|
import { useTextLayer as r } from "../hooks/useTextLayer.js";
|
|
5
5
|
import { isSafeUrl as i } from "../utils/url.js";
|
|
6
|
-
import { useAnnotationLayer as
|
|
7
|
-
import { usePDFLoader as
|
|
8
|
-
import { usePDFRenderer as
|
|
9
|
-
import { useOverlayRects as
|
|
10
|
-
import { computeFit as
|
|
11
|
-
import { ThemeProvider as
|
|
12
|
-
import { LabelsProvider as
|
|
13
|
-
import { useLabels as
|
|
14
|
-
import
|
|
15
|
-
import { useCallback as
|
|
16
|
-
import * as
|
|
17
|
-
import { Fragment as
|
|
6
|
+
import { useAnnotationLayer as a } from "../hooks/useAnnotationLayer.js";
|
|
7
|
+
import { usePDFLoader as ee } from "../hooks/usePDFLoader.js";
|
|
8
|
+
import { usePDFRenderer as te } from "../hooks/usePDFRenderer.js";
|
|
9
|
+
import { useOverlayRects as ne } from "../hooks/useOverlayRects.js";
|
|
10
|
+
import { computeFit as o } from "../utils/pdfFit.js";
|
|
11
|
+
import { ThemeProvider as re } from "../context/ThemeContext.js";
|
|
12
|
+
import { LabelsProvider as ie } from "../context/LabelsContext.js";
|
|
13
|
+
import { useLabels as s } from "../hooks/useLabels.js";
|
|
14
|
+
import c from "./PDFViewer.module.js";
|
|
15
|
+
import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
16
|
+
import * as ae from "pdfjs-dist";
|
|
17
|
+
import { Fragment as oe, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
18
18
|
//#region src/components/PDFViewer.tsx
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
let t =
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
className: `${
|
|
24
|
-
children: [e ? /* @__PURE__ */
|
|
19
|
+
var g = 2;
|
|
20
|
+
function se({ hasRead: e }) {
|
|
21
|
+
let t = s();
|
|
22
|
+
return /* @__PURE__ */ h("div", {
|
|
23
|
+
className: `${c.requireReadBanner} ${e ? c.requireReadDone : ""}`,
|
|
24
|
+
children: [e ? /* @__PURE__ */ m("svg", {
|
|
25
25
|
width: "16",
|
|
26
26
|
height: "16",
|
|
27
27
|
viewBox: "0 0 16 16",
|
|
28
28
|
fill: "none",
|
|
29
29
|
"aria-hidden": "true",
|
|
30
|
-
children: /* @__PURE__ */
|
|
30
|
+
children: /* @__PURE__ */ m("path", {
|
|
31
31
|
d: "M3 8l3.5 3.5L13 4.5",
|
|
32
32
|
stroke: "currentColor",
|
|
33
33
|
strokeWidth: "2",
|
|
34
34
|
strokeLinecap: "round",
|
|
35
35
|
strokeLinejoin: "round"
|
|
36
36
|
})
|
|
37
|
-
}) : /* @__PURE__ */
|
|
37
|
+
}) : /* @__PURE__ */ m("svg", {
|
|
38
38
|
width: "16",
|
|
39
39
|
height: "16",
|
|
40
40
|
viewBox: "0 0 16 16",
|
|
41
41
|
fill: "none",
|
|
42
42
|
"aria-hidden": "true",
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ m("path", {
|
|
44
44
|
d: "M8 3v10M4 9l4 4 4-4",
|
|
45
45
|
stroke: "currentColor",
|
|
46
46
|
strokeWidth: "2",
|
|
47
47
|
strokeLinecap: "round",
|
|
48
48
|
strokeLinejoin: "round"
|
|
49
49
|
})
|
|
50
|
-
}), /* @__PURE__ */
|
|
50
|
+
}), /* @__PURE__ */ m("span", { children: e ? t.requireReadDone : t.requireReadPending })]
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
let [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
let [_e, ve] =
|
|
62
|
-
_e !==
|
|
63
|
-
|
|
64
|
-
}, [
|
|
65
|
-
let { pdf:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, [
|
|
69
|
-
!
|
|
70
|
-
}, [
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
if (!
|
|
76
|
-
let e =
|
|
77
|
-
|
|
53
|
+
var _ = ({ file: s, workerSrc: _, sidebar: ce, toolbar: v, onChangeFile: y, themeOverrides: le, defaultTheme: ue, defaultFit: b, language: de, className: x, style: fe, requireRead: S, onDocumentRead: C, wasmUrl: pe }) => {
|
|
54
|
+
u(() => {
|
|
55
|
+
ae.GlobalWorkerOptions.workerSrc = _;
|
|
56
|
+
}, [_]);
|
|
57
|
+
let [w, T] = p(1), [E, D] = p(0), [O, k] = p(null), [A, me] = p([]), [j, he] = p(!1), [M, ge] = p(b ?? null), [N, P] = p(null), [F, I] = p(!1), L = f(!1), R = f(null), z = f([]), B = f([]), V = f(E);
|
|
58
|
+
u(() => {
|
|
59
|
+
V.current = E;
|
|
60
|
+
}, [E]);
|
|
61
|
+
let [_e, ve] = p(null);
|
|
62
|
+
_e !== s && (ve(s), k(null), I(!1)), u(() => {
|
|
63
|
+
L.current = !1;
|
|
64
|
+
}, [s]);
|
|
65
|
+
let { pdf: H, numPages: U, loading: ye } = ee(s, pe);
|
|
66
|
+
u(() => {
|
|
67
|
+
H && (z.current = Array(H.numPages).fill(null), B.current = Array(H.numPages).fill(null));
|
|
68
|
+
}, [H]), u(() => {
|
|
69
|
+
!H || !b || !R.current || o(b, H, R.current, V.current).then(T);
|
|
70
|
+
}, [H, b]);
|
|
71
|
+
let W = f(M);
|
|
72
|
+
u(() => {
|
|
73
|
+
W.current = M;
|
|
74
|
+
}, [M]), u(() => {
|
|
75
|
+
if (!H || !R.current) return;
|
|
76
|
+
let e = R.current, t = new ResizeObserver(() => {
|
|
77
|
+
W.current && o(W.current, H, e, V.current).then(T);
|
|
78
78
|
});
|
|
79
79
|
return t.observe(e), () => t.disconnect();
|
|
80
|
-
}, [
|
|
81
|
-
let { currentPage:
|
|
82
|
-
numPages:
|
|
83
|
-
containerRef:
|
|
84
|
-
pageRefs:
|
|
80
|
+
}, [H]);
|
|
81
|
+
let { currentPage: G, goToPage: K } = t({
|
|
82
|
+
numPages: U,
|
|
83
|
+
containerRef: R,
|
|
84
|
+
pageRefs: z
|
|
85
85
|
});
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
u(() => {
|
|
87
|
+
U === 0 || G < U || (S && !F && I(!0), L.current || (L.current = !0, C?.()));
|
|
88
88
|
}, [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
G,
|
|
90
|
+
U,
|
|
91
|
+
S,
|
|
92
|
+
F,
|
|
93
|
+
C
|
|
94
94
|
]);
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
-
let e = /* @__PURE__ */ new Set(), t = Math.max(
|
|
95
|
+
let q = d(() => {
|
|
96
|
+
if (U === 0) return [];
|
|
97
|
+
let e = /* @__PURE__ */ new Set(), t = Math.max(G - g, 1), n = Math.min(G + g, U);
|
|
98
98
|
for (let r = t; r <= n; r++) e.add(r);
|
|
99
|
-
|
|
100
|
-
for (let t of
|
|
99
|
+
O && e.add(O.page);
|
|
100
|
+
for (let t of A) e.add(t.page);
|
|
101
101
|
return Array.from(e).sort((e, t) => e - t);
|
|
102
102
|
}, [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
]), { pageSizes: be, renderedPages:
|
|
108
|
-
pdf:
|
|
109
|
-
zoom:
|
|
110
|
-
rotation:
|
|
111
|
-
visiblePages:
|
|
112
|
-
canvasRefs:
|
|
113
|
-
}),
|
|
114
|
-
let e = new Set(
|
|
115
|
-
for (let t of
|
|
103
|
+
G,
|
|
104
|
+
U,
|
|
105
|
+
O,
|
|
106
|
+
A
|
|
107
|
+
]), { pageSizes: be, renderedPages: J } = te({
|
|
108
|
+
pdf: H,
|
|
109
|
+
zoom: w,
|
|
110
|
+
rotation: E,
|
|
111
|
+
visiblePages: q,
|
|
112
|
+
canvasRefs: B
|
|
113
|
+
}), Y = d(() => {
|
|
114
|
+
let e = new Set(q);
|
|
115
|
+
for (let t of J) e.add(t);
|
|
116
116
|
return Array.from(e).sort((e, t) => e - t);
|
|
117
|
-
}, [
|
|
117
|
+
}, [q, J]);
|
|
118
118
|
n({
|
|
119
|
-
pdf:
|
|
120
|
-
currentPage:
|
|
121
|
-
goToPage:
|
|
122
|
-
setRotation:
|
|
119
|
+
pdf: H,
|
|
120
|
+
currentPage: G,
|
|
121
|
+
goToPage: K,
|
|
122
|
+
setRotation: D
|
|
123
123
|
});
|
|
124
124
|
let xe = r({
|
|
125
|
-
pdf:
|
|
126
|
-
zoom:
|
|
127
|
-
rotation:
|
|
128
|
-
mountedPages:
|
|
129
|
-
canvasRefs:
|
|
130
|
-
}), { linkOverlays: Se, noteOverlays: Ce } =
|
|
131
|
-
pdf:
|
|
132
|
-
zoom:
|
|
133
|
-
rotation:
|
|
134
|
-
mountedPages:
|
|
135
|
-
goToPage:
|
|
125
|
+
pdf: H,
|
|
126
|
+
zoom: w,
|
|
127
|
+
rotation: E,
|
|
128
|
+
mountedPages: Y,
|
|
129
|
+
canvasRefs: B
|
|
130
|
+
}), { linkOverlays: Se, noteOverlays: Ce } = a({
|
|
131
|
+
pdf: H,
|
|
132
|
+
zoom: w,
|
|
133
|
+
rotation: E,
|
|
134
|
+
mountedPages: Y,
|
|
135
|
+
goToPage: K
|
|
136
136
|
});
|
|
137
|
-
|
|
138
|
-
if (!
|
|
139
|
-
let e = () =>
|
|
140
|
-
e.key === "Escape" &&
|
|
137
|
+
u(() => {
|
|
138
|
+
if (!N) return;
|
|
139
|
+
let e = () => P(null), t = (e) => {
|
|
140
|
+
e.key === "Escape" && P(null);
|
|
141
141
|
};
|
|
142
142
|
return document.addEventListener("click", e), document.addEventListener("keydown", t), () => {
|
|
143
143
|
document.removeEventListener("click", e), document.removeEventListener("keydown", t);
|
|
144
144
|
};
|
|
145
|
-
}, [
|
|
146
|
-
let { overlayRect:
|
|
147
|
-
pdf:
|
|
148
|
-
highlight:
|
|
149
|
-
searchMatches:
|
|
150
|
-
zoom:
|
|
151
|
-
rotation:
|
|
152
|
-
}), Te =
|
|
145
|
+
}, [N]);
|
|
146
|
+
let { overlayRect: X, searchOverlays: we } = ne({
|
|
147
|
+
pdf: H,
|
|
148
|
+
highlight: O,
|
|
149
|
+
searchMatches: A,
|
|
150
|
+
zoom: w,
|
|
151
|
+
rotation: E
|
|
152
|
+
}), Te = l((e, t) => {
|
|
153
153
|
(!e.url || !i(e.url)) && (t.preventDefault(), e.url || e._handleClick());
|
|
154
|
-
}, []),
|
|
155
|
-
|
|
154
|
+
}, []), Z = f(null), Q = l((e, t) => {
|
|
155
|
+
Z.current && clearTimeout(Z.current);
|
|
156
156
|
let n = t.clientY > window.innerHeight * .6;
|
|
157
|
-
|
|
157
|
+
P({
|
|
158
158
|
x: Math.min(t.clientX, window.innerWidth - 304),
|
|
159
159
|
y: n ? window.innerHeight - t.clientY + 8 : t.clientY + 12,
|
|
160
160
|
above: n,
|
|
161
161
|
contents: e.contents,
|
|
162
162
|
title: e.title
|
|
163
163
|
});
|
|
164
|
-
}, []),
|
|
165
|
-
|
|
166
|
-
}, []),
|
|
167
|
-
|
|
164
|
+
}, []), $ = l(() => {
|
|
165
|
+
Z.current = setTimeout(() => P(null), 200);
|
|
166
|
+
}, []), Ee = l((e) => {
|
|
167
|
+
k({
|
|
168
168
|
page: e.page,
|
|
169
169
|
pdfRect: e.pdfRect
|
|
170
|
-
}),
|
|
171
|
-
}, [
|
|
172
|
-
pdf:
|
|
173
|
-
numPages:
|
|
174
|
-
zoom:
|
|
175
|
-
setZoom:
|
|
176
|
-
rotation:
|
|
177
|
-
setRotation:
|
|
178
|
-
currentPage:
|
|
179
|
-
goToPage:
|
|
180
|
-
containerRef:
|
|
181
|
-
canvasRefs:
|
|
182
|
-
file:
|
|
183
|
-
highlight:
|
|
184
|
-
setHighlight:
|
|
185
|
-
searchMatches:
|
|
170
|
+
}), K(e.page);
|
|
171
|
+
}, [k, K]), De = d(() => ({
|
|
172
|
+
pdf: H,
|
|
173
|
+
numPages: U,
|
|
174
|
+
zoom: w,
|
|
175
|
+
setZoom: T,
|
|
176
|
+
rotation: E,
|
|
177
|
+
setRotation: D,
|
|
178
|
+
currentPage: G,
|
|
179
|
+
goToPage: K,
|
|
180
|
+
containerRef: R,
|
|
181
|
+
canvasRefs: B,
|
|
182
|
+
file: s,
|
|
183
|
+
highlight: O,
|
|
184
|
+
setHighlight: k,
|
|
185
|
+
searchMatches: A,
|
|
186
186
|
setSearchMatches: me,
|
|
187
|
-
onChangeFile:
|
|
188
|
-
sidebarCollapsed:
|
|
187
|
+
onChangeFile: y,
|
|
188
|
+
sidebarCollapsed: j,
|
|
189
189
|
setSidebarCollapsed: he,
|
|
190
|
-
fitMode:
|
|
190
|
+
fitMode: M,
|
|
191
191
|
setFitMode: ge,
|
|
192
|
-
navigationLocked: !!
|
|
192
|
+
navigationLocked: !!S && !F
|
|
193
193
|
}), [
|
|
194
|
-
V,
|
|
195
194
|
H,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
U,
|
|
196
|
+
w,
|
|
197
|
+
E,
|
|
199
198
|
G,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
v,
|
|
199
|
+
K,
|
|
200
|
+
s,
|
|
201
|
+
O,
|
|
204
202
|
A,
|
|
203
|
+
y,
|
|
205
204
|
j,
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
M,
|
|
206
|
+
S,
|
|
207
|
+
F
|
|
208
208
|
]);
|
|
209
|
-
return /* @__PURE__ */
|
|
210
|
-
themeOverrides:
|
|
211
|
-
defaultTheme:
|
|
212
|
-
children: /* @__PURE__ */
|
|
213
|
-
language:
|
|
214
|
-
children: /* @__PURE__ */
|
|
215
|
-
value:
|
|
216
|
-
children: [/* @__PURE__ */
|
|
217
|
-
className: `${
|
|
218
|
-
style:
|
|
219
|
-
children: [
|
|
220
|
-
className:
|
|
221
|
-
children:
|
|
222
|
-
}), /* @__PURE__ */
|
|
223
|
-
className:
|
|
224
|
-
children: [
|
|
225
|
-
className:
|
|
226
|
-
ref:
|
|
209
|
+
return /* @__PURE__ */ m(re, {
|
|
210
|
+
themeOverrides: le,
|
|
211
|
+
defaultTheme: ue,
|
|
212
|
+
children: /* @__PURE__ */ m(ie, {
|
|
213
|
+
language: de,
|
|
214
|
+
children: /* @__PURE__ */ h(e.Provider, {
|
|
215
|
+
value: De,
|
|
216
|
+
children: [/* @__PURE__ */ h("div", {
|
|
217
|
+
className: `${c.appLayout}${x ? ` ${x}` : ""}`,
|
|
218
|
+
style: fe,
|
|
219
|
+
children: [v && /* @__PURE__ */ m("div", {
|
|
220
|
+
className: c.toolbar,
|
|
221
|
+
children: v
|
|
222
|
+
}), /* @__PURE__ */ h("div", {
|
|
223
|
+
className: c.body,
|
|
224
|
+
children: [ce, /* @__PURE__ */ h("div", {
|
|
225
|
+
className: c.scrollContainer,
|
|
226
|
+
ref: R,
|
|
227
227
|
children: [
|
|
228
|
-
ye && /* @__PURE__ */
|
|
229
|
-
Array.from({ length:
|
|
230
|
-
let n =
|
|
231
|
-
return /* @__PURE__ */
|
|
232
|
-
className:
|
|
228
|
+
ye && /* @__PURE__ */ m("div", { className: c.documentLoading }),
|
|
229
|
+
Array.from({ length: U }, (e, t) => {
|
|
230
|
+
let n = J.has(t + 1), r = be[t], a = Y.includes(t + 1);
|
|
231
|
+
return /* @__PURE__ */ h("div", {
|
|
232
|
+
className: c.pageWrapper,
|
|
233
233
|
ref: (e) => {
|
|
234
|
-
|
|
234
|
+
z.current[t] = e;
|
|
235
235
|
},
|
|
236
236
|
style: r ? {
|
|
237
237
|
width: r.width,
|
|
238
238
|
height: r.height
|
|
239
239
|
} : void 0,
|
|
240
240
|
children: [
|
|
241
|
-
r && !n && /* @__PURE__ */
|
|
242
|
-
className:
|
|
241
|
+
r && !n && /* @__PURE__ */ m("div", {
|
|
242
|
+
className: c.pageSkeleton,
|
|
243
243
|
style: {
|
|
244
244
|
width: r.width,
|
|
245
245
|
height: r.height
|
|
246
246
|
}
|
|
247
247
|
}),
|
|
248
|
-
|
|
249
|
-
className:
|
|
248
|
+
a && /* @__PURE__ */ h(oe, { children: [/* @__PURE__ */ m("canvas", {
|
|
249
|
+
className: c.pageCanvas,
|
|
250
250
|
ref: (e) => {
|
|
251
|
-
|
|
251
|
+
B.current[t] = e;
|
|
252
252
|
},
|
|
253
253
|
style: { display: n ? "block" : "none" }
|
|
254
|
-
}), /* @__PURE__ */
|
|
255
|
-
className: `textLayer ${
|
|
254
|
+
}), /* @__PURE__ */ m("div", {
|
|
255
|
+
className: `textLayer ${c.textLayer}`,
|
|
256
256
|
ref: (e) => {
|
|
257
257
|
xe.current[t] = e;
|
|
258
258
|
}
|
|
259
259
|
})] }),
|
|
260
|
-
Se.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */
|
|
261
|
-
className:
|
|
260
|
+
Se.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ m("a", {
|
|
261
|
+
className: c.linkOverlay,
|
|
262
262
|
href: e.url && i(e.url) ? e.url : "#",
|
|
263
263
|
target: "_blank",
|
|
264
264
|
rel: "noopener noreferrer",
|
|
@@ -270,25 +270,25 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
270
270
|
},
|
|
271
271
|
onClick: (t) => Te(e, t)
|
|
272
272
|
}, t)),
|
|
273
|
-
Ce.filter((e) => e.page === t + 1).map((e, t) => e.subtype === "Text" ? /* @__PURE__ */
|
|
274
|
-
className:
|
|
273
|
+
Ce.filter((e) => e.page === t + 1).map((e, t) => e.subtype === "Text" ? /* @__PURE__ */ m("div", {
|
|
274
|
+
className: c.noteIconOverlay,
|
|
275
275
|
style: {
|
|
276
276
|
left: e.x,
|
|
277
277
|
top: e.y,
|
|
278
278
|
width: Math.max(e.width, 26),
|
|
279
279
|
height: Math.max(e.height, 26)
|
|
280
280
|
},
|
|
281
|
-
onMouseEnter: (t) =>
|
|
282
|
-
onMouseLeave:
|
|
283
|
-
onClick: () =>
|
|
284
|
-
children: /* @__PURE__ */
|
|
281
|
+
onMouseEnter: (t) => Q(e, t),
|
|
282
|
+
onMouseLeave: $,
|
|
283
|
+
onClick: () => Ee(e),
|
|
284
|
+
children: /* @__PURE__ */ h("svg", {
|
|
285
285
|
width: "22",
|
|
286
286
|
height: "22",
|
|
287
287
|
viewBox: "0 0 12 12",
|
|
288
288
|
fill: "none",
|
|
289
289
|
"aria-hidden": "true",
|
|
290
290
|
children: [
|
|
291
|
-
/* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ m("rect", {
|
|
292
292
|
x: "0.5",
|
|
293
293
|
y: "0.5",
|
|
294
294
|
width: "9",
|
|
@@ -298,13 +298,13 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
298
298
|
stroke: "rgba(160,120,0,0.7)",
|
|
299
299
|
strokeWidth: "1"
|
|
300
300
|
}),
|
|
301
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ m("path", {
|
|
302
302
|
d: "M9.5 5.5v3l2.5-3z",
|
|
303
303
|
fill: "rgba(255,210,0,0.9)",
|
|
304
304
|
stroke: "rgba(160,120,0,0.7)",
|
|
305
305
|
strokeWidth: "1"
|
|
306
306
|
}),
|
|
307
|
-
/* @__PURE__ */
|
|
307
|
+
/* @__PURE__ */ m("line", {
|
|
308
308
|
x1: "2",
|
|
309
309
|
y1: "3",
|
|
310
310
|
x2: "8",
|
|
@@ -313,7 +313,7 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
313
313
|
strokeWidth: "1",
|
|
314
314
|
strokeLinecap: "round"
|
|
315
315
|
}),
|
|
316
|
-
/* @__PURE__ */
|
|
316
|
+
/* @__PURE__ */ m("line", {
|
|
317
317
|
x1: "2",
|
|
318
318
|
y1: "5.5",
|
|
319
319
|
x2: "7",
|
|
@@ -324,20 +324,20 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
324
324
|
})
|
|
325
325
|
]
|
|
326
326
|
})
|
|
327
|
-
}, t) : /* @__PURE__ */
|
|
328
|
-
className:
|
|
327
|
+
}, t) : /* @__PURE__ */ m("div", {
|
|
328
|
+
className: c.noteOverlay,
|
|
329
329
|
style: {
|
|
330
330
|
left: e.x,
|
|
331
331
|
top: e.y,
|
|
332
332
|
width: e.width,
|
|
333
333
|
height: e.height
|
|
334
334
|
},
|
|
335
|
-
onMouseEnter: (t) =>
|
|
336
|
-
onMouseLeave:
|
|
337
|
-
onClick: () =>
|
|
335
|
+
onMouseEnter: (t) => Q(e, t),
|
|
336
|
+
onMouseLeave: $,
|
|
337
|
+
onClick: () => Ee(e)
|
|
338
338
|
}, t)),
|
|
339
|
-
we.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */
|
|
340
|
-
className:
|
|
339
|
+
we.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ m("div", {
|
|
340
|
+
className: c.searchMatchOverlay,
|
|
341
341
|
style: {
|
|
342
342
|
left: e.x,
|
|
343
343
|
top: e.y,
|
|
@@ -345,42 +345,42 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
345
345
|
height: e.height
|
|
346
346
|
}
|
|
347
347
|
}, t)),
|
|
348
|
-
|
|
349
|
-
className:
|
|
348
|
+
O && X?.page === t + 1 && /* @__PURE__ */ m("div", {
|
|
349
|
+
className: c.highlightOverlay,
|
|
350
350
|
style: {
|
|
351
|
-
left:
|
|
352
|
-
top:
|
|
353
|
-
width:
|
|
354
|
-
height:
|
|
351
|
+
left: X.x,
|
|
352
|
+
top: X.y,
|
|
353
|
+
width: X.width,
|
|
354
|
+
height: X.height
|
|
355
355
|
}
|
|
356
356
|
})
|
|
357
357
|
]
|
|
358
|
-
}, `${t}-${
|
|
358
|
+
}, `${t}-${E}`);
|
|
359
359
|
}),
|
|
360
|
-
|
|
360
|
+
S && /* @__PURE__ */ m(se, { hasRead: F })
|
|
361
361
|
]
|
|
362
362
|
})]
|
|
363
363
|
})]
|
|
364
|
-
}),
|
|
365
|
-
className:
|
|
366
|
-
style:
|
|
367
|
-
left:
|
|
368
|
-
bottom:
|
|
364
|
+
}), N && /* @__PURE__ */ h("div", {
|
|
365
|
+
className: c.notePopover,
|
|
366
|
+
style: N.above ? {
|
|
367
|
+
left: N.x,
|
|
368
|
+
bottom: N.y
|
|
369
369
|
} : {
|
|
370
|
-
left:
|
|
371
|
-
top:
|
|
370
|
+
left: N.x,
|
|
371
|
+
top: N.y
|
|
372
372
|
},
|
|
373
373
|
onMouseEnter: () => {
|
|
374
|
-
|
|
374
|
+
Z.current && clearTimeout(Z.current);
|
|
375
375
|
},
|
|
376
|
-
onMouseLeave:
|
|
376
|
+
onMouseLeave: $,
|
|
377
377
|
onClick: (e) => e.stopPropagation(),
|
|
378
|
-
children: [
|
|
379
|
-
className:
|
|
380
|
-
children:
|
|
381
|
-
}), /* @__PURE__ */
|
|
382
|
-
className:
|
|
383
|
-
children:
|
|
378
|
+
children: [N.title && /* @__PURE__ */ m("div", {
|
|
379
|
+
className: c.notePopoverTitle,
|
|
380
|
+
children: N.title
|
|
381
|
+
}), /* @__PURE__ */ m("p", {
|
|
382
|
+
className: c.notePopoverContent,
|
|
383
|
+
children: N.contents
|
|
384
384
|
})]
|
|
385
385
|
})]
|
|
386
386
|
})
|
|
@@ -388,4 +388,4 @@ var g = ({ file: o, workerSrc: g, sidebar: le, toolbar: _, onChangeFile: v, them
|
|
|
388
388
|
});
|
|
389
389
|
};
|
|
390
390
|
//#endregion
|
|
391
|
-
export {
|
|
391
|
+
export { _ as default };
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import "
|
|
3
|
-
import "../node_modules/pdfjs-dist/wasm/qcms_bg.js";
|
|
4
|
-
import "../node_modules/pdfjs-dist/wasm/quickjs-eval.js";
|
|
5
|
-
import { useEffect as t, useState as n } from "react";
|
|
6
|
-
import * as r from "pdfjs-dist";
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
import * as n from "pdfjs-dist";
|
|
7
3
|
//#region src/hooks/usePDFLoader.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return t(() => {
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
let [a, o] = t(null), [s, c] = t(0), [l, u] = t(!0);
|
|
6
|
+
return e(() => {
|
|
12
7
|
u(!0), o(null), c(0);
|
|
13
|
-
let
|
|
14
|
-
|
|
8
|
+
let e = new FileReader();
|
|
9
|
+
e.onload = async (e) => {
|
|
15
10
|
let t = new Uint8Array(e.target?.result);
|
|
16
11
|
try {
|
|
17
|
-
let e = await
|
|
12
|
+
let e = await n.getDocument({
|
|
18
13
|
data: t,
|
|
19
|
-
wasmUrl: i
|
|
14
|
+
...i ? { wasmUrl: i } : {}
|
|
20
15
|
}).promise;
|
|
21
16
|
o(e), c(e.numPages);
|
|
22
17
|
} catch (e) {
|
|
@@ -24,12 +19,12 @@ function a(e) {
|
|
|
24
19
|
} finally {
|
|
25
20
|
u(!1);
|
|
26
21
|
}
|
|
27
|
-
},
|
|
28
|
-
}, [
|
|
22
|
+
}, e.readAsArrayBuffer(r);
|
|
23
|
+
}, [r, i]), {
|
|
29
24
|
pdf: a,
|
|
30
25
|
numPages: s,
|
|
31
26
|
loading: l
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
29
|
//#endregion
|
|
35
|
-
export {
|
|
30
|
+
export { r as usePDFLoader };
|