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