@react-pdf-kit/viewer 2.0.1-rc.2 → 2.1.0-beta.0
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 -88
- package/dist/components/RPController.js +73 -74
- package/dist/components/RPPages.js +544 -545
- package/dist/components/layout/toolbar/SearchTool.js +96 -93
- package/dist/contexts/InitialStateContext.js +6 -8
- 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 +93 -82
- package/dist/utils/hooks/useWatermark.js +39 -57
- package/dist/utils/injectPrintCSS.js +2 -1
- package/package.json +1 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsx as o, Fragment as
|
|
2
|
-
import { UIButton as
|
|
1
|
+
import { jsx as o, Fragment as pt, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import { UIButton as mt } from "../../ui/Button.js";
|
|
3
3
|
import { SearchIcon as A } from "../../icons/SearchIcon.js";
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useLayoutContainer as
|
|
4
|
+
import { useState as S, useCallback as i, useEffect as h, useMemo as W } from "react";
|
|
5
|
+
import { useLayoutContainer as st } from "../../../contexts/LayoutContainerContext.js";
|
|
6
6
|
import { c as n } from "../../../SearchTool.module-99f60dc7.js";
|
|
7
|
-
import { UIInput as
|
|
7
|
+
import { UIInput as lt } from "../../ui/Input.js";
|
|
8
8
|
import { UICheckbox as $ } from "../../ui/Checkbox.js";
|
|
9
9
|
import { ClearIcon as ht } from "../../icons/ClearIcon.js";
|
|
10
|
-
import { LoaderIcon as
|
|
11
|
-
import { useSearchContext as
|
|
12
|
-
import { useIconContext as
|
|
13
|
-
import { useDocumentContext as
|
|
14
|
-
import
|
|
15
|
-
import { useToolbarComponentContext as
|
|
16
|
-
import { useLocalizationContext as
|
|
10
|
+
import { LoaderIcon as dt } from "../../icons/LoaderIcon.js";
|
|
11
|
+
import { useSearchContext as ut } from "../../../contexts/SearchContext.js";
|
|
12
|
+
import { useIconContext as F } from "../../../contexts/IconContext.js";
|
|
13
|
+
import { useDocumentContext as ft } from "../../../contexts/RPDocumentContext.js";
|
|
14
|
+
import v from "../../ui/RPTooltip.js";
|
|
15
|
+
import { useToolbarComponentContext as It } from "../../../contexts/ToolbarComponentContext.js";
|
|
16
|
+
import { useLocalizationContext as Ct } from "../../../contexts/LocalizationContext.js";
|
|
17
17
|
import { InfoIcon as j } from "../../icons/InfoIcon.js";
|
|
18
|
-
import { useViewportContext as
|
|
18
|
+
import { useViewportContext as bt } from "../../../contexts/ViewportContext.js";
|
|
19
19
|
import { SearchResultNavigator as q } from "./SearchResultNavigator.js";
|
|
20
20
|
import { SearchCloseButton as z } from "./SearchCloseButton.js";
|
|
21
|
-
import { UIDropDown as
|
|
22
|
-
import { useIconToolContext as
|
|
21
|
+
import { UIDropDown as xt } from "../../ui/DropDown.js";
|
|
22
|
+
import { useIconToolContext as H } from "../../../contexts/IconToolContext.js";
|
|
23
23
|
import { useToolComponentContext as St } from "../../../contexts/ToolComponentContext.js";
|
|
24
24
|
import "../../../clsx-0c6e471a.js";
|
|
25
25
|
import "../../../utils/withRef.js";
|
|
@@ -69,78 +69,81 @@ import "../../icons/CloseIcon.js";
|
|
|
69
69
|
import "../../../index-61f59539.js";
|
|
70
70
|
import "../../../Combination-136ff99c.js";
|
|
71
71
|
const yt = () => {
|
|
72
|
-
const { searchIcon:
|
|
73
|
-
return
|
|
74
|
-
},
|
|
75
|
-
const {
|
|
72
|
+
const { searchIcon: s } = F(), { searchIcon: d } = H();
|
|
73
|
+
return s ?? d ?? /* @__PURE__ */ o(A, {});
|
|
74
|
+
}, Tt = () => {
|
|
75
|
+
const { searchClearIcon: s } = F(), { searchClearIcon: d } = H();
|
|
76
|
+
return s ?? d ?? /* @__PURE__ */ o(ht, {});
|
|
77
|
+
}, qo = ({ icon: s }) => {
|
|
78
|
+
const { container: d } = st(), [u, L] = S(!1), { pdf: y } = ft(), [k, G] = S(null), {
|
|
76
79
|
searchOptions: D,
|
|
77
|
-
setSearchOptions:
|
|
78
|
-
loading:
|
|
80
|
+
setSearchOptions: T,
|
|
81
|
+
loading: J,
|
|
79
82
|
setSearch: c,
|
|
80
83
|
totalMatches: K,
|
|
81
84
|
currentMatchPosition: B,
|
|
82
85
|
nextMatch: O,
|
|
83
86
|
prevMatch: P,
|
|
84
87
|
search: e
|
|
85
|
-
} =
|
|
88
|
+
} = ut(), { searchTool: Q = !0 } = It(), { searchTool: X = !0 } = St(), [f, I] = S(e), { localeMessages: t } = Ct(), { isSmallScreen: C } = bt(), [E, Y] = S(null), [Z, _] = S(!1), g = i(() => {
|
|
86
89
|
L(!0);
|
|
87
|
-
}, []),
|
|
88
|
-
c(""),
|
|
90
|
+
}, []), l = i(() => {
|
|
91
|
+
c(""), I(""), L(!1);
|
|
89
92
|
}, [c]), R = (r) => {
|
|
90
|
-
const a = r.key === "Enter",
|
|
91
|
-
(a ||
|
|
93
|
+
const a = r.key === "Enter", b = r.key === " ";
|
|
94
|
+
(a || b) && l();
|
|
92
95
|
}, w = i(
|
|
93
96
|
(r) => {
|
|
94
|
-
r.key === "Escape" &&
|
|
97
|
+
r.key === "Escape" && u && l();
|
|
95
98
|
},
|
|
96
|
-
[
|
|
97
|
-
),
|
|
99
|
+
[u]
|
|
100
|
+
), M = i(
|
|
98
101
|
(r) => {
|
|
99
|
-
r.shiftKey && r.key === "Enter" ? P() : r.key === "Enter" && e !==
|
|
102
|
+
r.shiftKey && r.key === "Enter" ? P() : r.key === "Enter" && e !== f ? c(f) : r.key === "Enter" && O();
|
|
100
103
|
},
|
|
101
|
-
[
|
|
104
|
+
[f, P, O, c, e]
|
|
102
105
|
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, [e]),
|
|
106
|
-
e &&
|
|
107
|
-
}, [e,
|
|
108
|
-
e && e.trim() !== "" && (
|
|
109
|
-
}, []),
|
|
106
|
+
h(() => {
|
|
107
|
+
I(e);
|
|
108
|
+
}, [e]), h(() => {
|
|
109
|
+
e && y && _(!0);
|
|
110
|
+
}, [e, y]), h(() => {
|
|
111
|
+
e && e.trim() !== "" && (I(e), c(e));
|
|
112
|
+
}, []), h(() => (window.addEventListener("keydown", w), () => {
|
|
110
113
|
window.removeEventListener("keydown", w);
|
|
111
|
-
}), [w]),
|
|
114
|
+
}), [w]), h(() => {
|
|
112
115
|
k && setTimeout(() => {
|
|
113
116
|
k.focus();
|
|
114
117
|
}, 0);
|
|
115
118
|
}, [k]);
|
|
116
|
-
const
|
|
117
|
-
|
|
119
|
+
const tt = i((r) => {
|
|
120
|
+
I(r.target.value);
|
|
118
121
|
}, []), U = i(() => {
|
|
119
|
-
|
|
120
|
-
}, [c]),
|
|
122
|
+
I(""), c("");
|
|
123
|
+
}, [c]), ot = W(() => `${B} / ${K}`, [B, K]), { wholeWords: rt, matchCase: et } = W(() => D, [D]), nt = i(
|
|
121
124
|
(r) => {
|
|
122
|
-
|
|
125
|
+
T((a) => ({ ...a, matchCase: r }));
|
|
123
126
|
},
|
|
124
|
-
[
|
|
125
|
-
),
|
|
127
|
+
[T]
|
|
128
|
+
), it = i(
|
|
126
129
|
(r) => {
|
|
127
|
-
|
|
130
|
+
T((a) => ({ ...a, wholeWords: r }));
|
|
128
131
|
},
|
|
129
|
-
[
|
|
132
|
+
[T]
|
|
130
133
|
);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
const p = W(() => (
|
|
134
|
+
h(() => {
|
|
135
|
+
y && Z && l();
|
|
136
|
+
}, [y, l]);
|
|
137
|
+
const p = W(() => (E == null ? void 0 : E.querySelectorAll('[tabindex]:not([tabindex="-1"])')) || [], [E]), at = i(
|
|
135
138
|
(r) => {
|
|
136
139
|
if (r.key === "Tab") {
|
|
137
140
|
const a = document.activeElement;
|
|
138
|
-
let
|
|
139
|
-
p.forEach((m,
|
|
140
|
-
m === a && (
|
|
141
|
+
let b = 0;
|
|
142
|
+
p.forEach((m, ct) => {
|
|
143
|
+
m === a && (b = ct);
|
|
141
144
|
});
|
|
142
|
-
let N =
|
|
143
|
-
r.shiftKey && (N =
|
|
145
|
+
let N = b + 1;
|
|
146
|
+
r.shiftKey && (N = b - 1);
|
|
144
147
|
const V = p[N];
|
|
145
148
|
if (V)
|
|
146
149
|
V.focus();
|
|
@@ -155,54 +158,54 @@ const yt = () => {
|
|
|
155
158
|
},
|
|
156
159
|
[p]
|
|
157
160
|
);
|
|
158
|
-
return !
|
|
159
|
-
|
|
161
|
+
return !Q || !X ? null : /* @__PURE__ */ o(pt, { children: /* @__PURE__ */ o(
|
|
162
|
+
xt,
|
|
160
163
|
{
|
|
161
|
-
open:
|
|
162
|
-
container:
|
|
164
|
+
open: u,
|
|
165
|
+
container: d,
|
|
163
166
|
side: "bottom",
|
|
164
167
|
align: "start",
|
|
165
168
|
tabIndex: 0,
|
|
166
169
|
avoidCollisions: !1,
|
|
167
|
-
triggerComponent: /* @__PURE__ */ o(
|
|
168
|
-
|
|
170
|
+
triggerComponent: /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchButtonTooltip, children: /* @__PURE__ */ o(
|
|
171
|
+
mt,
|
|
169
172
|
{
|
|
170
|
-
active:
|
|
171
|
-
onClick:
|
|
173
|
+
active: u,
|
|
174
|
+
onClick: g,
|
|
172
175
|
"aria-label": t == null ? void 0 : t.searchButtonTooltip,
|
|
173
|
-
"aria-expanded":
|
|
176
|
+
"aria-expanded": u,
|
|
174
177
|
"aria-haspopup": "dialog",
|
|
175
|
-
children:
|
|
178
|
+
children: s || /* @__PURE__ */ o(yt, {})
|
|
176
179
|
}
|
|
177
180
|
) }),
|
|
178
|
-
children: /* @__PURE__ */
|
|
181
|
+
children: /* @__PURE__ */ x(
|
|
179
182
|
"div",
|
|
180
183
|
{
|
|
181
|
-
ref:
|
|
184
|
+
ref: Y,
|
|
182
185
|
className: n["rp-search-tool-content"],
|
|
183
186
|
tabIndex: 0,
|
|
184
|
-
onKeyDown:
|
|
187
|
+
onKeyDown: at,
|
|
185
188
|
role: "dialog",
|
|
186
189
|
"aria-label": (t == null ? void 0 : t.searchInputTooltip) || "Search dialog",
|
|
187
190
|
children: [
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
/* @__PURE__ */ o(
|
|
191
|
-
|
|
191
|
+
/* @__PURE__ */ x("div", { className: n["rp-search-tool-input-wrapper"], children: [
|
|
192
|
+
/* @__PURE__ */ x("div", { className: n["rp-search-tool-input"], children: [
|
|
193
|
+
/* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchInputTooltip, children: /* @__PURE__ */ o(
|
|
194
|
+
lt,
|
|
192
195
|
{
|
|
193
|
-
value:
|
|
194
|
-
onKeyDown:
|
|
195
|
-
onChange:
|
|
196
|
+
value: f,
|
|
197
|
+
onKeyDown: M,
|
|
198
|
+
onChange: tt,
|
|
196
199
|
icon: /* @__PURE__ */ o(A, {}),
|
|
197
200
|
placeholder: t == null ? void 0 : t.searchInputPlaceholder,
|
|
198
201
|
className: n["rp-search-input"],
|
|
199
|
-
ref:
|
|
202
|
+
ref: G,
|
|
200
203
|
id: "search-input",
|
|
201
204
|
name: "search-input",
|
|
202
205
|
tabIndex: 0,
|
|
203
206
|
"aria-label": (t == null ? void 0 : t.searchInputTooltip) || (t == null ? void 0 : t.searchInputPlaceholder),
|
|
204
207
|
"aria-describedby": "search-results-count",
|
|
205
|
-
children: !!
|
|
208
|
+
children: !!f && /* @__PURE__ */ o(
|
|
206
209
|
"span",
|
|
207
210
|
{
|
|
208
211
|
className: n["rp-search-tool-input-clear"],
|
|
@@ -213,45 +216,45 @@ const yt = () => {
|
|
|
213
216
|
onKeyDown: (r) => {
|
|
214
217
|
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), U());
|
|
215
218
|
},
|
|
216
|
-
children: /* @__PURE__ */ o(
|
|
219
|
+
children: /* @__PURE__ */ o(Tt, {})
|
|
217
220
|
}
|
|
218
221
|
)
|
|
219
222
|
}
|
|
220
223
|
) }),
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
J ? /* @__PURE__ */ o("span", { "aria-live": "polite", "aria-label": "Searching", children: /* @__PURE__ */ o(dt, { className: n["rp-search-loader-icon"], "aria-hidden": "true" }) }) : /* @__PURE__ */ o("span", { id: "search-results-count", "aria-live": "polite", children: ot }),
|
|
225
|
+
C && /* @__PURE__ */ o("div", { className: n["rp-search-tool-controls"], children: /* @__PURE__ */ o(z, { onKeyPress: R, handleClose: l }) })
|
|
223
226
|
] }),
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
|
|
227
|
+
/* @__PURE__ */ x("div", { className: n["rp-search-tool-input-checkboxes"], children: [
|
|
228
|
+
C && /* @__PURE__ */ o(q, {}),
|
|
226
229
|
/* @__PURE__ */ o(
|
|
227
230
|
$,
|
|
228
231
|
{
|
|
229
232
|
tabIndex: 0,
|
|
230
233
|
name: "matchCase",
|
|
231
|
-
value:
|
|
232
|
-
onChange:
|
|
234
|
+
value: et,
|
|
235
|
+
onChange: nt,
|
|
233
236
|
"aria-label": t == null ? void 0 : t.searchMatchCaseLabel,
|
|
234
237
|
children: t == null ? void 0 : t.searchMatchCaseLabel
|
|
235
238
|
}
|
|
236
239
|
),
|
|
237
|
-
!
|
|
240
|
+
!C && /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchMatchCaseTooltip, children: /* @__PURE__ */ o("div", { className: n["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ o(j, {}) }) }),
|
|
238
241
|
/* @__PURE__ */ o(
|
|
239
242
|
$,
|
|
240
243
|
{
|
|
241
244
|
tabIndex: 0,
|
|
242
245
|
name: "wholeWord",
|
|
243
|
-
value:
|
|
244
|
-
onChange:
|
|
246
|
+
value: rt,
|
|
247
|
+
onChange: it,
|
|
245
248
|
"aria-label": t == null ? void 0 : t.searchWholeWordsLabel,
|
|
246
249
|
children: t == null ? void 0 : t.searchWholeWordsLabel
|
|
247
250
|
}
|
|
248
251
|
),
|
|
249
|
-
!
|
|
252
|
+
!C && /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchWholeWordsTooltip, children: /* @__PURE__ */ o("div", { tabIndex: 0, className: n["rp-search-icon-info"], children: /* @__PURE__ */ o(j, {}) }) })
|
|
250
253
|
] })
|
|
251
254
|
] }),
|
|
252
|
-
!
|
|
255
|
+
!C && /* @__PURE__ */ x("div", { className: n["rp-search-tool-controls"], children: [
|
|
253
256
|
/* @__PURE__ */ o(q, {}),
|
|
254
|
-
/* @__PURE__ */ o(z, { onKeyPress: R, handleClose:
|
|
257
|
+
/* @__PURE__ */ o(z, { onKeyPress: R, handleClose: l })
|
|
255
258
|
] })
|
|
256
259
|
]
|
|
257
260
|
}
|
|
@@ -260,5 +263,5 @@ const yt = () => {
|
|
|
260
263
|
) });
|
|
261
264
|
};
|
|
262
265
|
export {
|
|
263
|
-
|
|
266
|
+
qo as SearchTool
|
|
264
267
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const t =
|
|
4
|
-
instanceId: ""
|
|
5
|
-
}), x = ({
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as n, useContext as i } from "react";
|
|
3
|
+
const t = n({}), x = ({
|
|
6
4
|
children: e,
|
|
7
|
-
...
|
|
8
|
-
}) => /* @__PURE__ */
|
|
5
|
+
...o
|
|
6
|
+
}) => /* @__PURE__ */ r(t.Provider, { value: o, children: e }), u = () => i(t);
|
|
9
7
|
export {
|
|
10
8
|
t as InitialStateContext,
|
|
11
9
|
x as InitialStateProvider,
|
|
12
|
-
|
|
10
|
+
u as useInitialStateContext
|
|
13
11
|
};
|
|
@@ -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
|
}
|