@pdf-viewer/react 1.5.1 → 1.6.0-beta.10
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/RPDefaultLayout-4518b3d3.js +3059 -0
- package/dist/SearchCloseButton-959cc1ed.js +32 -0
- package/dist/assets/Container.css +1 -1
- package/dist/assets/PasswordModal.css +1 -0
- package/dist/assets/RPDefaultLayout.css +1 -1
- package/dist/assets/SearchCloseButton.css +1 -0
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPPages.js +4 -2
- package/dist/components/RPProvider.js +13 -12
- package/dist/components/layout/Container.js +7 -6
- package/dist/components/layout/LayoutContainer.js +3 -2
- package/dist/components/layout/RPDefaultLayout.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +4 -3
- package/dist/components/layout/toolbar/OtherTool.js +2 -2
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
- package/dist/components/layout/toolbar/RotateTool.js +1 -1
- package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
- package/dist/components/layout/toolbar/SearchCloseButton.js +9 -0
- package/dist/components/layout/toolbar/SearchResultNavigator.js +10 -0
- package/dist/components/layout/toolbar/SearchTool.js +5 -4
- package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
- package/dist/components/layout/toolbar/ViewModeTool.js +18 -19
- package/dist/components/layout/toolbar/ZoomTool.js +8 -27
- package/dist/components/page/AnnotationLayer.js +3 -2
- package/dist/components/page/CanvasLayer.js +3 -2
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/RPPage.js +3 -2
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +3 -2
- package/dist/components/page/TextLayer.js +3 -2
- package/dist/components/ui/Checkbox.js +14 -13
- package/dist/components/ui/DropDown.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +58 -0
- package/dist/components/ui/RPTooltip.js +689 -331
- package/dist/contexts/DocumentPasswordContext.js +40 -0
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/PrintContext.js +1 -1
- package/dist/contexts/RPDocumentContext.js +11 -8
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/contexts/SmoothScrollContext.js +8 -9
- package/dist/contexts/ThumbnailsContext.js +1 -1
- package/dist/contexts/ToolbarComponentContext.js +2 -2
- package/dist/contexts/ViewModeContext.js +16 -17
- package/dist/contexts/ZoomContext.js +17 -16
- package/dist/index-2e540713.js +23 -0
- package/dist/index-353ec0a6.js +172 -0
- package/dist/index-5ff5dbd0.js +1675 -0
- package/dist/index-71898eb9.js +139 -0
- package/dist/main.js +1 -1
- package/dist/types/components/layout/toolbar/SearchCloseButton.d.ts +7 -0
- package/dist/types/components/layout/toolbar/SearchResultNavigator.d.ts +1 -0
- package/dist/types/components/layout/toolbar/ViewModeTool.d.ts +1 -1
- package/dist/types/components/ui/PasswordModal.d.ts +3 -0
- package/dist/types/contexts/DocumentPasswordContext.d.ts +14 -0
- package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/getScrollDistance.d.ts +1 -0
- package/dist/types/utils/getWordPositionInPage.d.ts +11 -0
- package/dist/types/utils/getZoomLevel.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -0
- package/dist/types/utils/types.d.ts +20 -3
- package/dist/utils/constants.js +3 -2
- package/dist/utils/getScrollDistance.js +4 -0
- package/dist/utils/getWordPositionInPage.js +19 -0
- package/dist/utils/getZoomLevel.js +13 -9
- package/dist/utils/highlight.js +141 -126
- package/dist/utils/hooks/useFileDownload.js +3 -2
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +52 -40
- package/dist/utils/hooks/usePaginate.js +4 -2
- package/dist/utils/hooks/usePinch.js +68 -17
- package/dist/utils/hooks/usePresentPage.js +3 -2
- package/dist/utils/hooks/usePrint.js +3 -2
- package/dist/utils/hooks/useScrollToPage.js +4 -2
- package/dist/utils/hooks/useSearch.js +5 -3
- package/dist/utils/hooks/useThumbnail.js +3 -2
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
- package/dist/utils/types.js +4 -4
- package/package.json +1 -1
- package/dist/RPDefaultLayout-ed089918.js +0 -2958
- package/dist/index-1cb41342.js +0 -307
- package/dist/index-7279fb4e.js +0 -1557
- package/dist/index-aa2d3884.js +0 -140
package/dist/utils/highlight.js
CHANGED
|
@@ -1,205 +1,220 @@
|
|
|
1
|
-
import { getCharacterType as
|
|
2
|
-
function
|
|
1
|
+
import { getCharacterType as X } from "./charators.js";
|
|
2
|
+
function V(r, c, a, i) {
|
|
3
3
|
const o = [];
|
|
4
|
-
for (const n of
|
|
5
|
-
const
|
|
6
|
-
o.push(...
|
|
4
|
+
for (const n of r) {
|
|
5
|
+
const s = y(c, n, i);
|
|
6
|
+
o.push(...I(s, c, a));
|
|
7
7
|
}
|
|
8
8
|
return o;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
c.matchCase ||
|
|
13
|
-
let o =
|
|
14
|
-
return new RegExp(o,
|
|
10
|
+
const D = (r, c) => {
|
|
11
|
+
const a = ["g"];
|
|
12
|
+
c.matchCase || a.push("i");
|
|
13
|
+
let o = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
|
+
return new RegExp(o, a.join(""));
|
|
15
15
|
};
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
for (const t of
|
|
16
|
+
function y(r, c, a) {
|
|
17
|
+
const i = [];
|
|
18
|
+
for (const t of r.items)
|
|
19
19
|
if (t.hasEOL)
|
|
20
20
|
if (t.str.endsWith("-")) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const l = t.str.lastIndexOf("-");
|
|
22
|
+
i.push(t.str.substring(0, l));
|
|
23
23
|
} else
|
|
24
|
-
|
|
24
|
+
i.push(t.str, `
|
|
25
25
|
`);
|
|
26
26
|
else
|
|
27
|
-
|
|
28
|
-
const o =
|
|
27
|
+
i.push(t.str);
|
|
28
|
+
const o = i.join("").replace(/\n/g, " ");
|
|
29
29
|
let n;
|
|
30
|
-
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n =
|
|
31
|
-
const
|
|
30
|
+
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = D(c, a);
|
|
31
|
+
const s = [];
|
|
32
32
|
let e;
|
|
33
33
|
for (; (e = n.exec(o)) !== null; )
|
|
34
|
-
|
|
35
|
-
return
|
|
34
|
+
a.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
|
|
35
|
+
return s;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
function
|
|
39
|
-
return
|
|
37
|
+
function I(r, c, a) {
|
|
38
|
+
function i(l) {
|
|
39
|
+
return l.hasEOL ? l.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
41
41
|
let o = 0, n = 0;
|
|
42
|
-
const
|
|
43
|
-
for (let
|
|
44
|
-
let
|
|
45
|
-
for (; o !== e &&
|
|
46
|
-
const f =
|
|
47
|
-
n += f.str.length +
|
|
42
|
+
const s = c.items, e = s.length - 1, t = [];
|
|
43
|
+
for (let l = 0; l < r.length; l++) {
|
|
44
|
+
let d = r[l][0];
|
|
45
|
+
for (; o !== e && d >= n + s[o].str.length; ) {
|
|
46
|
+
const f = s[o];
|
|
47
|
+
n += f.str.length + i(f), o++;
|
|
48
48
|
}
|
|
49
49
|
const p = {
|
|
50
50
|
idx: o,
|
|
51
|
-
offset:
|
|
51
|
+
offset: d - n
|
|
52
52
|
};
|
|
53
|
-
for (
|
|
54
|
-
const f =
|
|
55
|
-
n += f.str.length +
|
|
53
|
+
for (d += r[l][1]; o !== e && d > n + s[o].str.length; ) {
|
|
54
|
+
const f = s[o];
|
|
55
|
+
n += f.str.length + i(f), o++;
|
|
56
56
|
}
|
|
57
57
|
const m = {
|
|
58
58
|
idx: o,
|
|
59
|
-
offset:
|
|
59
|
+
offset: d - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
62
|
start: p,
|
|
63
63
|
end: m,
|
|
64
|
-
str:
|
|
65
|
-
oIndex:
|
|
66
|
-
pageIndex:
|
|
64
|
+
str: r[l][2],
|
|
65
|
+
oIndex: r[l][0],
|
|
66
|
+
pageIndex: a,
|
|
67
|
+
rect: {
|
|
68
|
+
left: 0,
|
|
69
|
+
top: 0,
|
|
70
|
+
width: 0,
|
|
71
|
+
height: 0
|
|
72
|
+
}
|
|
67
73
|
});
|
|
68
74
|
}
|
|
75
|
+
for (const l of t) {
|
|
76
|
+
const d = s[l.start.idx], p = s[l.end.idx], m = d.transform[4], f = d.transform[5], E = m + d.width * l.start.offset / d.str.length, h = f, b = m + p.width * l.end.offset / p.str.length, N = f, u = {
|
|
77
|
+
left: Math.min(E, b),
|
|
78
|
+
top: Math.min(h, N),
|
|
79
|
+
width: Math.abs(b - E),
|
|
80
|
+
height: Math.max(d.height, p.height)
|
|
81
|
+
};
|
|
82
|
+
l.rect = u;
|
|
83
|
+
}
|
|
69
84
|
return t;
|
|
70
85
|
}
|
|
71
|
-
function
|
|
72
|
-
let
|
|
73
|
-
if (
|
|
74
|
-
const o =
|
|
75
|
-
if (
|
|
86
|
+
function L(r, c, a) {
|
|
87
|
+
let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
|
+
if (i) {
|
|
89
|
+
const o = r.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
|
+
if (X(o) === X(n))
|
|
76
91
|
return !1;
|
|
77
92
|
}
|
|
78
|
-
if (
|
|
79
|
-
const o =
|
|
80
|
-
if (
|
|
93
|
+
if (i = r.slice(c + a).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const o = r.charCodeAt(c + a - 1), n = i[1].charCodeAt(0);
|
|
95
|
+
if (X(o) === X(n))
|
|
81
96
|
return !1;
|
|
82
97
|
}
|
|
83
98
|
return !0;
|
|
84
99
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
function o(n,
|
|
88
|
-
const
|
|
89
|
-
let m = "", f = "",
|
|
90
|
-
if (!
|
|
100
|
+
function H(r, c, a) {
|
|
101
|
+
const i = [];
|
|
102
|
+
function o(n, s, e = -1, t = -1, l = "") {
|
|
103
|
+
const d = c.items[n], p = [];
|
|
104
|
+
let m = "", f = "", E = "", h = a[n];
|
|
105
|
+
if (!h)
|
|
91
106
|
return;
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
107
|
+
if (h.nodeType === Node.TEXT_NODE) {
|
|
108
|
+
const u = document.createElement("span");
|
|
109
|
+
h.before(u), u.append(h), a[n] = u, h = u;
|
|
95
110
|
}
|
|
96
|
-
e >= 0 && t >= 0 ? m =
|
|
97
|
-
const
|
|
98
|
-
if (N.className = "highlight appended " +
|
|
99
|
-
if (
|
|
100
|
-
f =
|
|
101
|
-
const
|
|
102
|
-
p.unshift(
|
|
111
|
+
e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
|
|
112
|
+
const b = document.createTextNode(m), N = document.createElement("span");
|
|
113
|
+
if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(b), p.push(N), i.push({ element: N, index: s }), e > 0)
|
|
114
|
+
if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
|
+
f = d.str.substring(0, e);
|
|
116
|
+
const u = document.createTextNode(f);
|
|
117
|
+
p.unshift(u);
|
|
103
118
|
} else {
|
|
104
|
-
let
|
|
105
|
-
const
|
|
106
|
-
for (const
|
|
107
|
-
const x =
|
|
108
|
-
|
|
119
|
+
let u = 0;
|
|
120
|
+
const C = [];
|
|
121
|
+
for (const g of h.childNodes) {
|
|
122
|
+
const x = g.nodeType === Node.TEXT_NODE ? g.nodeValue : g.firstChild.nodeValue;
|
|
123
|
+
u += x.length, u <= e ? C.push(g) : e >= u - x.length && t <= u && C.push(
|
|
109
124
|
document.createTextNode(
|
|
110
|
-
x.substring(0, e - (
|
|
125
|
+
x.substring(0, e - (u - x.length))
|
|
111
126
|
)
|
|
112
127
|
);
|
|
113
128
|
}
|
|
114
|
-
p.unshift(...
|
|
129
|
+
p.unshift(...C);
|
|
115
130
|
}
|
|
116
131
|
if (t > 0) {
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
p.push(
|
|
132
|
+
E = d.str.substring(t);
|
|
133
|
+
const u = document.createTextNode(E);
|
|
134
|
+
p.push(u);
|
|
120
135
|
}
|
|
121
|
-
|
|
136
|
+
h.replaceChildren(...p);
|
|
122
137
|
}
|
|
123
|
-
for (const [n,
|
|
124
|
-
if (
|
|
125
|
-
o(
|
|
138
|
+
for (const [n, s] of r.entries())
|
|
139
|
+
if (s.start.idx === s.end.idx)
|
|
140
|
+
o(s.start.idx, n, s.start.offset, s.end.offset);
|
|
126
141
|
else
|
|
127
|
-
for (let e =
|
|
128
|
-
e ===
|
|
129
|
-
return
|
|
142
|
+
for (let e = s.start.idx, t = s.end.idx; e <= t; e++)
|
|
143
|
+
e === s.start.idx ? o(e, n, s.start.offset, -1, "begin") : e === s.end.idx ? o(e, n, -1, s.end.offset, "end") : o(e, n, -1, -1, "middle");
|
|
144
|
+
return i;
|
|
130
145
|
}
|
|
131
|
-
function R(
|
|
132
|
-
const
|
|
133
|
-
for (let
|
|
134
|
-
const o = c[
|
|
146
|
+
function R(r, c) {
|
|
147
|
+
const a = r.items.map((i) => i.str);
|
|
148
|
+
for (let i = 0; i < c.length; i++) {
|
|
149
|
+
const o = c[i];
|
|
135
150
|
if (o && o.nodeType !== Node.TEXT_NODE) {
|
|
136
|
-
const n = document.createTextNode(
|
|
151
|
+
const n = document.createTextNode(a[i]);
|
|
137
152
|
o.replaceChildren(n);
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
|
-
function W(
|
|
142
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function W(r = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...r };
|
|
143
158
|
}
|
|
144
|
-
function A(
|
|
145
|
-
const
|
|
146
|
-
function o(n,
|
|
147
|
-
var
|
|
148
|
-
const
|
|
149
|
-
let m = "", f = "",
|
|
150
|
-
if (!
|
|
159
|
+
function A(r, c, a) {
|
|
160
|
+
const i = [];
|
|
161
|
+
function o(n, s, e = -1, t = -1, l) {
|
|
162
|
+
var u, C;
|
|
163
|
+
const d = c.items[n], p = [];
|
|
164
|
+
let m = "", f = "", E = "", h = a[n];
|
|
165
|
+
if (!h)
|
|
151
166
|
return;
|
|
152
|
-
e >= 0 && t >= 0 ? m =
|
|
153
|
-
const
|
|
154
|
-
if (N.style.background =
|
|
155
|
-
if (
|
|
156
|
-
f =
|
|
157
|
-
const
|
|
158
|
-
p.unshift(
|
|
167
|
+
e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
|
|
168
|
+
const b = document.createTextNode(m), N = document.createElement("span");
|
|
169
|
+
if (N.style.background = l, N.append(b), p.push(N), e > 0)
|
|
170
|
+
if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
|
+
f = d.str.substring(0, e);
|
|
172
|
+
const g = document.createTextNode(f);
|
|
173
|
+
p.unshift(g);
|
|
159
174
|
} else {
|
|
160
|
-
let
|
|
175
|
+
let g = 0;
|
|
161
176
|
const x = [];
|
|
162
|
-
for (const T of
|
|
163
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
164
|
-
if (
|
|
177
|
+
for (const T of h.childNodes) {
|
|
178
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((u = T.firstChild) == null ? void 0 : u.nodeValue) || "", M = v.length;
|
|
179
|
+
if (g += M, g <= e)
|
|
165
180
|
x.push(T);
|
|
166
|
-
else if (e >=
|
|
167
|
-
const
|
|
168
|
-
x.push(document.createTextNode(
|
|
181
|
+
else if (e >= g - M && t <= g) {
|
|
182
|
+
const w = v.substring(0, e - (g - M));
|
|
183
|
+
x.push(document.createTextNode(w));
|
|
169
184
|
}
|
|
170
185
|
}
|
|
171
186
|
p.unshift(...x);
|
|
172
187
|
}
|
|
173
188
|
if (t > 0)
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
p.push(
|
|
189
|
+
if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
190
|
+
E = d.str.substring(t);
|
|
191
|
+
const g = document.createTextNode(E);
|
|
192
|
+
p.push(g);
|
|
178
193
|
} else {
|
|
179
|
-
let
|
|
194
|
+
let g = 0;
|
|
180
195
|
const x = [];
|
|
181
|
-
for (const T of
|
|
182
|
-
|
|
183
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
|
|
196
|
+
for (const T of h.childNodes) {
|
|
197
|
+
g >= t && x.push(T);
|
|
198
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((C = T.firstChild) == null ? void 0 : C.nodeValue) || "", M = v.length;
|
|
199
|
+
if (g += M, g > t) {
|
|
200
|
+
const w = v.substring(t - (g - M));
|
|
201
|
+
w && x.push(document.createTextNode(w));
|
|
187
202
|
}
|
|
188
203
|
}
|
|
189
204
|
x.length > 0 && p.push(...x);
|
|
190
205
|
}
|
|
191
|
-
|
|
206
|
+
h.replaceChildren(...p), i.push({ element: N, index: s });
|
|
192
207
|
}
|
|
193
|
-
for (const [n,
|
|
194
|
-
const { start: e, end: t, color:
|
|
195
|
-
e.idx === t.idx && o(e.idx, n, e.offset, t.offset,
|
|
208
|
+
for (const [n, s] of r.entries()) {
|
|
209
|
+
const { start: e, end: t, color: l } = s;
|
|
210
|
+
e.idx === t.idx && o(e.idx, n, e.offset, t.offset, l);
|
|
196
211
|
}
|
|
197
|
-
return
|
|
212
|
+
return i;
|
|
198
213
|
}
|
|
199
214
|
export {
|
|
200
|
-
|
|
215
|
+
V as findMatches,
|
|
201
216
|
W as getHighlightOptionsWithDefaults,
|
|
202
|
-
|
|
217
|
+
H as highlightMatches,
|
|
203
218
|
A as highlightMultipleColorMatches,
|
|
204
219
|
R as resetDivs
|
|
205
220
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
|
-
import
|
|
4
|
+
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
+
import { c as E } from "../../RPDefaultLayout-4518b3d3.js";
|
|
5
6
|
import "../../contexts/DarkModeContext.js";
|
|
6
7
|
import "../../contexts/RotationContext.js";
|
|
7
8
|
import "../../contexts/LayerContext.js";
|
|
@@ -28,5 +29,5 @@ import "../../contexts/ThemeContext.js";
|
|
|
28
29
|
import "../../components/RPDropFileZone.js";
|
|
29
30
|
import "../../contexts/ToolbarComponentContext.js";
|
|
30
31
|
export {
|
|
31
|
-
|
|
32
|
+
E as useFileDownload
|
|
32
33
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as g, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as c } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-05-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-05-21T03:38:50.505Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
|
|
4
4
|
invalidLicense: `You are currently using without a valid license. ${l}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
|
|
6
6
|
expired: `Your license key has expired. ${l}`,
|
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { getThumbnailViewport as
|
|
4
|
-
import { useConfigContext as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useState as f, useRef as D, useEffect as C } from "react";
|
|
2
|
+
import * as k from "pdfjs-dist";
|
|
3
|
+
import { getThumbnailViewport as N } from "../getThumbnailViewport.js";
|
|
4
|
+
import { useConfigContext as S } from "../../contexts/ConfigContext.js";
|
|
5
|
+
import { useDocumentPasswordContext as U } from "../../contexts/DocumentPasswordContext.js";
|
|
6
|
+
const z = (m, o, I = {}) => {
|
|
7
|
+
const [r, q] = f(), { workerUrlAdded: x } = S(), [v, L] = f(/* @__PURE__ */ new Map()), i = D(), [R, g] = f(0), [P, y] = f(!1), {
|
|
8
|
+
password: d,
|
|
9
|
+
passwordError: T,
|
|
10
|
+
setPasswordError: u,
|
|
11
|
+
passwordRequired: c,
|
|
12
|
+
setPasswordRequired: a
|
|
13
|
+
} = U(), { onLoadError: p, onLoaded: w } = I;
|
|
14
|
+
return C(() => {
|
|
15
|
+
if (!x || !m)
|
|
9
16
|
return;
|
|
10
|
-
i.current = Date.now();
|
|
11
|
-
const t = i.current,
|
|
12
|
-
url:
|
|
13
|
-
cMapPacked: (
|
|
14
|
-
...(
|
|
17
|
+
g(0), a(!1), u(""), i.current = Date.now();
|
|
18
|
+
const t = i.current, E = {
|
|
19
|
+
url: m,
|
|
20
|
+
cMapPacked: (o == null ? void 0 : o.isCompressed) ?? !0,
|
|
21
|
+
...(o == null ? void 0 : o.url) && { cMapUrl: o.url },
|
|
22
|
+
...d && { password: d }
|
|
15
23
|
};
|
|
16
|
-
console.log("currently pdfjs version",
|
|
17
|
-
const n =
|
|
18
|
-
n.onProgress = (
|
|
24
|
+
console.log("currently pdfjs version", k.version, k);
|
|
25
|
+
const n = k.getDocument(E);
|
|
26
|
+
n.onProgress = (s) => {
|
|
19
27
|
if (t === i.current) {
|
|
20
|
-
const { loaded:
|
|
21
|
-
|
|
28
|
+
const { loaded: b, total: l } = s, j = l ? Math.min(100, Math.round(b / l * 100)) : 0;
|
|
29
|
+
g(j);
|
|
22
30
|
}
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
}).finally(() =>
|
|
31
|
+
}, y(!0);
|
|
32
|
+
const e = n.promise.then((s) => (t === i.current && (q(s), g(100)), w && w(s), a(!1), u(""), s)).catch((s) => {
|
|
33
|
+
s instanceof Error && s.name === "PasswordException" ? (a(!0), u(s.message || "Password required")) : s instanceof Error && s.name === "InvalidPDFException" && d ? (a(!0), u("Incorrect password")) : p && p(s);
|
|
34
|
+
}).finally(() => y(!1));
|
|
27
35
|
return () => {
|
|
28
|
-
|
|
36
|
+
e.finally(() => {
|
|
29
37
|
n.destroy();
|
|
30
38
|
});
|
|
31
39
|
};
|
|
32
|
-
}, [
|
|
40
|
+
}, [m, x, d, p, w]), C(() => {
|
|
41
|
+
if (c)
|
|
42
|
+
return;
|
|
33
43
|
const t = /* @__PURE__ */ new Map();
|
|
34
|
-
if (!r ||
|
|
35
|
-
|
|
44
|
+
if (!r || P) {
|
|
45
|
+
L(t);
|
|
36
46
|
return;
|
|
37
47
|
}
|
|
38
|
-
const
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
n.push(
|
|
48
|
+
const E = r.numPages, n = [];
|
|
49
|
+
for (let e = 1; e <= E; e++) {
|
|
50
|
+
const s = r.getPage(e);
|
|
51
|
+
n.push(s);
|
|
42
52
|
}
|
|
43
|
-
Promise.all(n).then((
|
|
44
|
-
|
|
45
|
-
const { thumbnailViewport:
|
|
46
|
-
t.set(
|
|
47
|
-
}),
|
|
53
|
+
Promise.all(n).then((e) => {
|
|
54
|
+
e.map((s) => {
|
|
55
|
+
const { thumbnailViewport: b, scale: l } = N(s);
|
|
56
|
+
t.set(s.pageNumber, { page: s, thumbnailViewport: b, thumbnailScale: l });
|
|
57
|
+
}), L(t);
|
|
48
58
|
});
|
|
49
|
-
}, [r,
|
|
59
|
+
}, [r, P, c]), {
|
|
50
60
|
pdf: r,
|
|
51
|
-
pages:
|
|
52
|
-
loading:
|
|
53
|
-
loadingProgress:
|
|
61
|
+
pages: v,
|
|
62
|
+
loading: P,
|
|
63
|
+
loadingProgress: R,
|
|
64
|
+
passwordRequired: c,
|
|
65
|
+
passwordError: T
|
|
54
66
|
};
|
|
55
67
|
};
|
|
56
68
|
export {
|
|
57
|
-
|
|
69
|
+
z as useLoadPdf
|
|
58
70
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import
|
|
2
|
+
import "../types.js";
|
|
3
|
+
import { g as G } from "../../RPDefaultLayout-4518b3d3.js";
|
|
3
4
|
import "react/jsx-runtime";
|
|
4
5
|
import "../../contexts/RPDocumentContext.js";
|
|
6
|
+
import "../../contexts/DocumentPasswordContext.js";
|
|
5
7
|
import "../../contexts/DarkModeContext.js";
|
|
6
8
|
import "../../contexts/RotationContext.js";
|
|
7
9
|
import "../../contexts/LayerContext.js";
|
|
@@ -29,5 +31,5 @@ import "../../components/RPDropFileZone.js";
|
|
|
29
31
|
import "../../contexts/ToolbarComponentContext.js";
|
|
30
32
|
import "./useDebounce.js";
|
|
31
33
|
export {
|
|
32
|
-
|
|
34
|
+
G as usePaginate
|
|
33
35
|
};
|
|
@@ -1,28 +1,79 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useDebounce as
|
|
3
|
-
import { useZoomContext as
|
|
4
|
-
const
|
|
5
|
-
const { currentZoom:
|
|
6
|
-
|
|
7
|
-
}, []),
|
|
1
|
+
import { useState as w, useRef as T, useCallback as r, useEffect as u } from "react";
|
|
2
|
+
import { useDebounce as g } from "./useDebounce.js";
|
|
3
|
+
import { useZoomContext as A } from "../../contexts/ZoomContext.js";
|
|
4
|
+
const I = (n) => {
|
|
5
|
+
const { currentZoom: m, setZoomLevel: b } = A(), [E, d] = w(m || 100), L = g(E, 100), [o, y] = w(!1), c = T(null), i = r((e) => {
|
|
6
|
+
d(e ? (t) => t + 3 : (t) => t - 3);
|
|
7
|
+
}, []), a = r(
|
|
8
8
|
(e) => {
|
|
9
9
|
if (!e.ctrlKey)
|
|
10
10
|
return;
|
|
11
11
|
e.preventDefault();
|
|
12
12
|
const t = e.deltaY < 0;
|
|
13
|
-
|
|
13
|
+
i(t);
|
|
14
14
|
},
|
|
15
|
-
[
|
|
15
|
+
[i]
|
|
16
16
|
);
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
const e = Math.round(
|
|
20
|
-
|
|
17
|
+
u(() => {
|
|
18
|
+
if (L) {
|
|
19
|
+
const e = Math.round(m * 100 + E);
|
|
20
|
+
d(0), b(e > 25 ? e : 25);
|
|
21
21
|
}
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
}, [L]);
|
|
23
|
+
const p = (e, t) => {
|
|
24
|
+
const s = e.clientX - t.clientX, l = e.clientY - t.clientY;
|
|
25
|
+
return Math.sqrt(s * s + l * l);
|
|
26
|
+
}, h = r(
|
|
27
|
+
(e) => {
|
|
28
|
+
if (!o || e.touches.length !== 2)
|
|
29
|
+
return;
|
|
30
|
+
const t = p(e.touches[0], e.touches[1]);
|
|
31
|
+
c.current = t, e.preventDefault();
|
|
32
|
+
},
|
|
33
|
+
[o]
|
|
34
|
+
), v = r(() => {
|
|
35
|
+
c.current = null;
|
|
36
|
+
}, []), f = r(
|
|
37
|
+
(e) => {
|
|
38
|
+
if (!o || e.touches.length !== 2 || c.current === null)
|
|
39
|
+
return;
|
|
40
|
+
const t = p(e.touches[0], e.touches[1]), s = t - c.current, l = Math.abs(s) > 5, S = s > 0;
|
|
41
|
+
l && (i(S), c.current = t, e.preventDefault());
|
|
42
|
+
},
|
|
43
|
+
[i, o]
|
|
44
|
+
), D = () => {
|
|
45
|
+
document.activeElement instanceof HTMLElement && document.activeElement.blur();
|
|
46
|
+
};
|
|
47
|
+
u(() => {
|
|
48
|
+
if (o) {
|
|
49
|
+
document.body.style.touchAction = "pan-x pan-y";
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
document.body.style.touchAction = "";
|
|
53
|
+
}, [o]), u(() => {
|
|
54
|
+
const e = () => {
|
|
55
|
+
const t = document.activeElement, s = !!(t != null && t.closest('[data-rp="container"]'));
|
|
56
|
+
y(s);
|
|
57
|
+
};
|
|
58
|
+
return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
|
|
59
|
+
window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
|
|
60
|
+
};
|
|
61
|
+
}, []), u(() => {
|
|
62
|
+
if (!n)
|
|
63
|
+
return;
|
|
64
|
+
const e = (t) => {
|
|
65
|
+
n.contains(t.target) || D();
|
|
66
|
+
};
|
|
67
|
+
return document.addEventListener("scroll", e), () => {
|
|
68
|
+
document.removeEventListener("scroll", e);
|
|
69
|
+
};
|
|
70
|
+
}, [n]), u(() => {
|
|
71
|
+
if (n)
|
|
72
|
+
return n.addEventListener("wheel", a, { passive: !1 }), n.addEventListener("touchstart", h, { passive: !1 }), n.addEventListener("touchmove", f, { passive: !1 }), n.addEventListener("touchend", v, { passive: !1 }), () => {
|
|
73
|
+
n.removeEventListener("wheel", a), n.removeEventListener("touchstart", h), n.removeEventListener("touchmove", f), n.removeEventListener("touchend", v);
|
|
74
|
+
};
|
|
75
|
+
}, [n, a, h, f, v]);
|
|
25
76
|
};
|
|
26
77
|
export {
|
|
27
|
-
|
|
78
|
+
I as usePinch
|
|
28
79
|
};
|
|
@@ -4,7 +4,8 @@ import "../../contexts/DimensionPagesContext.js";
|
|
|
4
4
|
import "../calculatePage.js";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "../../contexts/RPDocumentContext.js";
|
|
7
|
-
import
|
|
7
|
+
import "../../contexts/DocumentPasswordContext.js";
|
|
8
|
+
import { v as G } from "../../RPDefaultLayout-4518b3d3.js";
|
|
8
9
|
import "../../contexts/DarkModeContext.js";
|
|
9
10
|
import "../../contexts/RotationContext.js";
|
|
10
11
|
import "../../contexts/LayerContext.js";
|
|
@@ -30,5 +31,5 @@ import "../../components/RPDropFileZone.js";
|
|
|
30
31
|
import "../../contexts/ToolbarComponentContext.js";
|
|
31
32
|
import "./useDebounce.js";
|
|
32
33
|
export {
|
|
33
|
-
|
|
34
|
+
G as usePresentPage
|
|
34
35
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
|
-
import
|
|
4
|
+
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
+
import { i as F } from "../../RPDefaultLayout-4518b3d3.js";
|
|
5
6
|
import "../../contexts/DarkModeContext.js";
|
|
6
7
|
import "../../contexts/RotationContext.js";
|
|
7
8
|
import "../../contexts/LayerContext.js";
|
|
@@ -29,5 +30,5 @@ import "../../components/RPDropFileZone.js";
|
|
|
29
30
|
import "../../contexts/ToolbarComponentContext.js";
|
|
30
31
|
import "pdfjs-dist";
|
|
31
32
|
export {
|
|
32
|
-
|
|
33
|
+
F as usePrint
|
|
33
34
|
};
|