@react-pdf-kit/viewer 2.1.0-beta.1 → 2.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -49
- package/dist/assets/style.css +1 -1
- package/dist/components/layout/toolbar/DocumentDialog.js +36 -28
- package/dist/main.js +106 -104
- package/dist/types/main.d.ts +2 -0
- package/dist/utils/highlight.js +36 -36
- package/dist/utils/hooks/useHighlight.js +78 -40
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/usePrint.js +69 -76
- package/dist/utils/injectPrintCSS.js +4 -3
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import { RPProvider as
|
|
2
|
-
import { RPPages as
|
|
3
|
-
import { RPConfig as
|
|
4
|
-
import { RPDefaultLayout as
|
|
5
|
-
import { RPLayout as
|
|
6
|
-
import { RPTheme as
|
|
1
|
+
import { RPProvider as dt } from "./components/RPProvider.js";
|
|
2
|
+
import { RPPages as Dt } from "./components/RPPages.js";
|
|
3
|
+
import { RPConfig as Ft } from "./components/RPConfig.js";
|
|
4
|
+
import { RPDefaultLayout as Mt } from "./components/layout/RPDefaultLayout.js";
|
|
5
|
+
import { RPLayout as vt } from "./components/layout/RPLayout.js";
|
|
6
|
+
import { RPTheme as Bt } from "./components/RPTheme.js";
|
|
7
|
+
import { default as Ht } from "./components/ui/RPTooltip.js";
|
|
8
|
+
import { UIButton as bt } from "./components/ui/Button.js";
|
|
7
9
|
import { useDarkModeContext as zt } from "./contexts/DarkModeContext.js";
|
|
8
|
-
import { u as
|
|
9
|
-
import { useDocumentContext as
|
|
10
|
-
import { useRotationContext as
|
|
11
|
-
import { useViewModeContext as
|
|
12
|
-
import { useDropFileZoneContext as
|
|
13
|
-
import { useFileDownload as
|
|
14
|
-
import { useOpenFileContext as
|
|
15
|
-
import { usePrintContext as
|
|
16
|
-
import { useZoomContext as
|
|
17
|
-
import { useSearchContext as
|
|
18
|
-
import { useHighlightContext as
|
|
19
|
-
import { useFullScreenContext as
|
|
20
|
-
import { usePageRotateContext as
|
|
21
|
-
import { useElementPageContext as
|
|
22
|
-
import { SearchTool as
|
|
23
|
-
import { ThemeSwitcherTool as
|
|
24
|
-
import { ThumbnailTool as
|
|
25
|
-
import { FileUploadTool as
|
|
26
|
-
import { FileDownloadTool as
|
|
27
|
-
import { PrintTool as
|
|
28
|
-
import { FullScreenTool as
|
|
29
|
-
import { PreviousPageTool as
|
|
30
|
-
import { NextPageTool as
|
|
31
|
-
import { InputPageTool as
|
|
32
|
-
import { ZoomInTool as
|
|
10
|
+
import { u as Ut } from "./PaginationContext-9217cab4.js";
|
|
11
|
+
import { useDocumentContext as Nt } from "./contexts/RPDocumentContext.js";
|
|
12
|
+
import { useRotationContext as jt } from "./contexts/RotationContext.js";
|
|
13
|
+
import { useViewModeContext as At } from "./contexts/ViewModeContext.js";
|
|
14
|
+
import { useDropFileZoneContext as Jt } from "./contexts/DropFileZoneContext.js";
|
|
15
|
+
import { useFileDownload as Qt } from "./utils/hooks/useFileDownload.js";
|
|
16
|
+
import { useOpenFileContext as Yt } from "./contexts/FileInputContext.js";
|
|
17
|
+
import { usePrintContext as $t } from "./contexts/PrintContext.js";
|
|
18
|
+
import { useZoomContext as rm } from "./contexts/ZoomContext.js";
|
|
19
|
+
import { useSearchContext as mm } from "./contexts/SearchContext.js";
|
|
20
|
+
import { useHighlightContext as im } from "./contexts/HighlightContext.js";
|
|
21
|
+
import { useFullScreenContext as lm } from "./contexts/FullScreenContext.js";
|
|
22
|
+
import { usePageRotateContext as fm } from "./utils/hooks/usePageRotateContext.js";
|
|
23
|
+
import { useElementPageContext as nm } from "./contexts/ElementPageContext.js";
|
|
24
|
+
import { SearchTool as Tm } from "./components/layout/toolbar/SearchTool.js";
|
|
25
|
+
import { ThemeSwitcherTool as sm } from "./components/layout/toolbar/tools/ThemeSwitcherTool.js";
|
|
26
|
+
import { ThumbnailTool as gm } from "./components/layout/toolbar/tools/ThumbnailTool.js";
|
|
27
|
+
import { FileUploadTool as Rm } from "./components/layout/toolbar/tools/FileUploadTool.js";
|
|
28
|
+
import { FileDownloadTool as dm } from "./components/layout/toolbar/tools/FileDownloadTool.js";
|
|
29
|
+
import { PrintTool as Dm } from "./components/layout/toolbar/tools/PrintTool.js";
|
|
30
|
+
import { FullScreenTool as Fm } from "./components/layout/toolbar/tools/FullScreenTool.js";
|
|
31
|
+
import { PreviousPageTool as Mm } from "./components/layout/toolbar/tools/PreviousPageTool.js";
|
|
32
|
+
import { NextPageTool as vm } from "./components/layout/toolbar/tools/NextPageTool.js";
|
|
33
|
+
import { InputPageTool as Bm } from "./components/layout/toolbar/tools/InputPageTool.js";
|
|
34
|
+
import { ZoomInTool as Hm } from "./components/layout/toolbar/tools/ZoomInTool.js";
|
|
33
35
|
import { ZoomOutTool as bm } from "./components/layout/toolbar/tools/ZoomOutTool.js";
|
|
34
36
|
import { ZoomLevelTool as zm } from "./components/layout/toolbar/tools/ZoomLevelTool.js";
|
|
35
|
-
import { DocumentPropertiesTool as
|
|
36
|
-
import { RotateClockwiseTool as
|
|
37
|
-
import { RotateCounterclockwiseTool as
|
|
38
|
-
import { RPHorizontalBar as
|
|
39
|
-
import { RPVerticalBar as
|
|
40
|
-
import { SelectionModeSwitcherTool as
|
|
41
|
-
import { SinglePageTool as
|
|
42
|
-
import { DualPageTool as
|
|
43
|
-
import { DualPageWithCoverTool as
|
|
44
|
-
import { PageScrollingTool as
|
|
45
|
-
import { VerticalScrollingTool as
|
|
46
|
-
import { HorizontalScrollingTool as
|
|
47
|
-
import { FirstPageTool as
|
|
48
|
-
import { LastPageTool as
|
|
49
|
-
import { Locales as
|
|
37
|
+
import { DocumentPropertiesTool as Um } from "./components/layout/toolbar/tools/DocumentPropertiesTool.js";
|
|
38
|
+
import { RotateClockwiseTool as Nm } from "./components/layout/toolbar/tools/RotateClockwiseTool.js";
|
|
39
|
+
import { RotateCounterclockwiseTool as jm } from "./components/layout/toolbar/tools/RotateCounterclockwiseTool.js";
|
|
40
|
+
import { RPHorizontalBar as Am } from "./components/layout/toolbar/tools/defaults/RPHorizontalBar.js";
|
|
41
|
+
import { RPVerticalBar as Jm } from "./components/layout/toolbar/tools/defaults/RPVerticalBar.js";
|
|
42
|
+
import { SelectionModeSwitcherTool as Qm } from "./components/layout/toolbar/tools/SelectionModeSwitcherTool.js";
|
|
43
|
+
import { SinglePageTool as Ym } from "./components/layout/toolbar/tools/SinglePageTool.js";
|
|
44
|
+
import { DualPageTool as $m } from "./components/layout/toolbar/tools/DualPageTool.js";
|
|
45
|
+
import { DualPageWithCoverTool as rp } from "./components/layout/toolbar/tools/DualPageWithCoverTool.js";
|
|
46
|
+
import { PageScrollingTool as mp } from "./components/layout/toolbar/tools/PageScrollingTool.js";
|
|
47
|
+
import { VerticalScrollingTool as ip } from "./components/layout/toolbar/tools/VerticalScrollingTool.js";
|
|
48
|
+
import { HorizontalScrollingTool as lp } from "./components/layout/toolbar/tools/HorizontalScrollingTool.js";
|
|
49
|
+
import { FirstPageTool as fp } from "./components/layout/toolbar/tools/FirstPageTool.js";
|
|
50
|
+
import { LastPageTool as np } from "./components/layout/toolbar/tools/LastPageTool.js";
|
|
51
|
+
import { Locales as Tp, ScrollMode as Pp, SelectionMode as sp, ThemeVariables as cp, ViewMode as gp, ZoomLevel as Cp } from "./utils/types.js";
|
|
50
52
|
import "react/jsx-runtime";
|
|
51
53
|
import "react";
|
|
52
54
|
import "./contexts/DocumentPasswordContext.js";
|
|
@@ -128,24 +130,22 @@ import "./components/layout/toolbar/RPToolbar.js";
|
|
|
128
130
|
import "./RPToolbar.module-27d7fe77.js";
|
|
129
131
|
import "./components/layout/toolbar/Paginate.js";
|
|
130
132
|
import "./components/icons/ChevronUpIcon.js";
|
|
131
|
-
import "./components/ui/Button.js";
|
|
132
133
|
import "./components/ui/Input.js";
|
|
133
134
|
import "./Paginate.module-4eef00aa.js";
|
|
134
135
|
import "./contexts/IconContext.js";
|
|
135
136
|
import "./contexts/ToolbarComponentContext.js";
|
|
136
137
|
import "./contexts/ViewportContext.js";
|
|
137
|
-
import "./components/ui/RPTooltip.js";
|
|
138
|
-
import "./index-c0faa594.js";
|
|
139
|
-
import "react-dom";
|
|
140
|
-
import "./index-e3ee9457.js";
|
|
141
|
-
import "./floating-ui.react-dom-5ec29bd6.js";
|
|
142
|
-
import "./index-655864a7.js";
|
|
143
138
|
import "./components/layout/toolbar/RPToolbarEnd.js";
|
|
144
139
|
import "./components/layout/toolbar/FileUploadTool.js";
|
|
145
140
|
import "./components/icons/FileUploadDefaultIcon.js";
|
|
146
141
|
import "./components/layout/toolbar/MenuItem.js";
|
|
147
142
|
import "./index-61f59539.js";
|
|
143
|
+
import "./index-c0faa594.js";
|
|
144
|
+
import "react-dom";
|
|
145
|
+
import "./index-e3ee9457.js";
|
|
148
146
|
import "./Combination-136ff99c.js";
|
|
147
|
+
import "./floating-ui.react-dom-5ec29bd6.js";
|
|
148
|
+
import "./index-655864a7.js";
|
|
149
149
|
import "./components/layout/toolbar/DarkModeTool.js";
|
|
150
150
|
import "./components/icons/MoonIcon.js";
|
|
151
151
|
import "./components/icons/SunIcon.js";
|
|
@@ -230,58 +230,60 @@ import "./components/layout/toolbar/SearchCloseButton.js";
|
|
|
230
230
|
import "./components/icons/ChevronDownIcon.js";
|
|
231
231
|
import "./components/layout/toolbar/ThumbnailTool.js";
|
|
232
232
|
export {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
Dt as
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
sm as
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
233
|
+
Um as DocumentPropertiesTool,
|
|
234
|
+
$m as DualPageTool,
|
|
235
|
+
rp as DualPageWithCoverTool,
|
|
236
|
+
dm as FileDownloadTool,
|
|
237
|
+
Rm as FileUploadTool,
|
|
238
|
+
fp as FirstPageTool,
|
|
239
|
+
Fm as FullScreenTool,
|
|
240
|
+
lp as HorizontalScrollingTool,
|
|
241
|
+
Bm as InputPageTool,
|
|
242
|
+
np as LastPageTool,
|
|
243
|
+
Tp as Locales,
|
|
244
|
+
vm as NextPageTool,
|
|
245
|
+
mp as PageScrollingTool,
|
|
246
|
+
Mm as PreviousPageTool,
|
|
247
|
+
Dm as PrintTool,
|
|
248
|
+
bt as RPButton,
|
|
249
|
+
Ft as RPConfig,
|
|
250
|
+
Mt as RPDefaultLayout,
|
|
251
|
+
Am as RPHorizontalBar,
|
|
252
|
+
vt as RPLayout,
|
|
253
|
+
Dt as RPPages,
|
|
254
|
+
dt as RPProvider,
|
|
255
|
+
Bt as RPTheme,
|
|
256
|
+
Ht as RPTooltip,
|
|
257
|
+
Jm as RPVerticalBar,
|
|
258
|
+
Nm as RotateClockwiseTool,
|
|
259
|
+
jm as RotateCounterclockwiseTool,
|
|
260
|
+
Pp as ScrollMode,
|
|
261
|
+
Tm as SearchTool,
|
|
262
|
+
sp as SelectionMode,
|
|
263
|
+
Qm as SelectionModeSwitcherTool,
|
|
264
|
+
Ym as SinglePageTool,
|
|
265
|
+
sm as ThemeSwitcherTool,
|
|
266
|
+
cp as ThemeVariables,
|
|
267
|
+
gm as ThumbnailTool,
|
|
268
|
+
ip as VerticalScrollingTool,
|
|
269
|
+
gp as ViewMode,
|
|
270
|
+
Hm as ZoomInTool,
|
|
271
|
+
Cp as ZoomLevel,
|
|
270
272
|
zm as ZoomLevelTool,
|
|
271
273
|
bm as ZoomOutTool,
|
|
272
274
|
zt as useDarkModeContext,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
275
|
+
Nt as useDocumentContext,
|
|
276
|
+
Jt as useDropFileZoneContext,
|
|
277
|
+
nm as useElementPageContext,
|
|
278
|
+
Qt as useFileDownload,
|
|
279
|
+
lm as useFullScreenContext,
|
|
280
|
+
im as useHighlightContext,
|
|
281
|
+
Yt as useOpenFileContext,
|
|
282
|
+
fm as usePageRotateContext,
|
|
283
|
+
Ut as usePaginationContext,
|
|
284
|
+
$t as usePrintContext,
|
|
285
|
+
jt as useRotationContext,
|
|
286
|
+
mm as useSearchContext,
|
|
287
|
+
At as useViewModeContext,
|
|
288
|
+
rm as useZoomContext
|
|
287
289
|
};
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { RPConfig } from './components/RPConfig';
|
|
|
4
4
|
export { RPDefaultLayout } from './components/layout/RPDefaultLayout';
|
|
5
5
|
export { RPLayout } from './components/layout/RPLayout';
|
|
6
6
|
export { RPTheme } from './components/RPTheme';
|
|
7
|
+
export { default as RPTooltip } from './components/ui/RPTooltip';
|
|
8
|
+
export { UIButton as RPButton } from './components/ui/Button';
|
|
7
9
|
export { useDarkModeContext } from './contexts/DarkModeContext';
|
|
8
10
|
export { usePaginationContext } from './contexts/PaginationContext';
|
|
9
11
|
export { useDocumentContext } from './contexts/RPDocumentContext';
|
package/dist/utils/highlight.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { getCharacterType as D } from "./charators.js";
|
|
2
|
-
function _(
|
|
2
|
+
function _(l, c, m, i) {
|
|
3
3
|
const s = [];
|
|
4
|
-
for (const n of
|
|
4
|
+
for (const n of l) {
|
|
5
5
|
const o = y(c, n, i);
|
|
6
6
|
s.push(...R(o, c, m));
|
|
7
7
|
}
|
|
8
8
|
return s;
|
|
9
9
|
}
|
|
10
|
-
const L = (
|
|
10
|
+
const L = (l, c) => {
|
|
11
11
|
const m = ["g"];
|
|
12
12
|
c.matchCase || m.push("i");
|
|
13
|
-
let s =
|
|
13
|
+
let s = l.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
14
|
return new RegExp(s, m.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(
|
|
16
|
+
function y(l, c, m) {
|
|
17
17
|
const i = [];
|
|
18
|
-
for (const t of
|
|
18
|
+
for (const t of l.items)
|
|
19
19
|
if (t.hasEOL)
|
|
20
20
|
if (t.str.endsWith("-")) {
|
|
21
21
|
const d = t.str.lastIndexOf("-");
|
|
@@ -34,14 +34,14 @@ function y(r, c, m) {
|
|
|
34
34
|
m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
|
|
35
35
|
return o;
|
|
36
36
|
}
|
|
37
|
-
function R(
|
|
37
|
+
function R(l, c, m) {
|
|
38
38
|
function i(d) {
|
|
39
39
|
return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
41
41
|
let s = 0, n = 0;
|
|
42
42
|
const o = c.items, e = o.length - 1, t = [];
|
|
43
|
-
for (let d = 0; d <
|
|
44
|
-
let h =
|
|
43
|
+
for (let d = 0; d < l.length; d++) {
|
|
44
|
+
let h = l[d][0];
|
|
45
45
|
for (; s !== e && h >= n + o[s].str.length; ) {
|
|
46
46
|
const x = o[s];
|
|
47
47
|
n += x.str.length + i(x), s++;
|
|
@@ -50,19 +50,19 @@ function R(r, c, m) {
|
|
|
50
50
|
idx: s,
|
|
51
51
|
offset: h - n
|
|
52
52
|
};
|
|
53
|
-
for (h +=
|
|
53
|
+
for (h += l[d][1]; s !== e && h > n + o[s].str.length; ) {
|
|
54
54
|
const x = o[s];
|
|
55
55
|
n += x.str.length + i(x), s++;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const r = {
|
|
58
58
|
idx: s,
|
|
59
59
|
offset: h - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
62
|
start: g,
|
|
63
|
-
end:
|
|
64
|
-
str:
|
|
65
|
-
oIndex:
|
|
63
|
+
end: r,
|
|
64
|
+
str: l[d][2],
|
|
65
|
+
oIndex: l[d][0],
|
|
66
66
|
pageIndex: m,
|
|
67
67
|
rect: { left: 0, bottom: 0, width: 0, height: 0 },
|
|
68
68
|
rects: []
|
|
@@ -71,45 +71,45 @@ function R(r, c, m) {
|
|
|
71
71
|
for (const d of t) {
|
|
72
72
|
const h = [];
|
|
73
73
|
for (let g = d.start.idx; g <= d.end.idx; g++) {
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const r = o[g], x = r.transform[4], C = r.transform[5], a = r.str.length > 0 ? r.width / r.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : r.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[r.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * r.height;
|
|
75
|
+
r.height > 0 && r.width > 0 && h.push({
|
|
76
76
|
left: f,
|
|
77
77
|
bottom: b,
|
|
78
78
|
width: E,
|
|
79
|
-
height:
|
|
79
|
+
height: r.height
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
d.rect = h[0], d.rects = h;
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function W(
|
|
87
|
-
let i =
|
|
86
|
+
function W(l, c, m) {
|
|
87
|
+
let i = l.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
|
-
const s =
|
|
89
|
+
const s = l.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
90
|
if (D(s) === D(n))
|
|
91
91
|
return !1;
|
|
92
92
|
}
|
|
93
|
-
if (i =
|
|
94
|
-
const s =
|
|
93
|
+
if (i = l.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const s = l.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
|
|
95
95
|
if (D(s) === D(n))
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
|
-
function I(
|
|
100
|
+
function I(l, c, m) {
|
|
101
101
|
const i = [];
|
|
102
102
|
function s(n, o, e = -1, t = -1, d = "") {
|
|
103
103
|
const h = c.items[n], g = [];
|
|
104
|
-
let
|
|
104
|
+
let r = "", x = "", C = "", a = m[n];
|
|
105
105
|
if (!a)
|
|
106
106
|
return;
|
|
107
107
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
108
|
const f = document.createElement("span");
|
|
109
109
|
a.before(f), f.append(a), m[n] = f, a = f;
|
|
110
110
|
}
|
|
111
|
-
e >= 0 && t >= 0 ?
|
|
112
|
-
const M = document.createTextNode(
|
|
111
|
+
e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
|
|
112
|
+
const M = document.createTextNode(r), N = document.createElement("span");
|
|
113
113
|
if (N.className = "highlight appended " + d, N.setAttribute("data-match-index", `${o}`), N.append(M), g.push(N), i.push({ element: N, index: o }), e > 0)
|
|
114
114
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
115
|
x = h.str.substring(0, e);
|
|
@@ -135,7 +135,7 @@ function I(r, c, m) {
|
|
|
135
135
|
}
|
|
136
136
|
a.replaceChildren(...g);
|
|
137
137
|
}
|
|
138
|
-
for (const [n, o] of
|
|
138
|
+
for (const [n, o] of l.entries())
|
|
139
139
|
if (o.start.idx === o.end.idx)
|
|
140
140
|
s(o.start.idx, n, o.start.offset, o.end.offset);
|
|
141
141
|
else
|
|
@@ -143,8 +143,8 @@ function I(r, c, m) {
|
|
|
143
143
|
e === o.start.idx ? s(e, n, o.start.offset, -1, "begin") : e === o.end.idx ? s(e, n, -1, o.end.offset, "end") : s(e, n, -1, -1, "middle");
|
|
144
144
|
return i;
|
|
145
145
|
}
|
|
146
|
-
function V(
|
|
147
|
-
const m =
|
|
146
|
+
function V(l, c) {
|
|
147
|
+
const m = l.items.map((i) => i.str);
|
|
148
148
|
for (let i = 0; i < c.length; i++) {
|
|
149
149
|
const s = c[i];
|
|
150
150
|
if (s && s.nodeType !== Node.TEXT_NODE) {
|
|
@@ -153,19 +153,19 @@ function V(r, c) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function H(
|
|
157
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function H(l = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...l };
|
|
158
158
|
}
|
|
159
|
-
function S(
|
|
159
|
+
function S(l, c, m) {
|
|
160
160
|
const i = [];
|
|
161
161
|
function s(n, o, e = -1, t = -1, d) {
|
|
162
162
|
var f, E;
|
|
163
163
|
const h = c.items[n], g = [];
|
|
164
|
-
let
|
|
164
|
+
let r = "", x = "", C = "", a = m[n];
|
|
165
165
|
if (!a)
|
|
166
166
|
return;
|
|
167
|
-
e >= 0 && t >= 0 ?
|
|
168
|
-
const M = document.createTextNode(
|
|
167
|
+
e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
|
|
168
|
+
const M = document.createTextNode(r), N = document.createElement("span");
|
|
169
169
|
if (N.style.background = d, N.append(M), g.push(N), e > 0)
|
|
170
170
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
171
|
x = h.str.substring(0, e);
|
|
@@ -205,7 +205,7 @@ function S(r, c, m) {
|
|
|
205
205
|
}
|
|
206
206
|
a.replaceChildren(...g), i.push({ element: N, index: o });
|
|
207
207
|
}
|
|
208
|
-
for (const [n, o] of
|
|
208
|
+
for (const [n, o] of l.entries()) {
|
|
209
209
|
const { start: e, end: t, color: d } = o;
|
|
210
210
|
e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
|
|
211
211
|
}
|
|
@@ -1,55 +1,93 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { getHighlightOptionsWithDefaults as
|
|
1
|
+
import { useState as f, useCallback as p, useEffect as w } from "react";
|
|
2
|
+
import { getHighlightOptionsWithDefaults as k, findMatches as P } from "../highlight.js";
|
|
3
3
|
import "../charators.js";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
4
|
+
const x = (n) => {
|
|
5
|
+
const e = Math.min(...n.map((s) => s.left)), c = Math.max(...n.map((s) => s.left + s.width)), o = Math.min(...n.map((s) => s.bottom)), t = Math.max(...n.map((s) => s.height));
|
|
6
|
+
return { left: e, bottom: o, width: c - e, height: t };
|
|
7
|
+
}, N = (n) => n.flatMap((e) => e.rects ?? (e.rect ? [e.rect] : [])), O = (n) => {
|
|
8
|
+
const e = n.reduce((o, t) => {
|
|
9
|
+
const s = Math.round(t.bottom);
|
|
10
|
+
return o[s] || (o[s] = []), o[s].push(t), o;
|
|
11
|
+
}, {});
|
|
12
|
+
return Object.entries(e).sort((o, t) => Number(t[0]) - Number(o[0])).map(([o, t]) => x(t));
|
|
13
|
+
}, L = (n) => {
|
|
14
|
+
const e = {};
|
|
15
|
+
for (const c of n) {
|
|
16
|
+
const o = c.keyword, t = e[o] ?? [];
|
|
17
|
+
t.push(c), e[o] = t;
|
|
18
|
+
}
|
|
19
|
+
return e;
|
|
20
|
+
}, j = (n, e) => {
|
|
21
|
+
const c = n[0], o = N(n), t = o.length > 0 ? O(o) : c.rect ? [c.rect] : [];
|
|
22
|
+
return {
|
|
23
|
+
...c,
|
|
24
|
+
pageMatchIdx: e,
|
|
25
|
+
rect: t[0] ?? c.rect,
|
|
26
|
+
rects: t
|
|
27
|
+
};
|
|
28
|
+
}, v = (n) => {
|
|
29
|
+
const e = {};
|
|
30
|
+
for (const t of n) {
|
|
31
|
+
const s = e[t.page] ?? [];
|
|
32
|
+
s.push(t), e[t.page] = s;
|
|
33
|
+
}
|
|
34
|
+
let c = 0;
|
|
35
|
+
const o = [];
|
|
36
|
+
for (const t of Object.values(e)) {
|
|
37
|
+
const s = L(t);
|
|
38
|
+
for (const g of Object.values(s))
|
|
39
|
+
o.push(j(g, c++));
|
|
40
|
+
}
|
|
41
|
+
return o;
|
|
42
|
+
}, K = (n) => {
|
|
43
|
+
const [e, c] = f(void 0), [o, t] = f([]), s = p(async (r) => {
|
|
44
|
+
if (!r)
|
|
7
45
|
return {};
|
|
8
|
-
const i =
|
|
9
|
-
for (let
|
|
10
|
-
const
|
|
11
|
-
|
|
46
|
+
const i = r.numPages, h = {};
|
|
47
|
+
for (let a = 1; a <= i; a++) {
|
|
48
|
+
const u = await r.getPage(a);
|
|
49
|
+
h[a.toString()] = await u.getTextContent();
|
|
12
50
|
}
|
|
13
|
-
return
|
|
14
|
-
}, []),
|
|
15
|
-
c(
|
|
16
|
-
}, []),
|
|
17
|
-
|
|
51
|
+
return h;
|
|
52
|
+
}, []), g = p(async (r) => {
|
|
53
|
+
c(r);
|
|
54
|
+
}, []), l = p(() => {
|
|
55
|
+
t([]), c(void 0);
|
|
18
56
|
}, []);
|
|
19
|
-
return
|
|
20
|
-
|
|
57
|
+
return w(() => {
|
|
58
|
+
n && s(n).then((r) => {
|
|
21
59
|
let i = [];
|
|
22
|
-
for (const { keyword:
|
|
23
|
-
if (!
|
|
60
|
+
for (const { keyword: h, highlightColor: a, options: u } of e) {
|
|
61
|
+
if (!h)
|
|
24
62
|
continue;
|
|
25
|
-
const
|
|
26
|
-
for (const
|
|
27
|
-
const
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
Number(
|
|
31
|
-
|
|
32
|
-
).map((
|
|
33
|
-
...
|
|
34
|
-
page: Number(
|
|
35
|
-
pageMatchIdx:
|
|
36
|
-
color:
|
|
37
|
-
keyword:
|
|
63
|
+
const b = k(u);
|
|
64
|
+
for (const m of Object.keys(r)) {
|
|
65
|
+
const d = P(
|
|
66
|
+
[h],
|
|
67
|
+
r[m],
|
|
68
|
+
Number(m) - 1,
|
|
69
|
+
b
|
|
70
|
+
).map((M, y) => ({
|
|
71
|
+
...M,
|
|
72
|
+
page: Number(m),
|
|
73
|
+
pageMatchIdx: y,
|
|
74
|
+
color: a,
|
|
75
|
+
keyword: h
|
|
38
76
|
}));
|
|
39
|
-
i = [...i, ...
|
|
77
|
+
i = [...i, ...d];
|
|
40
78
|
}
|
|
41
79
|
}
|
|
42
|
-
|
|
80
|
+
t(v(i));
|
|
43
81
|
}).catch(() => {
|
|
44
|
-
|
|
82
|
+
l();
|
|
45
83
|
});
|
|
46
|
-
}, [
|
|
47
|
-
highlight:
|
|
48
|
-
clear:
|
|
49
|
-
highlightMatches:
|
|
50
|
-
highlightKeywords:
|
|
84
|
+
}, [e, n, l, s]), {
|
|
85
|
+
highlight: g,
|
|
86
|
+
clear: l,
|
|
87
|
+
highlightMatches: o,
|
|
88
|
+
highlightKeywords: e
|
|
51
89
|
};
|
|
52
90
|
};
|
|
53
91
|
export {
|
|
54
|
-
|
|
92
|
+
K as useHighlight
|
|
55
93
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as E, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2026-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2026-03-06T06:28:25.760Z"), d = "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. ${d}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
6
6
|
expired: `Your license key has expired. ${d}`,
|