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