@react-pdf-kit/viewer 2.0.1-rc.6 → 2.1.0-beta.1
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 +49 -84
- package/dist/{Combination-17ab8af1.js → Combination-136ff99c.js} +2 -2
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +4 -4
- package/dist/components/RPController.js +73 -74
- package/dist/components/RPPages.js +544 -545
- package/dist/components/layout/RPDefaultLayout.js +6 -6
- package/dist/components/layout/RPLayout.js +6 -6
- package/dist/components/layout/sidebar/RPSidebar.js +4 -4
- package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +3 -3
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
- package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
- package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/MenuItem.js +6 -6
- package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
- package/dist/components/layout/toolbar/MostPageTool.js +6 -6
- package/dist/components/layout/toolbar/OtherTool.js +6 -6
- package/dist/components/layout/toolbar/Paginate.js +4 -4
- package/dist/components/layout/toolbar/PrintTool.js +6 -6
- package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
- package/dist/components/layout/toolbar/RPMoreOptions.js +6 -6
- package/dist/components/layout/toolbar/RPToolbar.js +6 -6
- package/dist/components/layout/toolbar/RPToolbarEnd.js +6 -6
- package/dist/components/layout/toolbar/RotateTool.js +6 -6
- package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
- package/dist/components/layout/toolbar/SearchResultNavigator.js +21 -29
- package/dist/components/layout/toolbar/SearchTool.js +102 -99
- package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/ThumbnailTool.js +4 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +6 -6
- package/dist/components/layout/toolbar/ToolbarLayout.js +6 -6
- package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
- package/dist/components/layout/toolbar/ZoomTool.js +6 -6
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +5 -5
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +6 -6
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -4
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +4 -4
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +6 -6
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/LastPageTool.js +6 -6
- package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PrintTool.js +4 -4
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +4 -4
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +4 -4
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -4
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +6 -6
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +4 -4
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -6
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -4
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
- package/dist/components/ui/Checkbox.js +2 -2
- package/dist/components/ui/DropDown.js +6 -6
- package/dist/components/ui/Input.js +10 -10
- package/dist/components/ui/RPTooltip.js +411 -197
- package/dist/contexts/InitialStateContext.js +6 -8
- package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
- package/dist/index-61f59539.js +1198 -0
- package/dist/{index-ada501c4.js → index-655864a7.js} +1 -1
- package/dist/{index-113053cf.js → index-c0faa594.js} +2 -2
- package/dist/{index-23911b43.js → index-e3ee9457.js} +6 -6
- package/dist/main.js +6 -6
- package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
- package/dist/types/utils/types.d.ts +1 -1
- package/dist/utils/highlight.js +36 -36
- package/dist/utils/hooks/useHighlight.js +40 -78
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/usePrint.js +78 -71
- package/dist/utils/hooks/useWatermark.js +43 -61
- package/dist/utils/injectPrintCSS.js +9 -9
- package/package.json +1 -1
- package/dist/index-11f3cd64.js +0 -983
- package/dist/index-d0f0aa9a.js +0 -1542
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as r from "react";
|
|
2
|
-
import { a as R, P as w, b as
|
|
2
|
+
import { a as R, P as w, b as y, h as _, u as U } from "./index-c0faa594.js";
|
|
3
3
|
import { jsx as T } from "react/jsx-runtime";
|
|
4
4
|
function b(t) {
|
|
5
5
|
const e = r.useRef(t);
|
|
@@ -34,11 +34,11 @@ var H = "DismissableLayer", p = "dismissableLayer.update", M = "dismissableLayer
|
|
|
34
34
|
onDismiss: d,
|
|
35
35
|
...E
|
|
36
36
|
} = t, u = r.useContext(S), [c, B] = r.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = r.useState({}), I = R(e, (o) => B(o)), m = Array.from(u.layers), [W] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), A = m.indexOf(W), P = c ? m.indexOf(c) : -1, N = u.layersWithOutsidePointerEventsDisabled.size > 0, D = P >= A, k = $((o) => {
|
|
37
|
-
const v = o.target, C = [...u.branches].some((
|
|
37
|
+
const v = o.target, C = [...u.branches].some((h) => h.contains(v));
|
|
38
38
|
!D || C || (i == null || i(o), l == null || l(o), o.defaultPrevented || d == null || d());
|
|
39
39
|
}, f), L = q((o) => {
|
|
40
40
|
const v = o.target;
|
|
41
|
-
[...u.branches].some((
|
|
41
|
+
[...u.branches].some((h) => h.contains(v)) || (a == null || a(o), l == null || l(o), o.defaultPrevented || d == null || d());
|
|
42
42
|
}, f);
|
|
43
43
|
return z((o) => {
|
|
44
44
|
P === u.layers.size - 1 && (s == null || s(o), !o.defaultPrevented && d && (o.preventDefault(), d()));
|
|
@@ -61,9 +61,9 @@ var H = "DismissableLayer", p = "dismissableLayer.update", M = "dismissableLayer
|
|
|
61
61
|
pointerEvents: N ? D ? "auto" : "none" : void 0,
|
|
62
62
|
...t.style
|
|
63
63
|
},
|
|
64
|
-
onFocusCapture:
|
|
65
|
-
onBlurCapture:
|
|
66
|
-
onPointerDownCapture:
|
|
64
|
+
onFocusCapture: y(t.onFocusCapture, L.onFocusCapture),
|
|
65
|
+
onBlurCapture: y(t.onBlurCapture, L.onBlurCapture),
|
|
66
|
+
onPointerDownCapture: y(
|
|
67
67
|
t.onPointerDownCapture,
|
|
68
68
|
k.onPointerDownCapture
|
|
69
69
|
)
|
package/dist/main.js
CHANGED
|
@@ -135,17 +135,17 @@ import "./contexts/IconContext.js";
|
|
|
135
135
|
import "./contexts/ToolbarComponentContext.js";
|
|
136
136
|
import "./contexts/ViewportContext.js";
|
|
137
137
|
import "./components/ui/RPTooltip.js";
|
|
138
|
-
import "./index-
|
|
138
|
+
import "./index-c0faa594.js";
|
|
139
139
|
import "react-dom";
|
|
140
|
-
import "./index-
|
|
141
|
-
import "./
|
|
142
|
-
import "./index-
|
|
140
|
+
import "./index-e3ee9457.js";
|
|
141
|
+
import "./floating-ui.react-dom-5ec29bd6.js";
|
|
142
|
+
import "./index-655864a7.js";
|
|
143
143
|
import "./components/layout/toolbar/RPToolbarEnd.js";
|
|
144
144
|
import "./components/layout/toolbar/FileUploadTool.js";
|
|
145
145
|
import "./components/icons/FileUploadDefaultIcon.js";
|
|
146
146
|
import "./components/layout/toolbar/MenuItem.js";
|
|
147
|
-
import "./index-
|
|
148
|
-
import "./Combination-
|
|
147
|
+
import "./index-61f59539.js";
|
|
148
|
+
import "./Combination-136ff99c.js";
|
|
149
149
|
import "./components/layout/toolbar/DarkModeTool.js";
|
|
150
150
|
import "./components/icons/MoonIcon.js";
|
|
151
151
|
import "./components/icons/SunIcon.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useWatermark: (
|
|
1
|
+
export declare const useWatermark: (container: HTMLDivElement | null) => void;
|
|
@@ -540,7 +540,6 @@ export interface ZoomContextType {
|
|
|
540
540
|
}
|
|
541
541
|
export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
|
|
542
542
|
export type InitialStateContextType = {
|
|
543
|
-
instanceId: string;
|
|
544
543
|
interactiveForm?: boolean;
|
|
545
544
|
} & ZoomProviderProps & PageProviderProps & ViewModeInitialProps & ScrollModeInitialProps & RotateProviderProps;
|
|
546
545
|
export interface ZoomProviderProps {
|
|
@@ -820,6 +819,7 @@ export interface RPHorizontalBarIcons {
|
|
|
820
819
|
documentPropertiesIcon?: React.ReactNode;
|
|
821
820
|
printIcon?: React.ReactNode;
|
|
822
821
|
searchIcon?: React.ReactNode;
|
|
822
|
+
searchClearIcon?: React.ReactNode;
|
|
823
823
|
textSelectionIcon?: React.ReactNode;
|
|
824
824
|
handModeIcon?: React.ReactNode;
|
|
825
825
|
}
|
package/dist/utils/highlight.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { getCharacterType as D } from "./charators.js";
|
|
2
|
-
function _(
|
|
2
|
+
function _(r, c, m, i) {
|
|
3
3
|
const s = [];
|
|
4
|
-
for (const n of
|
|
4
|
+
for (const n of r) {
|
|
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 = (r, c) => {
|
|
11
11
|
const m = ["g"];
|
|
12
12
|
c.matchCase || m.push("i");
|
|
13
|
-
let s =
|
|
13
|
+
let s = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
14
|
return new RegExp(s, m.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(
|
|
16
|
+
function y(r, c, m) {
|
|
17
17
|
const i = [];
|
|
18
|
-
for (const t of
|
|
18
|
+
for (const t of r.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(l, 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(r, 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 < r.length; d++) {
|
|
44
|
+
let h = r[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(l, c, m) {
|
|
|
50
50
|
idx: s,
|
|
51
51
|
offset: h - n
|
|
52
52
|
};
|
|
53
|
-
for (h +=
|
|
53
|
+
for (h += r[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 l = {
|
|
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: l,
|
|
64
|
+
str: r[d][2],
|
|
65
|
+
oIndex: r[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(l, 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 l = o[g], x = l.transform[4], C = l.transform[5], a = l.str.length > 0 ? l.width / l.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : l.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[l.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 * l.height;
|
|
75
|
+
(E > 0 || l.height > 0) && h.push({
|
|
76
76
|
left: f,
|
|
77
77
|
bottom: b,
|
|
78
78
|
width: E,
|
|
79
|
-
height:
|
|
79
|
+
height: l.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(r, c, m) {
|
|
87
|
+
let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
|
-
const s =
|
|
89
|
+
const s = r.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 = r.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const s = r.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(r, 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 l = "", 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 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
|
|
112
|
+
const M = document.createTextNode(l), 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(l, c, m) {
|
|
|
135
135
|
}
|
|
136
136
|
a.replaceChildren(...g);
|
|
137
137
|
}
|
|
138
|
-
for (const [n, o] of
|
|
138
|
+
for (const [n, o] of r.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(l, 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(r, c) {
|
|
147
|
+
const m = r.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(l, c) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function H(
|
|
157
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function H(r = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...r };
|
|
158
158
|
}
|
|
159
|
-
function S(
|
|
159
|
+
function S(r, 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 l = "", 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 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
|
|
168
|
+
const M = document.createTextNode(l), 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(l, 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 r.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,93 +1,55 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { getHighlightOptionsWithDefaults as
|
|
1
|
+
import { useState as m, useCallback as r, useEffect as C } from "react";
|
|
2
|
+
import { getHighlightOptionsWithDefaults as H, findMatches as M } from "../highlight.js";
|
|
3
3
|
import "../charators.js";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
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)
|
|
4
|
+
const k = (s) => {
|
|
5
|
+
const [n, c] = m(void 0), [f, l] = m([]), u = r(async (t) => {
|
|
6
|
+
if (!t)
|
|
45
7
|
return {};
|
|
46
|
-
const i =
|
|
47
|
-
for (let
|
|
48
|
-
const
|
|
49
|
-
|
|
8
|
+
const i = t.numPages, e = {};
|
|
9
|
+
for (let o = 1; o <= i; o++) {
|
|
10
|
+
const h = await t.getPage(o);
|
|
11
|
+
e[o.toString()] = await h.getTextContent();
|
|
50
12
|
}
|
|
51
|
-
return
|
|
52
|
-
}, []),
|
|
53
|
-
c(
|
|
54
|
-
}, []),
|
|
55
|
-
|
|
13
|
+
return e;
|
|
14
|
+
}, []), p = r(async (t) => {
|
|
15
|
+
c(t);
|
|
16
|
+
}, []), g = r(() => {
|
|
17
|
+
l([]), c(void 0);
|
|
56
18
|
}, []);
|
|
57
|
-
return
|
|
58
|
-
|
|
19
|
+
return C(() => {
|
|
20
|
+
s && u(s).then((t) => {
|
|
59
21
|
let i = [];
|
|
60
|
-
for (const { keyword:
|
|
61
|
-
if (!
|
|
22
|
+
for (const { keyword: e, highlightColor: o, options: h } of n) {
|
|
23
|
+
if (!e)
|
|
62
24
|
continue;
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
65
|
-
const
|
|
66
|
-
[
|
|
67
|
-
|
|
68
|
-
Number(
|
|
69
|
-
|
|
70
|
-
).map((
|
|
71
|
-
...
|
|
72
|
-
page: Number(
|
|
73
|
-
pageMatchIdx:
|
|
74
|
-
color:
|
|
75
|
-
keyword:
|
|
25
|
+
const y = H(h);
|
|
26
|
+
for (const a of Object.keys(t)) {
|
|
27
|
+
const b = M(
|
|
28
|
+
[e],
|
|
29
|
+
t[a],
|
|
30
|
+
Number(a) - 1,
|
|
31
|
+
y
|
|
32
|
+
).map((w, x) => ({
|
|
33
|
+
...w,
|
|
34
|
+
page: Number(a),
|
|
35
|
+
pageMatchIdx: x,
|
|
36
|
+
color: o,
|
|
37
|
+
keyword: e
|
|
76
38
|
}));
|
|
77
|
-
i = [...i, ...
|
|
39
|
+
i = [...i, ...b];
|
|
78
40
|
}
|
|
79
41
|
}
|
|
80
|
-
|
|
42
|
+
l(i);
|
|
81
43
|
}).catch(() => {
|
|
82
|
-
|
|
44
|
+
g();
|
|
83
45
|
});
|
|
84
|
-
}, [
|
|
85
|
-
highlight:
|
|
86
|
-
clear:
|
|
87
|
-
highlightMatches:
|
|
88
|
-
highlightKeywords:
|
|
46
|
+
}, [n, s, g, u]), {
|
|
47
|
+
highlight: p,
|
|
48
|
+
clear: g,
|
|
49
|
+
highlightMatches: f,
|
|
50
|
+
highlightKeywords: n
|
|
89
51
|
};
|
|
90
52
|
};
|
|
91
53
|
export {
|
|
92
|
-
|
|
54
|
+
k as useHighlight
|
|
93
55
|
};
|
|
@@ -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-02-27T08:34:10.839Z"), 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}`,
|