@pdf-viewer/react 1.18.0-beta.0 → 1.18.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/dist/types/utils/types.d.ts +1 -0
- package/dist/utils/highlight.js +139 -139
- package/dist/utils/hooks/useLicense.js +1 -1
- package/package.json +1 -1
package/dist/utils/highlight.js
CHANGED
|
@@ -1,221 +1,221 @@
|
|
|
1
1
|
import { getCharacterType as D } from "./charators.js";
|
|
2
|
-
function
|
|
3
|
-
const
|
|
2
|
+
function _(r, c, m, i) {
|
|
3
|
+
const s = [];
|
|
4
4
|
for (const n of r) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const o = y(c, n, i);
|
|
6
|
+
s.push(...R(o, c, m));
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return s;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
c.matchCase ||
|
|
13
|
-
let
|
|
14
|
-
return new RegExp(
|
|
10
|
+
const L = (r, c) => {
|
|
11
|
+
const m = ["g"];
|
|
12
|
+
c.matchCase || m.push("i");
|
|
13
|
+
let s = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
|
+
return new RegExp(s, m.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(r, c,
|
|
16
|
+
function y(r, c, m) {
|
|
17
17
|
const i = [];
|
|
18
18
|
for (const t of r.items)
|
|
19
19
|
if (t.hasEOL)
|
|
20
20
|
if (t.str.endsWith("-")) {
|
|
21
|
-
const
|
|
22
|
-
i.push(t.str.substring(0,
|
|
21
|
+
const d = t.str.lastIndexOf("-");
|
|
22
|
+
i.push(t.str.substring(0, d));
|
|
23
23
|
} else
|
|
24
24
|
i.push(t.str, `
|
|
25
25
|
`);
|
|
26
26
|
else
|
|
27
27
|
i.push(t.str);
|
|
28
|
-
const
|
|
28
|
+
const s = 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 = L(c, m);
|
|
31
|
+
const o = [];
|
|
32
32
|
let e;
|
|
33
|
-
for (; (e = n.exec(
|
|
34
|
-
|
|
35
|
-
return
|
|
33
|
+
for (; (e = n.exec(s)) !== null; )
|
|
34
|
+
m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
|
|
35
|
+
return o;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
function i(
|
|
39
|
-
return
|
|
37
|
+
function R(r, c, m) {
|
|
38
|
+
function i(d) {
|
|
39
|
+
return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
41
|
-
let
|
|
42
|
-
const
|
|
43
|
-
for (let
|
|
44
|
-
let
|
|
45
|
-
for (;
|
|
46
|
-
const
|
|
47
|
-
n +=
|
|
41
|
+
let s = 0, n = 0;
|
|
42
|
+
const o = c.items, e = o.length - 1, t = [];
|
|
43
|
+
for (let d = 0; d < r.length; d++) {
|
|
44
|
+
let h = r[d][0];
|
|
45
|
+
for (; s !== e && h >= n + o[s].str.length; ) {
|
|
46
|
+
const x = o[s];
|
|
47
|
+
n += x.str.length + i(x), s++;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
idx:
|
|
51
|
-
offset:
|
|
49
|
+
const g = {
|
|
50
|
+
idx: s,
|
|
51
|
+
offset: h - n
|
|
52
52
|
};
|
|
53
|
-
for (
|
|
54
|
-
const
|
|
55
|
-
n +=
|
|
53
|
+
for (h += r[d][1]; s !== e && h > n + o[s].str.length; ) {
|
|
54
|
+
const x = o[s];
|
|
55
|
+
n += x.str.length + i(x), s++;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
idx:
|
|
59
|
-
offset:
|
|
57
|
+
const l = {
|
|
58
|
+
idx: s,
|
|
59
|
+
offset: h - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
|
-
start:
|
|
63
|
-
end:
|
|
64
|
-
str: r[
|
|
65
|
-
oIndex: r[
|
|
66
|
-
pageIndex:
|
|
67
|
-
rect: {
|
|
68
|
-
|
|
69
|
-
bottom: 0,
|
|
70
|
-
width: 0,
|
|
71
|
-
height: 0
|
|
72
|
-
}
|
|
62
|
+
start: g,
|
|
63
|
+
end: l,
|
|
64
|
+
str: r[d][2],
|
|
65
|
+
oIndex: r[d][0],
|
|
66
|
+
pageIndex: m,
|
|
67
|
+
rect: { left: 0, bottom: 0, width: 0, height: 0 },
|
|
68
|
+
rects: []
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
for (const d of t) {
|
|
72
|
+
const h = [];
|
|
73
|
+
for (let g = d.start.idx; g <= d.end.idx; g++) {
|
|
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
|
+
left: f,
|
|
77
|
+
bottom: b,
|
|
78
|
+
width: E,
|
|
79
|
+
height: l.height
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
d.rect = h[0], d.rects = h;
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function W(r, c, m) {
|
|
87
87
|
let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
|
-
const
|
|
90
|
-
if (D(
|
|
89
|
+
const s = r.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
|
+
if (D(s) === D(n))
|
|
91
91
|
return !1;
|
|
92
92
|
}
|
|
93
|
-
if (i = r.slice(c +
|
|
94
|
-
const
|
|
95
|
-
if (D(
|
|
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
|
+
if (D(s) === D(n))
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function I(r, c, m) {
|
|
101
101
|
const i = [];
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
let
|
|
102
|
+
function s(n, o, e = -1, t = -1, d = "") {
|
|
103
|
+
const h = c.items[n], g = [];
|
|
104
|
+
let l = "", x = "", C = "", a = m[n];
|
|
105
105
|
if (!a)
|
|
106
106
|
return;
|
|
107
107
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
|
-
const
|
|
109
|
-
a.before(
|
|
108
|
+
const f = document.createElement("span");
|
|
109
|
+
a.before(f), f.append(a), m[n] = f, a = f;
|
|
110
110
|
}
|
|
111
|
-
e >= 0 && t >= 0 ?
|
|
112
|
-
const M = document.createTextNode(
|
|
113
|
-
if (N.className = "highlight appended " +
|
|
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
|
+
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
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
115
|
+
x = h.str.substring(0, e);
|
|
116
|
+
const f = document.createTextNode(x);
|
|
117
|
+
g.unshift(f);
|
|
118
118
|
} else {
|
|
119
|
-
let
|
|
120
|
-
const
|
|
121
|
-
for (const
|
|
122
|
-
const
|
|
123
|
-
|
|
119
|
+
let f = 0;
|
|
120
|
+
const E = [];
|
|
121
|
+
for (const p of a.childNodes) {
|
|
122
|
+
const u = p.nodeType === Node.TEXT_NODE ? p.nodeValue : p.firstChild.nodeValue;
|
|
123
|
+
f += u.length, f <= e ? E.push(p) : e >= f - u.length && t <= f && E.push(
|
|
124
124
|
document.createTextNode(
|
|
125
|
-
|
|
125
|
+
u.substring(0, e - (f - u.length))
|
|
126
126
|
)
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
g.unshift(...E);
|
|
130
130
|
}
|
|
131
131
|
if (t > 0) {
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
132
|
+
C = h.str.substring(t);
|
|
133
|
+
const f = document.createTextNode(C);
|
|
134
|
+
g.push(f);
|
|
135
135
|
}
|
|
136
|
-
a.replaceChildren(...
|
|
136
|
+
a.replaceChildren(...g);
|
|
137
137
|
}
|
|
138
|
-
for (const [n,
|
|
139
|
-
if (
|
|
140
|
-
o
|
|
138
|
+
for (const [n, o] of r.entries())
|
|
139
|
+
if (o.start.idx === o.end.idx)
|
|
140
|
+
s(o.start.idx, n, o.start.offset, o.end.offset);
|
|
141
141
|
else
|
|
142
|
-
for (let e =
|
|
143
|
-
e ===
|
|
142
|
+
for (let e = o.start.idx, t = o.end.idx; e <= t; e++)
|
|
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
|
|
147
|
-
const
|
|
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
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
const n = document.createTextNode(
|
|
152
|
-
|
|
149
|
+
const s = c[i];
|
|
150
|
+
if (s && s.nodeType !== Node.TEXT_NODE) {
|
|
151
|
+
const n = document.createTextNode(m[i]);
|
|
152
|
+
s.replaceChildren(n);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function H(r = {}) {
|
|
157
157
|
return { matchCase: !1, wholeWords: !1, ...r };
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function S(r, c, m) {
|
|
160
160
|
const i = [];
|
|
161
|
-
function
|
|
162
|
-
var
|
|
163
|
-
const
|
|
164
|
-
let
|
|
161
|
+
function s(n, o, e = -1, t = -1, d) {
|
|
162
|
+
var f, E;
|
|
163
|
+
const h = c.items[n], g = [];
|
|
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(
|
|
169
|
-
if (N.style.background =
|
|
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
|
+
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
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
x = h.str.substring(0, e);
|
|
172
|
+
const p = document.createTextNode(x);
|
|
173
|
+
g.unshift(p);
|
|
174
174
|
} else {
|
|
175
|
-
let
|
|
176
|
-
const
|
|
175
|
+
let p = 0;
|
|
176
|
+
const u = [];
|
|
177
177
|
for (const T of a.childNodes) {
|
|
178
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
else if (e >=
|
|
182
|
-
const w = v.substring(0, e - (
|
|
183
|
-
|
|
178
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((f = T.firstChild) == null ? void 0 : f.nodeValue) || "", b = v.length;
|
|
179
|
+
if (p += b, p <= e)
|
|
180
|
+
u.push(T);
|
|
181
|
+
else if (e >= p - b && t <= p) {
|
|
182
|
+
const w = v.substring(0, e - (p - b));
|
|
183
|
+
u.push(document.createTextNode(w));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
g.unshift(...u);
|
|
187
187
|
}
|
|
188
188
|
if (t > 0)
|
|
189
189
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
190
|
+
C = h.str.substring(t);
|
|
191
|
+
const p = document.createTextNode(C);
|
|
192
|
+
g.push(p);
|
|
193
193
|
} else {
|
|
194
|
-
let
|
|
195
|
-
const
|
|
194
|
+
let p = 0;
|
|
195
|
+
const u = [];
|
|
196
196
|
for (const T of a.childNodes) {
|
|
197
|
-
|
|
198
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
199
|
-
if (
|
|
200
|
-
const w = v.substring(t - (
|
|
201
|
-
w &&
|
|
197
|
+
p >= t && u.push(T);
|
|
198
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((E = T.firstChild) == null ? void 0 : E.nodeValue) || "", b = v.length;
|
|
199
|
+
if (p += b, p > t) {
|
|
200
|
+
const w = v.substring(t - (p - b));
|
|
201
|
+
w && u.push(document.createTextNode(w));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
u.length > 0 && g.push(...u);
|
|
205
205
|
}
|
|
206
|
-
a.replaceChildren(...
|
|
206
|
+
a.replaceChildren(...g), i.push({ element: N, index: o });
|
|
207
207
|
}
|
|
208
|
-
for (const [n,
|
|
209
|
-
const { start: e, end: t, color:
|
|
210
|
-
e.idx === t.idx &&
|
|
208
|
+
for (const [n, o] of r.entries()) {
|
|
209
|
+
const { start: e, end: t, color: d } = o;
|
|
210
|
+
e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
|
|
211
211
|
}
|
|
212
212
|
return i;
|
|
213
213
|
}
|
|
214
214
|
export {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
_ as findMatches,
|
|
216
|
+
H as getHighlightOptionsWithDefaults,
|
|
217
|
+
I as highlightMatches,
|
|
218
|
+
S as highlightMultipleColorMatches,
|
|
219
|
+
W as isMatchEntireWord,
|
|
220
|
+
V as resetDivs
|
|
221
221
|
};
|
|
@@ -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-02T10:36:09.752Z"), 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}`,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@pdf-viewer/react",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
|
|
5
|
-
"version": "1.18.0-beta.
|
|
5
|
+
"version": "1.18.0-beta.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react-pdf",
|
|
8
8
|
"react-pdf-viewer",
|