@react-pdf-kit/viewer 0.0.0-experimental.2 → 0.0.0-experimental.4
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-17ab8af1.js → Combination-479e39c6.js} +187 -184
- package/dist/RPLayout.module-7766e0b4.js +14 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +15 -15
- package/dist/components/RPController.js +24 -20
- package/dist/components/RPPages.js +322 -321
- package/dist/components/RPProvider.js +22 -19
- package/dist/components/layout/LayoutContainer.js +1 -1
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +7 -5
- package/dist/components/layout/RPLayout.js +7 -5
- package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
- package/dist/components/layout/toolbar/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/MenuItem.js +2 -2
- package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
- package/dist/components/layout/toolbar/MostPageTool.js +2 -2
- package/dist/components/layout/toolbar/OtherTool.js +2 -2
- package/dist/components/layout/toolbar/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
- package/dist/components/layout/toolbar/RPMoreOptions.js +2 -2
- package/dist/components/layout/toolbar/RPToolbar.js +6 -4
- package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
- package/dist/components/layout/toolbar/RotateTool.js +2 -2
- package/dist/components/layout/toolbar/ScrollModeTool.js +2 -2
- package/dist/components/layout/toolbar/SearchResultNavigator.js +4 -2
- package/dist/components/layout/toolbar/SearchTool.js +6 -4
- package/dist/components/layout/toolbar/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/ToolbarDefault.js +6 -4
- package/dist/components/layout/toolbar/ToolbarLayout.js +6 -4
- package/dist/components/layout/toolbar/ViewModeTool.js +2 -2
- package/dist/components/layout/toolbar/ZoomTool.js +2 -2
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +9 -6
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +9 -6
- package/dist/components/layout/toolbar/tools/LastPageTool.js +9 -6
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -4
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
- package/dist/components/page/AnnotationLayer.js +52 -52
- package/dist/components/page/DualPage.js +9 -4
- package/dist/components/page/DualPageWithCover.js +9 -4
- package/dist/components/page/RPPage.js +9 -4
- package/dist/components/page/SinglePage.js +9 -4
- package/dist/components/page/TextHighlightLayer.js +84 -177
- package/dist/components/page/TextLayer.js +124 -170
- package/dist/components/ui/DropDown.js +2 -2
- package/dist/contexts/HighlightContext.js +8 -6
- package/dist/contexts/SearchContext.js +6 -4
- package/dist/contexts/TextSelectionContext.js +191 -0
- package/dist/{index-11f3cd64.js → index-535ad364.js} +1 -1
- package/dist/main.js +116 -114
- package/dist/types/contexts/TextSelectionContext.d.ts +14 -0
- package/dist/types/utils/geometryCache.d.ts +15 -0
- package/dist/types/utils/glyphHitTest.d.ts +12 -0
- package/dist/types/utils/hooks/useTextSelection.d.ts +12 -3
- package/dist/types/utils/selectionUtils.d.ts +30 -0
- package/dist/utils/geometryCache.js +32 -0
- package/dist/utils/glyphHitTest.js +29 -0
- package/dist/utils/highlight.js +184 -158
- package/dist/utils/hooks/useCopyText.js +60 -22
- package/dist/utils/hooks/useHighlight.js +35 -33
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useSearch.js +4 -2
- package/dist/utils/hooks/useTextSelection.js +2 -73
- package/dist/utils/selectionUtils.js +96 -0
- package/package.json +2 -2
- package/dist/RPLayout.module-b4b23e29.js +0 -14
- package/dist/types/utils/hooks/useFlickerSelectText.d.ts +0 -1
- package/dist/utils/hooks/useFlickerSelectText.js +0 -25
package/dist/main.js
CHANGED
|
@@ -1,54 +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
|
|
7
|
-
import { default as
|
|
8
|
-
import { UIButton as
|
|
9
|
-
import { useDarkModeContext as
|
|
10
|
-
import { u as
|
|
11
|
-
import { useDocumentContext as
|
|
12
|
-
import { useRotationContext as
|
|
13
|
-
import { useViewModeContext as
|
|
14
|
-
import { useDropFileZoneContext as
|
|
15
|
-
import { useFileDownload as
|
|
16
|
-
import { useOpenFileContext as
|
|
17
|
-
import { usePrintContext as
|
|
18
|
-
import { useZoomContext as
|
|
19
|
-
import { useSearchContext as
|
|
20
|
-
import { useHighlightContext as
|
|
21
|
-
import { useFullScreenContext as
|
|
22
|
-
import { usePageRotateContext as
|
|
23
|
-
import { useElementPageContext as
|
|
24
|
-
import { SearchTool as
|
|
25
|
-
import { ThemeSwitcherTool as
|
|
26
|
-
import { ThumbnailTool as
|
|
27
|
-
import { FileUploadTool as
|
|
28
|
-
import { FileDownloadTool as
|
|
29
|
-
import { PrintTool as
|
|
30
|
-
import { FullScreenTool as
|
|
31
|
-
import { PreviousPageTool as
|
|
32
|
-
import { NextPageTool as
|
|
33
|
-
import { InputPageTool as
|
|
34
|
-
import { ZoomInTool as
|
|
35
|
-
import { ZoomOutTool as
|
|
36
|
-
import { ZoomLevelTool as
|
|
37
|
-
import { DocumentPropertiesTool as
|
|
38
|
-
import { RotateClockwiseTool as
|
|
39
|
-
import { RotateCounterclockwiseTool as
|
|
40
|
-
import { RPHorizontalBar as
|
|
41
|
-
import { RPVerticalBar as
|
|
42
|
-
import { SelectionModeSwitcherTool as
|
|
43
|
-
import { SinglePageTool as
|
|
44
|
-
import { DualPageTool as
|
|
45
|
-
import { DualPageWithCoverTool as
|
|
46
|
-
import { PageScrollingTool as
|
|
47
|
-
import { VerticalScrollingTool as
|
|
48
|
-
import { HorizontalScrollingTool as
|
|
49
|
-
import { FirstPageTool as
|
|
50
|
-
import { LastPageTool as
|
|
51
|
-
import { Locales as
|
|
1
|
+
import { RPProvider as Dt } from "./components/RPProvider.js";
|
|
2
|
+
import { RPPages as Ft } from "./components/RPPages.js";
|
|
3
|
+
import { RPConfig as Mt } from "./components/RPConfig.js";
|
|
4
|
+
import { RPDefaultLayout as vt } from "./components/layout/RPDefaultLayout.js";
|
|
5
|
+
import { RPLayout as Bt } from "./components/layout/RPLayout.js";
|
|
6
|
+
import { RPTheme as Ht } from "./components/RPTheme.js";
|
|
7
|
+
import { default as bt } from "./components/ui/RPTooltip.js";
|
|
8
|
+
import { UIButton as zt } from "./components/ui/Button.js";
|
|
9
|
+
import { useDarkModeContext as Ut } from "./contexts/DarkModeContext.js";
|
|
10
|
+
import { u as Nt } from "./PaginationContext-9217cab4.js";
|
|
11
|
+
import { useDocumentContext as jt } from "./contexts/RPDocumentContext.js";
|
|
12
|
+
import { useRotationContext as At } from "./contexts/RotationContext.js";
|
|
13
|
+
import { useViewModeContext as Jt } from "./contexts/ViewModeContext.js";
|
|
14
|
+
import { useDropFileZoneContext as Qt } from "./contexts/DropFileZoneContext.js";
|
|
15
|
+
import { useFileDownload as Yt } from "./utils/hooks/useFileDownload.js";
|
|
16
|
+
import { useOpenFileContext as $t } from "./contexts/FileInputContext.js";
|
|
17
|
+
import { usePrintContext as rm } from "./contexts/PrintContext.js";
|
|
18
|
+
import { useZoomContext as mm } from "./contexts/ZoomContext.js";
|
|
19
|
+
import { useSearchContext as im } from "./contexts/SearchContext.js";
|
|
20
|
+
import { useHighlightContext as lm } from "./contexts/HighlightContext.js";
|
|
21
|
+
import { useFullScreenContext as fm } from "./contexts/FullScreenContext.js";
|
|
22
|
+
import { usePageRotateContext as nm } from "./utils/hooks/usePageRotateContext.js";
|
|
23
|
+
import { useElementPageContext as Tm } from "./contexts/ElementPageContext.js";
|
|
24
|
+
import { SearchTool as sm } from "./components/layout/toolbar/SearchTool.js";
|
|
25
|
+
import { ThemeSwitcherTool as gm } from "./components/layout/toolbar/tools/ThemeSwitcherTool.js";
|
|
26
|
+
import { ThumbnailTool as Rm } from "./components/layout/toolbar/tools/ThumbnailTool.js";
|
|
27
|
+
import { FileUploadTool as dm } from "./components/layout/toolbar/tools/FileUploadTool.js";
|
|
28
|
+
import { FileDownloadTool as Dm } from "./components/layout/toolbar/tools/FileDownloadTool.js";
|
|
29
|
+
import { PrintTool as Fm } from "./components/layout/toolbar/tools/PrintTool.js";
|
|
30
|
+
import { FullScreenTool as Mm } from "./components/layout/toolbar/tools/FullScreenTool.js";
|
|
31
|
+
import { PreviousPageTool as vm } from "./components/layout/toolbar/tools/PreviousPageTool.js";
|
|
32
|
+
import { NextPageTool as Bm } from "./components/layout/toolbar/tools/NextPageTool.js";
|
|
33
|
+
import { InputPageTool as Hm } from "./components/layout/toolbar/tools/InputPageTool.js";
|
|
34
|
+
import { ZoomInTool as bm } from "./components/layout/toolbar/tools/ZoomInTool.js";
|
|
35
|
+
import { ZoomOutTool as zm } from "./components/layout/toolbar/tools/ZoomOutTool.js";
|
|
36
|
+
import { ZoomLevelTool as Um } from "./components/layout/toolbar/tools/ZoomLevelTool.js";
|
|
37
|
+
import { DocumentPropertiesTool as Nm } from "./components/layout/toolbar/tools/DocumentPropertiesTool.js";
|
|
38
|
+
import { RotateClockwiseTool as jm } from "./components/layout/toolbar/tools/RotateClockwiseTool.js";
|
|
39
|
+
import { RotateCounterclockwiseTool as Am } from "./components/layout/toolbar/tools/RotateCounterclockwiseTool.js";
|
|
40
|
+
import { RPHorizontalBar as Jm } from "./components/layout/toolbar/tools/defaults/RPHorizontalBar.js";
|
|
41
|
+
import { RPVerticalBar as Qm } from "./components/layout/toolbar/tools/defaults/RPVerticalBar.js";
|
|
42
|
+
import { SelectionModeSwitcherTool as Ym } from "./components/layout/toolbar/tools/SelectionModeSwitcherTool.js";
|
|
43
|
+
import { SinglePageTool as $m } from "./components/layout/toolbar/tools/SinglePageTool.js";
|
|
44
|
+
import { DualPageTool as rp } from "./components/layout/toolbar/tools/DualPageTool.js";
|
|
45
|
+
import { DualPageWithCoverTool as mp } from "./components/layout/toolbar/tools/DualPageWithCoverTool.js";
|
|
46
|
+
import { PageScrollingTool as ip } from "./components/layout/toolbar/tools/PageScrollingTool.js";
|
|
47
|
+
import { VerticalScrollingTool as lp } from "./components/layout/toolbar/tools/VerticalScrollingTool.js";
|
|
48
|
+
import { HorizontalScrollingTool as fp } from "./components/layout/toolbar/tools/HorizontalScrollingTool.js";
|
|
49
|
+
import { FirstPageTool as np } from "./components/layout/toolbar/tools/FirstPageTool.js";
|
|
50
|
+
import { LastPageTool as Tp } from "./components/layout/toolbar/tools/LastPageTool.js";
|
|
51
|
+
import { Locales as sp, ScrollMode as cp, SelectionMode as gp, ThemeVariables as Cp, ViewMode as Rp, ZoomLevel as Sp } from "./utils/types.js";
|
|
52
52
|
import "react/jsx-runtime";
|
|
53
53
|
import "react";
|
|
54
54
|
import "./contexts/DocumentPasswordContext.js";
|
|
@@ -81,21 +81,22 @@ import "./utils/Queue.js";
|
|
|
81
81
|
import "./utils/renderPage.js";
|
|
82
82
|
import "@pdf-viewer/pdfium/compat";
|
|
83
83
|
import "./contexts/GlobalCurrentPage.js";
|
|
84
|
+
import "./contexts/TextSelectionContext.js";
|
|
85
|
+
import "./utils/glyphHitTest.js";
|
|
86
|
+
import "./utils/selectionUtils.js";
|
|
87
|
+
import "./utils/geometryCache.js";
|
|
84
88
|
import "./contexts/LoaderContext.js";
|
|
85
89
|
import "./components/icons/LoaderIcon.js";
|
|
86
90
|
import "./clsx-0c6e471a.js";
|
|
87
91
|
import "./contexts/ToolComponentContext.js";
|
|
88
92
|
import "./contexts/IconToolContext.js";
|
|
89
93
|
import "./contexts/OtherToolContext.js";
|
|
90
|
-
import "./utils/hooks/useFlickerSelectText.js";
|
|
91
94
|
import "./assets/style.js";
|
|
92
95
|
import "./libInjectCss.js";
|
|
93
96
|
import "./utils/injectPrintCSS.js";
|
|
94
97
|
import "./components/page/RPPage.js";
|
|
95
98
|
import "./components/page/CanvasLayer.js";
|
|
96
99
|
import "./components/page/TextLayer.js";
|
|
97
|
-
import "./utils/highlight.js";
|
|
98
|
-
import "./utils/charators.js";
|
|
99
100
|
import "./components/page/AnnotationLayer.js";
|
|
100
101
|
import "./utils/link_service.js";
|
|
101
102
|
import "./utils/annotations.js";
|
|
@@ -104,6 +105,8 @@ import "./utils/dateFormatter.js";
|
|
|
104
105
|
import "./components/page/TextHighlightLayer.js";
|
|
105
106
|
import "./components/page/searchHighlight.js";
|
|
106
107
|
import "./utils/const.js";
|
|
108
|
+
import "./utils/highlight.js";
|
|
109
|
+
import "./utils/charators.js";
|
|
107
110
|
import "./components/page/CustomElement.js";
|
|
108
111
|
import "./utils/withRef.js";
|
|
109
112
|
import "./utils/hooks/useVirtualReactWindow.js";
|
|
@@ -118,11 +121,10 @@ import "./utils/hooks/useDebounce.js";
|
|
|
118
121
|
import "./components/ui/PasswordModal.js";
|
|
119
122
|
import "./utils/hooks/usePresentPage.js";
|
|
120
123
|
import "./components/layout/LayoutContainer.js";
|
|
121
|
-
import "./RPLayout.module-
|
|
124
|
+
import "./RPLayout.module-7766e0b4.js";
|
|
122
125
|
import "./contexts/ThemeContext.js";
|
|
123
126
|
import "./components/layout/LayoutWrapper.js";
|
|
124
127
|
import "./utils/hooks/useCopyText.js";
|
|
125
|
-
import "./utils/hooks/useTextSelection.js";
|
|
126
128
|
import "./utils/approximateFragtion.js";
|
|
127
129
|
import "./contexts/ConfigContext.js";
|
|
128
130
|
import "./components/layout/toolbar/RPToolbar.js";
|
|
@@ -138,11 +140,11 @@ import "./components/layout/toolbar/RPToolbarEnd.js";
|
|
|
138
140
|
import "./components/layout/toolbar/FileUploadTool.js";
|
|
139
141
|
import "./components/icons/FileUploadDefaultIcon.js";
|
|
140
142
|
import "./components/layout/toolbar/MenuItem.js";
|
|
141
|
-
import "./index-
|
|
143
|
+
import "./index-535ad364.js";
|
|
142
144
|
import "./index-113053cf.js";
|
|
143
145
|
import "react-dom";
|
|
144
146
|
import "./index-23911b43.js";
|
|
145
|
-
import "./Combination-
|
|
147
|
+
import "./Combination-479e39c6.js";
|
|
146
148
|
import "./index-d0f0aa9a.js";
|
|
147
149
|
import "./index-ada501c4.js";
|
|
148
150
|
import "./components/layout/toolbar/DarkModeTool.js";
|
|
@@ -230,60 +232,60 @@ import "./components/layout/toolbar/SearchCloseButton.js";
|
|
|
230
232
|
import "./components/icons/ChevronDownIcon.js";
|
|
231
233
|
import "./components/layout/toolbar/ThumbnailTool.js";
|
|
232
234
|
export {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
235
|
+
Nm as DocumentPropertiesTool,
|
|
236
|
+
rp as DualPageTool,
|
|
237
|
+
mp as DualPageWithCoverTool,
|
|
238
|
+
Dm as FileDownloadTool,
|
|
239
|
+
dm as FileUploadTool,
|
|
240
|
+
np as FirstPageTool,
|
|
241
|
+
Mm as FullScreenTool,
|
|
242
|
+
fp as HorizontalScrollingTool,
|
|
243
|
+
Hm as InputPageTool,
|
|
244
|
+
Tp as LastPageTool,
|
|
245
|
+
sp as Locales,
|
|
246
|
+
Bm as NextPageTool,
|
|
247
|
+
ip as PageScrollingTool,
|
|
248
|
+
vm as PreviousPageTool,
|
|
249
|
+
Fm as PrintTool,
|
|
250
|
+
zt as RPButton,
|
|
251
|
+
Mt as RPConfig,
|
|
252
|
+
vt as RPDefaultLayout,
|
|
253
|
+
Jm as RPHorizontalBar,
|
|
254
|
+
Bt as RPLayout,
|
|
255
|
+
Ft as RPPages,
|
|
256
|
+
Dt as RPProvider,
|
|
257
|
+
Ht as RPTheme,
|
|
258
|
+
bt as RPTooltip,
|
|
259
|
+
Qm as RPVerticalBar,
|
|
260
|
+
jm as RotateClockwiseTool,
|
|
261
|
+
Am as RotateCounterclockwiseTool,
|
|
262
|
+
cp as ScrollMode,
|
|
263
|
+
sm as SearchTool,
|
|
264
|
+
gp as SelectionMode,
|
|
265
|
+
Ym as SelectionModeSwitcherTool,
|
|
266
|
+
$m as SinglePageTool,
|
|
267
|
+
gm as ThemeSwitcherTool,
|
|
268
|
+
Cp as ThemeVariables,
|
|
269
|
+
Rm as ThumbnailTool,
|
|
270
|
+
lp as VerticalScrollingTool,
|
|
271
|
+
Rp as ViewMode,
|
|
272
|
+
bm as ZoomInTool,
|
|
273
|
+
Sp as ZoomLevel,
|
|
274
|
+
Um as ZoomLevelTool,
|
|
275
|
+
zm as ZoomOutTool,
|
|
276
|
+
Ut as useDarkModeContext,
|
|
277
|
+
jt as useDocumentContext,
|
|
278
|
+
Qt as useDropFileZoneContext,
|
|
279
|
+
Tm as useElementPageContext,
|
|
280
|
+
Yt as useFileDownload,
|
|
281
|
+
fm as useFullScreenContext,
|
|
282
|
+
lm as useHighlightContext,
|
|
283
|
+
$t as useOpenFileContext,
|
|
284
|
+
nm as usePageRotateContext,
|
|
285
|
+
Nt as usePaginationContext,
|
|
286
|
+
rm as usePrintContext,
|
|
287
|
+
At as useRotationContext,
|
|
288
|
+
im as useSearchContext,
|
|
289
|
+
Jt as useViewModeContext,
|
|
290
|
+
mm as useZoomContext
|
|
289
291
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { HighlightRect } from '../utils/selectionUtils';
|
|
3
|
+
export interface TextSelectionContextType {
|
|
4
|
+
handlePointerDown: (pageIndex: number, e: React.PointerEvent, overlayEl: HTMLElement) => void;
|
|
5
|
+
handlePointerMove: (pageIndex: number, e: React.PointerEvent, overlayEl: HTMLElement) => void;
|
|
6
|
+
handlePointerUp: () => void;
|
|
7
|
+
getPageSelectionRects: (pageIndex: number) => HighlightRect[];
|
|
8
|
+
isSelecting: boolean;
|
|
9
|
+
selectedText: string;
|
|
10
|
+
selectionVersion: number;
|
|
11
|
+
clearSelection: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const useTextSelectionContext: () => TextSelectionContextType;
|
|
14
|
+
export declare const TextSelectionProvider: FC<PropsWithChildren>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PageGeometry } from '@pdf-viewer/pdfium';
|
|
2
|
+
/**
|
|
3
|
+
* LRU cache for PageGeometry objects keyed by page index.
|
|
4
|
+
*/
|
|
5
|
+
export declare class GeometryCache {
|
|
6
|
+
private cache;
|
|
7
|
+
private readonly maxSize;
|
|
8
|
+
constructor(maxSize?: number);
|
|
9
|
+
get(pageIndex: number): PageGeometry | undefined;
|
|
10
|
+
set(pageIndex: number, geometry: PageGeometry): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
get size(): number;
|
|
13
|
+
}
|
|
14
|
+
/** Shared singleton instance */
|
|
15
|
+
export declare const geometryCache: GeometryCache;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PageGeometry } from '@pdf-viewer/pdfium';
|
|
2
|
+
export interface HitResult {
|
|
3
|
+
runIndex: number;
|
|
4
|
+
glyphIndex: number;
|
|
5
|
+
charIndex: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Two-pass glyph hit-testing:
|
|
9
|
+
* 1. Exact match against tight bounds
|
|
10
|
+
* 2. Tolerance-expanded match using Manhattan distance
|
|
11
|
+
*/
|
|
12
|
+
export declare function glyphAt(geometry: PageGeometry, x: number, y: number, tolerance?: number): HitResult | null;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Legacy hook — selection logic has moved to TextSelectionContext.
|
|
3
|
+
*
|
|
4
|
+
* This file is kept so existing call sites compile without changes.
|
|
5
|
+
* The TextSelectionProvider (in contexts/TextSelectionContext.tsx) now
|
|
6
|
+
* manages all pointer-event-based text selection via glyph hit-testing
|
|
7
|
+
* and fires `onTextSelect` through EventCallbackContext.
|
|
8
|
+
*
|
|
9
|
+
* This hook is intentionally a no-op. Remove the call site when convenient.
|
|
10
|
+
*/
|
|
2
11
|
interface UseTextSelectionOptions {
|
|
3
|
-
onTextSelect?: (selection:
|
|
12
|
+
onTextSelect?: ((selection: unknown) => void) | undefined;
|
|
4
13
|
pagesRef: HTMLElement | null;
|
|
5
14
|
}
|
|
6
|
-
export declare const useTextSelection: (
|
|
15
|
+
export declare const useTextSelection: (_options: UseTextSelectionOptions) => void;
|
|
7
16
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PageGeometry } from '@pdf-viewer/pdfium';
|
|
2
|
+
export interface CharRange {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
}
|
|
6
|
+
export interface HighlightRect {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Expand selection to word boundaries.
|
|
14
|
+
* Walk backward/forward from charIndex until hitting a space (flags=1) or empty (flags=2) glyph.
|
|
15
|
+
*/
|
|
16
|
+
export declare function expandToWordBoundary(geometry: PageGeometry, charIndex: number): CharRange;
|
|
17
|
+
/**
|
|
18
|
+
* Expand selection to line boundaries.
|
|
19
|
+
* Find all runs that vertically overlap >= 50% with the run containing charIndex.
|
|
20
|
+
*/
|
|
21
|
+
export declare function expandToLineBoundary(geometry: PageGeometry, charIndex: number): CharRange;
|
|
22
|
+
/**
|
|
23
|
+
* Compute merged highlight rectangles for a character range.
|
|
24
|
+
* Adjacent glyphs on the same visual line are merged into single rectangles.
|
|
25
|
+
*/
|
|
26
|
+
export declare function rectsForRange(geometry: PageGeometry, startChar: number, endChar: number): HighlightRect[];
|
|
27
|
+
/**
|
|
28
|
+
* Extract text from a character range across all runs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function textForRange(geometry: PageGeometry, startChar: number, endChar: number): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var i = Object.defineProperty;
|
|
2
|
+
var a = (t, e, c) => e in t ? i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: c }) : t[e] = c;
|
|
3
|
+
var h = (t, e, c) => (a(t, typeof e != "symbol" ? e + "" : e, c), c);
|
|
4
|
+
class o {
|
|
5
|
+
constructor(e = 50) {
|
|
6
|
+
h(this, "cache", /* @__PURE__ */ new Map());
|
|
7
|
+
h(this, "maxSize");
|
|
8
|
+
this.maxSize = e;
|
|
9
|
+
}
|
|
10
|
+
get(e) {
|
|
11
|
+
const c = this.cache.get(e);
|
|
12
|
+
return c !== void 0 && (this.cache.delete(e), this.cache.set(e, c)), c;
|
|
13
|
+
}
|
|
14
|
+
set(e, c) {
|
|
15
|
+
if (this.cache.has(e) && this.cache.delete(e), this.cache.size >= this.maxSize) {
|
|
16
|
+
const s = this.cache.keys().next().value;
|
|
17
|
+
s !== void 0 && this.cache.delete(s);
|
|
18
|
+
}
|
|
19
|
+
this.cache.set(e, c);
|
|
20
|
+
}
|
|
21
|
+
clear() {
|
|
22
|
+
this.cache.clear();
|
|
23
|
+
}
|
|
24
|
+
get size() {
|
|
25
|
+
return this.cache.size;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const l = new o();
|
|
29
|
+
export {
|
|
30
|
+
o as GeometryCache,
|
|
31
|
+
l as geometryCache
|
|
32
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function x(g, s, i, u = 4) {
|
|
2
|
+
let e = 0;
|
|
3
|
+
for (let h = 0; h < g.runs.length; h++) {
|
|
4
|
+
const l = g.runs[h];
|
|
5
|
+
for (let n = 0; n < l.glyphs.length; n++) {
|
|
6
|
+
const t = l.glyphs[n];
|
|
7
|
+
if (s >= t.tightX && s <= t.tightX + t.tightWidth && i >= t.tightY && i <= t.tightY + t.tightHeight)
|
|
8
|
+
return { runIndex: h, glyphIndex: n, charIndex: e + n };
|
|
9
|
+
}
|
|
10
|
+
e += l.glyphs.length;
|
|
11
|
+
}
|
|
12
|
+
let c = 1 / 0, o = null;
|
|
13
|
+
e = 0;
|
|
14
|
+
for (let h = 0; h < g.runs.length; h++) {
|
|
15
|
+
const l = g.runs[h];
|
|
16
|
+
for (let n = 0; n < l.glyphs.length; n++) {
|
|
17
|
+
const t = l.glyphs[n];
|
|
18
|
+
if (t.flags === 2)
|
|
19
|
+
continue;
|
|
20
|
+
const f = t.x + t.width / 2, p = t.y + t.height / 2, d = Math.abs(s - f) + Math.abs(i - p), r = u / 2;
|
|
21
|
+
s >= t.x - r && s <= t.x + t.width + r && i >= t.y - r && i <= t.y + t.height + r && d < c && (c = d, o = { runIndex: h, glyphIndex: n, charIndex: e + n });
|
|
22
|
+
}
|
|
23
|
+
e += l.glyphs.length;
|
|
24
|
+
}
|
|
25
|
+
return o;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
x as glyphAt
|
|
29
|
+
};
|