@react-pdf-kit/viewer 0.0.0-experimental.4 → 0.0.0-experimental.5
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/{Combination-479e39c6.js → Combination-136ff99c.js} +184 -187
- package/dist/RPLayout.module-b4b23e29.js +14 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +15 -15
- package/dist/components/RPConfig.js +16 -6
- package/dist/components/RPController.js +21 -26
- package/dist/components/RPDropFileZone.js +35 -29
- package/dist/components/RPPages.js +351 -360
- package/dist/components/RPProvider.js +20 -24
- package/dist/components/layout/LayoutContainer.js +1 -1
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +12 -13
- package/dist/components/layout/RPLayout.js +28 -28
- package/dist/components/layout/WrapperLayout.js +10 -11
- package/dist/components/layout/sidebar/RPSidebar.js +7 -8
- package/dist/components/layout/sidebar/Thumbnail.js +3 -4
- package/dist/components/layout/sidebar/Thumbnails.js +3 -4
- package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +8 -9
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +9 -10
- package/dist/components/layout/toolbar/FileUploadTool.js +9 -10
- 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 +9 -10
- package/dist/components/layout/toolbar/OtherTool.js +9 -10
- package/dist/components/layout/toolbar/Paginate.js +7 -8
- package/dist/components/layout/toolbar/PrintTool.js +9 -10
- package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
- package/dist/components/layout/toolbar/RPMoreOptions.js +9 -10
- package/dist/components/layout/toolbar/RPToolbar.js +9 -12
- package/dist/components/layout/toolbar/RPToolbarEnd.js +9 -10
- package/dist/components/layout/toolbar/RotateTool.js +9 -10
- 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 +7 -10
- package/dist/components/layout/toolbar/SearchTool.js +11 -14
- package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/ThumbnailTool.js +7 -8
- package/dist/components/layout/toolbar/ToolbarCustom.js +3 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +9 -12
- package/dist/components/layout/toolbar/ToolbarLayout.js +9 -12
- package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
- package/dist/components/layout/toolbar/ZoomTool.js +9 -10
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +8 -9
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +13 -15
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +7 -8
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +7 -8
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +13 -15
- 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 +7 -8
- package/dist/components/layout/toolbar/tools/LastPageTool.js +13 -15
- package/dist/components/layout/toolbar/tools/NextPageTool.js +7 -8
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +7 -8
- package/dist/components/layout/toolbar/tools/PrintTool.js +7 -8
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +7 -8
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +7 -8
- 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 +7 -8
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +7 -8
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +19 -20
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +7 -8
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +9 -12
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +7 -8
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +9 -10
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +9 -10
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +9 -10
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +9 -10
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +9 -10
- 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/page/AnnotationLayer.js +65 -66
- package/dist/components/page/CanvasLayer.js +3 -4
- package/dist/components/page/CustomElement.js +3 -4
- package/dist/components/page/DualPage.js +5 -11
- package/dist/components/page/DualPageWithCover.js +5 -11
- package/dist/components/page/RPPage.js +6 -12
- package/dist/components/page/SinglePage.js +5 -11
- package/dist/components/page/TextHighlightLayer.js +178 -86
- package/dist/components/page/TextLayer.js +170 -125
- package/dist/components/ui/Checkbox.js +2 -2
- package/dist/components/ui/DropDown.js +6 -6
- package/dist/components/ui/LoadingIndicator.js +7 -8
- package/dist/components/ui/RPTooltip.js +411 -197
- package/dist/contexts/ConfigContext.js +5 -4
- package/dist/contexts/DimensionPagesContext.js +5 -6
- package/dist/contexts/DropFileZoneContext.js +4 -5
- package/dist/contexts/ElementPageContext.js +5 -6
- package/dist/contexts/FileInputContext.js +5 -6
- package/dist/contexts/HighlightContext.js +7 -10
- package/dist/contexts/LayoutDropFileZoneContext.js +11 -0
- package/dist/contexts/PagesRotateContext.js +5 -6
- package/dist/contexts/PaginationContext.js +5 -6
- package/dist/contexts/PrintContext.js +16 -17
- package/dist/contexts/RPDocumentContext.js +13 -14
- package/dist/contexts/RenderQueueProvider.js +5 -6
- package/dist/contexts/RotationContext.js +8 -9
- package/dist/contexts/SearchContext.js +5 -8
- package/dist/contexts/ThumbnailsContext.js +4 -5
- package/dist/contexts/ZoomContext.js +5 -6
- 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 +15 -15
- package/dist/polyfills.js +8055 -0
- package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
- package/dist/types/contexts/LayoutDropFileZoneContext.d.ts +9 -0
- package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
- package/dist/types/contexts/RenderQueueProvider.d.ts +1 -1
- package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
- package/dist/types/main.d.ts +1 -1
- package/dist/types/utils/annotations.d.ts +2 -2
- package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
- package/dist/types/utils/highlight.d.ts +5 -5
- package/dist/types/utils/hooks/useDropFileZone.d.ts +5 -0
- package/dist/types/utils/hooks/useFlickerSelectText.d.ts +1 -0
- package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadWorker.d.ts +1 -5
- package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
- package/dist/types/utils/hooks/useTextSelection.d.ts +3 -12
- package/dist/types/utils/link_service.d.ts +3 -2
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +8 -5
- package/dist/utils/highlight.js +158 -184
- package/dist/utils/hooks/useCopyText.js +22 -60
- package/dist/utils/hooks/useDropFileZone.js +12 -0
- package/dist/utils/hooks/useFileDownload.js +5 -6
- package/dist/utils/hooks/useFlickerSelectText.js +25 -0
- package/dist/utils/hooks/useHighlight.js +33 -35
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +70 -95
- package/dist/utils/hooks/useLoadWorker.js +14 -4
- package/dist/utils/hooks/usePageRotateContext.js +7 -8
- package/dist/utils/hooks/usePaginate.js +3 -4
- package/dist/utils/hooks/usePinch.js +10 -11
- package/dist/utils/hooks/usePresentPage.js +3 -4
- package/dist/utils/hooks/usePrint.js +55 -54
- package/dist/utils/hooks/useRotate.js +3 -4
- package/dist/utils/hooks/useScrollToPage.js +3 -4
- package/dist/utils/hooks/useSearch.js +15 -18
- package/dist/utils/hooks/useTextSelection.js +73 -2
- package/dist/utils/hooks/useThumbnail.js +17 -18
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
- package/dist/utils/link_service.js +19 -18
- package/dist/utils/renderPage.js +1 -1
- package/package.json +13 -4
- package/dist/RPLayout.module-7766e0b4.js +0 -14
- package/dist/contexts/TextSelectionContext.js +0 -191
- package/dist/index-535ad364.js +0 -983
- package/dist/index-d0f0aa9a.js +0 -1542
- package/dist/types/contexts/TextSelectionContext.d.ts +0 -14
- package/dist/types/utils/geometryCache.d.ts +0 -15
- package/dist/types/utils/glyphHitTest.d.ts +0 -12
- package/dist/types/utils/selectionUtils.d.ts +0 -30
- package/dist/utils/geometryCache.js +0 -32
- package/dist/utils/glyphHitTest.js +0 -29
- package/dist/utils/selectionUtils.js +0 -96
package/dist/utils/highlight.js
CHANGED
|
@@ -1,247 +1,221 @@
|
|
|
1
|
-
import { getCharacterType as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const c = X(d, s, i);
|
|
8
|
-
t.push(..._(c, d, a));
|
|
1
|
+
import { getCharacterType as D } from "./charators.js";
|
|
2
|
+
function _(l, c, m, i) {
|
|
3
|
+
const s = [];
|
|
4
|
+
for (const n of l) {
|
|
5
|
+
const o = y(c, n, i);
|
|
6
|
+
s.push(...R(o, c, m));
|
|
9
7
|
}
|
|
10
|
-
return
|
|
8
|
+
return s;
|
|
11
9
|
}
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
return new RegExp(
|
|
10
|
+
const L = (l, c) => {
|
|
11
|
+
const m = ["g"];
|
|
12
|
+
c.matchCase || m.push("i");
|
|
13
|
+
let s = l.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
|
+
return new RegExp(s, m.join(""));
|
|
17
15
|
};
|
|
18
|
-
function
|
|
16
|
+
function y(l, c, m) {
|
|
19
17
|
const i = [];
|
|
20
|
-
for (const
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
i.push(
|
|
18
|
+
for (const t of l.items)
|
|
19
|
+
if (t.hasEOL)
|
|
20
|
+
if (t.str.endsWith("-")) {
|
|
21
|
+
const d = t.str.lastIndexOf("-");
|
|
22
|
+
i.push(t.str.substring(0, d));
|
|
25
23
|
} else
|
|
26
|
-
i.push(
|
|
24
|
+
i.push(t.str, `
|
|
27
25
|
`);
|
|
28
26
|
else
|
|
29
|
-
i.push(
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
const
|
|
27
|
+
i.push(t.str);
|
|
28
|
+
const s = i.join("").replace(/\n/g, " ");
|
|
29
|
+
let n;
|
|
30
|
+
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = L(c, m);
|
|
31
|
+
const o = [];
|
|
34
32
|
let e;
|
|
35
|
-
for (; (e =
|
|
36
|
-
|
|
37
|
-
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;
|
|
38
36
|
}
|
|
39
|
-
function
|
|
40
|
-
function i(
|
|
41
|
-
return
|
|
37
|
+
function R(l, c, m) {
|
|
38
|
+
function i(d) {
|
|
39
|
+
return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
|
|
42
40
|
}
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
for (let
|
|
46
|
-
let
|
|
47
|
-
for (;
|
|
48
|
-
const x =
|
|
49
|
-
|
|
41
|
+
let s = 0, n = 0;
|
|
42
|
+
const o = c.items, e = o.length - 1, t = [];
|
|
43
|
+
for (let d = 0; d < l.length; d++) {
|
|
44
|
+
let h = l[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++;
|
|
50
48
|
}
|
|
51
|
-
const
|
|
52
|
-
idx:
|
|
53
|
-
offset:
|
|
49
|
+
const g = {
|
|
50
|
+
idx: s,
|
|
51
|
+
offset: h - n
|
|
54
52
|
};
|
|
55
|
-
for (
|
|
56
|
-
const x =
|
|
57
|
-
|
|
53
|
+
for (h += l[d][1]; s !== e && h > n + o[s].str.length; ) {
|
|
54
|
+
const x = o[s];
|
|
55
|
+
n += x.str.length + i(x), s++;
|
|
58
56
|
}
|
|
59
|
-
const
|
|
60
|
-
idx:
|
|
61
|
-
offset:
|
|
57
|
+
const r = {
|
|
58
|
+
idx: s,
|
|
59
|
+
offset: h - n
|
|
62
60
|
};
|
|
63
|
-
|
|
64
|
-
start:
|
|
65
|
-
end:
|
|
66
|
-
str:
|
|
67
|
-
oIndex:
|
|
68
|
-
pageIndex:
|
|
61
|
+
t.push({
|
|
62
|
+
start: g,
|
|
63
|
+
end: r,
|
|
64
|
+
str: l[d][2],
|
|
65
|
+
oIndex: l[d][0],
|
|
66
|
+
pageIndex: m,
|
|
69
67
|
rect: { left: 0, bottom: 0, width: 0, height: 0 },
|
|
70
68
|
rects: []
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
bottom: h.y + h.height,
|
|
84
|
-
width: h.width,
|
|
85
|
-
height: h.height
|
|
86
|
-
});
|
|
87
|
-
}
|
|
71
|
+
for (const d of t) {
|
|
72
|
+
const h = [];
|
|
73
|
+
for (let g = d.start.idx; g <= d.end.idx; g++) {
|
|
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
|
+
left: f,
|
|
77
|
+
bottom: b,
|
|
78
|
+
width: E,
|
|
79
|
+
height: r.height
|
|
80
|
+
});
|
|
88
81
|
}
|
|
89
|
-
|
|
90
|
-
for (let u = o.start.idx; u <= o.end.idx; u++) {
|
|
91
|
-
const g = c[u], x = g.transform[4], h = g.transform[5], v = g.str.length > 0 ? g.width / g.str.length : 0, b = u === o.start.idx ? o.start.offset : 0, p = u === o.end.idx ? o.end.offset : g.str.length, E = x + b * v, f = (p - b) * v, m = (d.styles ?? {})[g.fontName], M = (m == null ? void 0 : m.ascent) ?? 1, C = (m == null ? void 0 : m.descent) != null ? Math.abs(m.descent) : 1 - M, w = h - C * g.height;
|
|
92
|
-
g.height > 0 && g.width > 0 && l.push({
|
|
93
|
-
left: E,
|
|
94
|
-
bottom: w,
|
|
95
|
-
width: f,
|
|
96
|
-
height: g.height
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
o.rect = l[0] ?? { left: 0, bottom: 0, width: 0, height: 0 }, o.rects = l;
|
|
82
|
+
d.rect = h[0], d.rects = h;
|
|
100
83
|
}
|
|
101
|
-
return
|
|
84
|
+
return t;
|
|
102
85
|
}
|
|
103
|
-
function
|
|
104
|
-
let i =
|
|
86
|
+
function W(l, c, m) {
|
|
87
|
+
let i = l.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
105
88
|
if (i) {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
89
|
+
const s = l.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
|
+
if (D(s) === D(n))
|
|
108
91
|
return !1;
|
|
109
92
|
}
|
|
110
|
-
if (i =
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
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
|
+
if (D(s) === D(n))
|
|
113
96
|
return !1;
|
|
114
97
|
}
|
|
115
98
|
return !0;
|
|
116
99
|
}
|
|
117
|
-
function
|
|
100
|
+
function I(l, c, m) {
|
|
118
101
|
const i = [];
|
|
119
|
-
function
|
|
120
|
-
const
|
|
121
|
-
let
|
|
122
|
-
if (!
|
|
102
|
+
function s(n, o, e = -1, t = -1, d = "") {
|
|
103
|
+
const h = c.items[n], g = [];
|
|
104
|
+
let r = "", x = "", C = "", a = m[n];
|
|
105
|
+
if (!a)
|
|
123
106
|
return;
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
|
|
107
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
|
+
const f = document.createElement("span");
|
|
109
|
+
a.before(f), f.append(a), m[n] = f, a = f;
|
|
127
110
|
}
|
|
128
|
-
e >= 0 &&
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
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
|
+
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
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
|
+
x = h.str.substring(0, e);
|
|
116
|
+
const f = document.createTextNode(x);
|
|
117
|
+
g.unshift(f);
|
|
135
118
|
} else {
|
|
136
|
-
let
|
|
119
|
+
let f = 0;
|
|
137
120
|
const E = [];
|
|
138
|
-
for (const
|
|
139
|
-
const
|
|
140
|
-
|
|
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(
|
|
141
124
|
document.createTextNode(
|
|
142
|
-
|
|
125
|
+
u.substring(0, e - (f - u.length))
|
|
143
126
|
)
|
|
144
127
|
);
|
|
145
128
|
}
|
|
146
|
-
|
|
129
|
+
g.unshift(...E);
|
|
147
130
|
}
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
131
|
+
if (t > 0) {
|
|
132
|
+
C = h.str.substring(t);
|
|
133
|
+
const f = document.createTextNode(C);
|
|
134
|
+
g.push(f);
|
|
152
135
|
}
|
|
153
|
-
|
|
136
|
+
a.replaceChildren(...g);
|
|
154
137
|
}
|
|
155
|
-
for (const [
|
|
156
|
-
if (
|
|
157
|
-
|
|
138
|
+
for (const [n, o] of l.entries())
|
|
139
|
+
if (o.start.idx === o.end.idx)
|
|
140
|
+
s(o.start.idx, n, o.start.offset, o.end.offset);
|
|
158
141
|
else
|
|
159
|
-
for (let e =
|
|
160
|
-
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");
|
|
161
144
|
return i;
|
|
162
145
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
for (let i = 0; i <
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
|
|
146
|
+
function V(l, c) {
|
|
147
|
+
const m = l.items.map((i) => i.str);
|
|
148
|
+
for (let i = 0; i < c.length; i++) {
|
|
149
|
+
const s = c[i];
|
|
150
|
+
if (s && s.nodeType !== Node.TEXT_NODE) {
|
|
151
|
+
const n = document.createTextNode(m[i]);
|
|
152
|
+
s.replaceChildren(n);
|
|
170
153
|
}
|
|
171
154
|
}
|
|
172
155
|
}
|
|
173
|
-
function
|
|
174
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function H(l = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...l };
|
|
175
158
|
}
|
|
176
|
-
function
|
|
159
|
+
function S(l, c, m) {
|
|
177
160
|
const i = [];
|
|
178
|
-
function
|
|
179
|
-
var
|
|
180
|
-
const
|
|
181
|
-
let
|
|
182
|
-
if (!
|
|
161
|
+
function s(n, o, e = -1, t = -1, d) {
|
|
162
|
+
var f, E;
|
|
163
|
+
const h = c.items[n], g = [];
|
|
164
|
+
let r = "", x = "", C = "", a = m[n];
|
|
165
|
+
if (!a)
|
|
183
166
|
return;
|
|
184
|
-
e >= 0 &&
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
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
|
+
if (N.style.background = d, N.append(M), g.push(N), e > 0)
|
|
170
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
|
+
x = h.str.substring(0, e);
|
|
172
|
+
const p = document.createTextNode(x);
|
|
173
|
+
g.unshift(p);
|
|
191
174
|
} else {
|
|
192
|
-
let
|
|
193
|
-
const
|
|
194
|
-
for (const
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
else if (e >=
|
|
199
|
-
const w =
|
|
200
|
-
|
|
175
|
+
let p = 0;
|
|
176
|
+
const u = [];
|
|
177
|
+
for (const T of a.childNodes) {
|
|
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));
|
|
201
184
|
}
|
|
202
185
|
}
|
|
203
|
-
|
|
186
|
+
g.unshift(...u);
|
|
204
187
|
}
|
|
205
|
-
if (
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
188
|
+
if (t > 0)
|
|
189
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
190
|
+
C = h.str.substring(t);
|
|
191
|
+
const p = document.createTextNode(C);
|
|
192
|
+
g.push(p);
|
|
210
193
|
} else {
|
|
211
|
-
let
|
|
212
|
-
const
|
|
213
|
-
for (const
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
const w =
|
|
218
|
-
w &&
|
|
194
|
+
let p = 0;
|
|
195
|
+
const u = [];
|
|
196
|
+
for (const T of a.childNodes) {
|
|
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));
|
|
219
202
|
}
|
|
220
203
|
}
|
|
221
|
-
|
|
204
|
+
u.length > 0 && g.push(...u);
|
|
222
205
|
}
|
|
223
|
-
|
|
206
|
+
a.replaceChildren(...g), i.push({ element: N, index: o });
|
|
224
207
|
}
|
|
225
|
-
for (const [
|
|
226
|
-
const { start: e, end:
|
|
227
|
-
e.idx ===
|
|
208
|
+
for (const [n, o] of l.entries()) {
|
|
209
|
+
const { start: e, end: t, color: d } = o;
|
|
210
|
+
e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
|
|
228
211
|
}
|
|
229
212
|
return i;
|
|
230
213
|
}
|
|
231
|
-
function D(r, d, a) {
|
|
232
|
-
let i = 0;
|
|
233
|
-
for (let t = 0; t < r.runs.length; t++) {
|
|
234
|
-
if (t === d)
|
|
235
|
-
return i + Math.min(a, r.runs[t].glyphs.length - 1);
|
|
236
|
-
i += r.runs[t].glyphs.length;
|
|
237
|
-
}
|
|
238
|
-
return Math.max(0, i - 1);
|
|
239
|
-
}
|
|
240
214
|
export {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
215
|
+
_ as findMatches,
|
|
216
|
+
H as getHighlightOptionsWithDefaults,
|
|
217
|
+
I as highlightMatches,
|
|
218
|
+
S as highlightMultipleColorMatches,
|
|
219
|
+
W as isMatchEntireWord,
|
|
220
|
+
V as resetDivs
|
|
247
221
|
};
|
|
@@ -1,74 +1,36 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../geometryCache.js";
|
|
7
|
-
import "../../contexts/EventCallbackContext.js";
|
|
8
|
-
import "../../contexts/ZoomContext.js";
|
|
9
|
-
import "../types.js";
|
|
10
|
-
import "../../de_DE-a553b162.js";
|
|
11
|
-
import "../appConsole.js";
|
|
12
|
-
import "../../contexts/InitialStateContext.js";
|
|
13
|
-
import "../../contexts/RPDocumentContext.js";
|
|
14
|
-
import "./useLoadPdf.js";
|
|
15
|
-
import "@pdf-viewer/pdfium";
|
|
16
|
-
import "@pdf-viewer/pdfium/compat";
|
|
17
|
-
import "../getThumbnailViewport.js";
|
|
18
|
-
import "../../contexts/ConfigContext.js";
|
|
19
|
-
import "../../contexts/DocumentPasswordContext.js";
|
|
20
|
-
import "./usePdfProperties.js";
|
|
21
|
-
import "../convertPdfDate.js";
|
|
22
|
-
import "../formatFileSize.js";
|
|
23
|
-
import "../constants.js";
|
|
24
|
-
import "../getZoomLevel.js";
|
|
25
|
-
import "../../contexts/LayoutContainerContext.js";
|
|
26
|
-
import "../../contexts/ViewModeContext.js";
|
|
27
|
-
import "../../contexts/RotationContext.js";
|
|
28
|
-
import "../../contexts/GlobalCurrentPage.js";
|
|
29
|
-
import "./useDebounce.js";
|
|
30
|
-
const g = /[\x00-\x1F]/g;
|
|
31
|
-
let c = null, o = null;
|
|
32
|
-
function C(t) {
|
|
33
|
-
return c || (c = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu, o = /* @__PURE__ */ new Map([["ſt", "ſt"]])), t.replace(
|
|
1
|
+
import { useRef as o, useEffect as i } from "react";
|
|
2
|
+
const s = /[\x00-\x1F]/g;
|
|
3
|
+
let c = null, r = null;
|
|
4
|
+
function d(e) {
|
|
5
|
+
return c || (c = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu, r = /* @__PURE__ */ new Map([["ſt", "ſt"]])), e.replace(
|
|
34
6
|
c,
|
|
35
|
-
(
|
|
7
|
+
(f, u, t) => u ? u.normalize("NFKC") : (r == null ? void 0 : r.get(t)) || ""
|
|
36
8
|
);
|
|
37
9
|
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
10
|
+
function p(e, f = !1) {
|
|
11
|
+
return s.test(e) ? f ? e.replace(s, (u) => u === "\0" ? "" : " ") : e.replace(/\x00/g, "") : e;
|
|
40
12
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
f.current
|
|
45
|
-
}, [e, r]), x(() => {
|
|
46
|
-
if (!t || i.current)
|
|
13
|
+
const x = (e) => {
|
|
14
|
+
const f = o(!1), u = o(null);
|
|
15
|
+
i(() => {
|
|
16
|
+
if (!e || f.current)
|
|
47
17
|
return;
|
|
48
|
-
const
|
|
49
|
-
var
|
|
50
|
-
const m = f.current;
|
|
51
|
-
if (m) {
|
|
52
|
-
(s = u.clipboardData) == null || s.setData(
|
|
53
|
-
"text/plain",
|
|
54
|
-
D(C(m))
|
|
55
|
-
), u.preventDefault(), u.stopPropagation();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
18
|
+
const t = (n) => {
|
|
19
|
+
var l;
|
|
58
20
|
const b = document.getSelection();
|
|
59
21
|
if (!b)
|
|
60
22
|
return;
|
|
61
|
-
const
|
|
62
|
-
|
|
23
|
+
const a = b.toString();
|
|
24
|
+
a && ((l = n.clipboardData) == null || l.setData(
|
|
63
25
|
"text/plain",
|
|
64
|
-
|
|
65
|
-
),
|
|
26
|
+
p(d(a))
|
|
27
|
+
), n.preventDefault(), n.stopPropagation());
|
|
66
28
|
};
|
|
67
|
-
return
|
|
68
|
-
|
|
29
|
+
return e.addEventListener("copy", t), u.current = e, f.current = !0, () => {
|
|
30
|
+
u.current && (u.current.removeEventListener("copy", t), f.current = !1);
|
|
69
31
|
};
|
|
70
|
-
}, [
|
|
32
|
+
}, [e]);
|
|
71
33
|
};
|
|
72
34
|
export {
|
|
73
|
-
|
|
35
|
+
x as useCopyText
|
|
74
36
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useLayoutDropFileZoneContext as r } from "../../contexts/LayoutDropFileZoneContext.js";
|
|
2
|
+
import { useToolComponentContext as n } from "../../contexts/ToolComponentContext.js";
|
|
3
|
+
import { useToolbarComponentContext as p } from "../../contexts/ToolbarComponentContext.js";
|
|
4
|
+
import "react/jsx-runtime";
|
|
5
|
+
import "react";
|
|
6
|
+
const F = () => {
|
|
7
|
+
const o = r(), { dropFileZone: e } = n(), { dropFileZone: t } = p();
|
|
8
|
+
return { DropFileZoneLayout: o, DropFileZoneTool: e, DropFileZoneToolbar: t };
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
F as useDropFileZone
|
|
12
|
+
};
|
|
@@ -3,8 +3,7 @@ import { useCallback as a } from "react";
|
|
|
3
3
|
import { useDownloadContext as s } from "../../contexts/DownloadContext.js";
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "./useLoadPdf.js";
|
|
6
|
-
import "
|
|
7
|
-
import "@pdf-viewer/pdfium/compat";
|
|
6
|
+
import "pdfjs-dist";
|
|
8
7
|
import "../types.js";
|
|
9
8
|
import "../../de_DE-a553b162.js";
|
|
10
9
|
import "../getThumbnailViewport.js";
|
|
@@ -14,10 +13,10 @@ import "../appConsole.js";
|
|
|
14
13
|
import "./usePdfProperties.js";
|
|
15
14
|
import "../convertPdfDate.js";
|
|
16
15
|
import "../formatFileSize.js";
|
|
17
|
-
const i = ".pdf", d = (o) => URL.createObjectURL(o),
|
|
16
|
+
const i = ".pdf", d = (o) => URL.createObjectURL(o), l = async (o) => {
|
|
18
17
|
const r = await (await fetch(o)).blob();
|
|
19
18
|
return d(r);
|
|
20
|
-
},
|
|
19
|
+
}, k = () => {
|
|
21
20
|
const { filename: o, pdfSrc: e } = c(), { downloadFilename: r } = s(), m = (t) => {
|
|
22
21
|
const n = r || t;
|
|
23
22
|
return n.endsWith(i) ? n : `${n}${i}`;
|
|
@@ -26,9 +25,9 @@ const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
|
|
|
26
25
|
if (!o || !e)
|
|
27
26
|
throw new Error("There is no PDF source to download");
|
|
28
27
|
const t = document.createElement("a");
|
|
29
|
-
t.href = await
|
|
28
|
+
t.href = await l(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
30
29
|
}, [o, e]) };
|
|
31
30
|
};
|
|
32
31
|
export {
|
|
33
|
-
|
|
32
|
+
k as useFileDownload
|
|
34
33
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useRef as u, useCallback as g, useEffect as f } from "react";
|
|
2
|
+
const m = () => {
|
|
3
|
+
const i = u(null), a = u(/firefox/i.test(navigator.userAgent)), o = g(() => {
|
|
4
|
+
var c, d;
|
|
5
|
+
const s = document.getSelection();
|
|
6
|
+
if (!s || s.rangeCount === 0 || a.current)
|
|
7
|
+
return;
|
|
8
|
+
const t = s.getRangeAt(0), l = i.current && (t.compareBoundaryPoints(Range.END_TO_END, i.current) === 0 || t.compareBoundaryPoints(Range.START_TO_END, i.current) === 0);
|
|
9
|
+
let e = l ? t.startContainer : t.endContainer;
|
|
10
|
+
if ((e == null ? void 0 : e.nodeType) === Node.TEXT_NODE && (e = e.parentNode), !l && t.endOffset === 0)
|
|
11
|
+
do {
|
|
12
|
+
for (; !(e != null && e.previousSibling); )
|
|
13
|
+
e = e == null ? void 0 : e.parentNode;
|
|
14
|
+
e = e.previousSibling;
|
|
15
|
+
} while (!e.childNodes.length);
|
|
16
|
+
const n = (c = e == null ? void 0 : e.parentElement) == null ? void 0 : c.closest("[data-rp-text-layer]"), r = n == null ? void 0 : n.querySelector(".endOfContent");
|
|
17
|
+
r && (r.style.width = n.style.width, r.style.height = n.style.height, (d = e == null ? void 0 : e.parentElement) == null || d.insertBefore(r, l ? e : e.nextSibling)), i.current = t.cloneRange();
|
|
18
|
+
}, []);
|
|
19
|
+
f(() => (document == null || document.addEventListener("selectionchange", o), () => {
|
|
20
|
+
document == null || document.removeEventListener("selectionchange", o);
|
|
21
|
+
}), [o]);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
m as useFlickerSelectText
|
|
25
|
+
};
|