@react-pdf-kit/viewer 0.0.0-experimental.0 → 0.0.0-experimental.2
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 +84 -49
- package/dist/{Combination-54a77a7a.js → Combination-17ab8af1.js} +184 -187
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +8 -8
- package/dist/components/RPConfig.js +5 -7
- package/dist/components/RPController.js +76 -77
- package/dist/components/RPDropFileZone.js +4 -3
- package/dist/components/RPPages.js +577 -573
- package/dist/components/RPProvider.js +2 -2
- package/dist/components/layout/RPDefaultLayout.js +10 -9
- package/dist/components/layout/RPLayout.js +10 -9
- package/dist/components/layout/WrapperLayout.js +4 -3
- package/dist/components/layout/sidebar/RPSidebar.js +8 -7
- package/dist/components/layout/sidebar/Thumbnail.js +4 -3
- package/dist/components/layout/sidebar/Thumbnails.js +4 -3
- package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +43 -34
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/FileUploadTool.js +10 -9
- 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 +10 -9
- package/dist/components/layout/toolbar/OtherTool.js +10 -9
- package/dist/components/layout/toolbar/Paginate.js +8 -7
- package/dist/components/layout/toolbar/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
- package/dist/components/layout/toolbar/RPMoreOptions.js +10 -9
- package/dist/components/layout/toolbar/RPToolbar.js +10 -9
- package/dist/components/layout/toolbar/RPToolbarEnd.js +10 -9
- package/dist/components/layout/toolbar/RotateTool.js +10 -9
- 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 +23 -30
- package/dist/components/layout/toolbar/SearchTool.js +104 -100
- package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/ThumbnailTool.js +8 -7
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
- package/dist/components/layout/toolbar/ToolbarDefault.js +10 -9
- package/dist/components/layout/toolbar/ToolbarLayout.js +10 -9
- package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
- package/dist/components/layout/toolbar/ZoomTool.js +10 -9
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +9 -8
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +10 -11
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +10 -11
- 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 +8 -7
- package/dist/components/layout/toolbar/tools/LastPageTool.js +10 -11
- package/dist/components/layout/toolbar/tools/NextPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PrintTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +8 -7
- 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 +8 -7
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +8 -7
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +20 -19
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +8 -7
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +10 -9
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +8 -7
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +10 -9
- 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 +25 -24
- package/dist/components/page/CanvasLayer.js +38 -54
- package/dist/components/page/CustomElement.js +4 -3
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +35 -35
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/components/page/TextHighlightLayer.js +16 -15
- package/dist/components/page/TextLayer.js +27 -28
- 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/LoadingIndicator.js +8 -7
- package/dist/components/ui/RPTooltip.js +197 -411
- package/dist/contexts/DimensionPagesContext.js +28 -56
- package/dist/contexts/DropFileZoneContext.js +5 -4
- package/dist/contexts/ElementPageContext.js +6 -5
- package/dist/contexts/FileInputContext.js +6 -5
- package/dist/contexts/HighlightContext.js +6 -5
- package/dist/contexts/InitialStateContext.js +6 -8
- package/dist/contexts/PagesRotateContext.js +6 -5
- package/dist/contexts/PaginationContext.js +6 -5
- package/dist/contexts/PrintContext.js +17 -16
- package/dist/contexts/RPDocumentContext.js +14 -13
- package/dist/contexts/RenderQueueProvider.js +14 -13
- package/dist/contexts/RotationContext.js +9 -8
- package/dist/contexts/SearchContext.js +6 -5
- package/dist/contexts/ThumbnailsContext.js +5 -4
- package/dist/contexts/ZoomContext.js +6 -5
- package/dist/{index-c0faa594.js → index-113053cf.js} +2 -2
- package/dist/index-11f3cd64.js +983 -0
- package/dist/{index-e3ee9457.js → index-23911b43.js} +6 -6
- package/dist/{index-655864a7.js → index-ada501c4.js} +1 -1
- package/dist/index-d0f0aa9a.js +1542 -0
- package/dist/main.js +47 -47
- package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
- package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
- package/dist/types/contexts/RenderQueueProvider.d.ts +1 -2
- package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
- package/dist/types/main.d.ts +3 -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/useHighlight.d.ts +1 -1
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadWorker.d.ts +5 -1
- package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
- package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
- package/dist/types/utils/link_service.d.ts +2 -3
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +7 -8
- package/dist/utils/highlight.js +36 -36
- package/dist/utils/hooks/useFileDownload.js +6 -5
- package/dist/utils/hooks/useHighlight.js +78 -40
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +96 -70
- package/dist/utils/hooks/useLoadWorker.js +4 -14
- package/dist/utils/hooks/usePageRotateContext.js +8 -7
- package/dist/utils/hooks/usePaginate.js +4 -3
- package/dist/utils/hooks/usePinch.js +44 -90
- package/dist/utils/hooks/usePresentPage.js +4 -3
- package/dist/utils/hooks/usePrint.js +92 -100
- package/dist/utils/hooks/useRotate.js +4 -3
- package/dist/utils/hooks/useScrollToPage.js +4 -3
- package/dist/utils/hooks/useSearch.js +16 -15
- package/dist/utils/hooks/useThumbnail.js +18 -17
- package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
- package/dist/utils/hooks/useWatermark.js +43 -61
- package/dist/utils/injectPrintCSS.js +4 -3
- package/dist/utils/link_service.js +18 -19
- package/dist/utils/renderPage.js +14 -14
- package/package.json +2 -3
- package/dist/contexts/SmoothScaleContext.js +0 -67
- package/dist/floating-ui.react-dom-5ec29bd6.js +0 -1327
- package/dist/index-4baea9b5.js +0 -1198
- package/dist/types/contexts/SmoothScaleContext.d.ts +0 -16
- package/dist/types/utils/hooks/useAccumulateFactor.d.ts +0 -9
- package/dist/utils/hooks/useAccumulateFactor.js +0 -17
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var u = (n, e, t) => e in n ? g(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var a = (n, e, t) => (u(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
class f {
|
|
5
5
|
constructor(e, t) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
a(this, "externalLinkEnabled");
|
|
7
|
+
a(this, "pdfDocument");
|
|
8
8
|
this.externalLinkEnabled = !0, this.pdfDocument = e, this.goToPage = t;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -46,7 +46,7 @@ class p {
|
|
|
46
46
|
* @param {string|Array} _dest - The named, or explicit, PDF destination.
|
|
47
47
|
*/
|
|
48
48
|
async goToDestination(e) {
|
|
49
|
-
var i, s
|
|
49
|
+
var i, s;
|
|
50
50
|
let t, r;
|
|
51
51
|
if (typeof e == "string" ? t = await ((i = this.pdfDocument) == null ? void 0 : i.getDestination(e)) : t = await e, !Array.isArray(t)) {
|
|
52
52
|
console.error(
|
|
@@ -55,17 +55,16 @@ class p {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
const [o] = t;
|
|
58
|
-
if (o && typeof o == "object")
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} else
|
|
58
|
+
if (o && typeof o == "object")
|
|
59
|
+
try {
|
|
60
|
+
r = (await ((s = this.pdfDocument) == null ? void 0 : s.getPageIndex(o)) || 0) + 1;
|
|
61
|
+
} catch {
|
|
62
|
+
console.error(
|
|
63
|
+
`goToDestination: "${o}" is not a valid page reference, for dest="${e}".`
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
else
|
|
69
68
|
Number.isInteger(o) && (r = o + 1);
|
|
70
69
|
if (!r || r < 1 || r > this.pagesCount) {
|
|
71
70
|
console.error(
|
|
@@ -134,5 +133,5 @@ class p {
|
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
export {
|
|
137
|
-
|
|
136
|
+
f as SimpleLinkService
|
|
138
137
|
};
|
package/dist/utils/renderPage.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { AnnotationMode as
|
|
2
|
-
const
|
|
3
|
-
const { scale:
|
|
1
|
+
import { AnnotationMode as h } from "@pdf-viewer/pdfium/compat";
|
|
2
|
+
const x = (e, t, s = {}) => {
|
|
3
|
+
const { scale: i = 1, rotate: r = 0, renderForms: w = !1, interactiveForm: a = !0 } = s, c = t.getContext("2d", {
|
|
4
4
|
desynchronized: !1
|
|
5
|
-
}),
|
|
6
|
-
scale:
|
|
7
|
-
rotation:
|
|
5
|
+
}), p = window.devicePixelRatio, n = e.getViewport({ scale: i, rotation: r }), o = e.getViewport({
|
|
6
|
+
scale: i * p,
|
|
7
|
+
rotation: r
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
return
|
|
12
|
-
canvas:
|
|
13
|
-
canvasContext:
|
|
14
|
-
viewport:
|
|
15
|
-
annotationMode:
|
|
9
|
+
t.width = o.width, t.height = o.height, t.style.width = `${Math.floor(n.width)}px`, t.style.height = `${Math.floor(n.height)}px`;
|
|
10
|
+
let d = w ? h.ENABLE_FORMS : void 0;
|
|
11
|
+
return a || (d = h.ENABLE), e.render({
|
|
12
|
+
canvas: t,
|
|
13
|
+
canvasContext: c,
|
|
14
|
+
viewport: o,
|
|
15
|
+
annotationMode: d
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
export {
|
|
19
|
-
|
|
19
|
+
x as renderPage
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-pdf-kit/viewer",
|
|
3
|
-
"version": "0.0.0-experimental.
|
|
3
|
+
"version": "0.0.0-experimental.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"prepare": "husky"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@pdf-viewer/pdfium": "0.0.0-experimental.0",
|
|
42
43
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
43
44
|
"@radix-ui/react-popover": "^1.1.15",
|
|
44
45
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
45
|
-
"pdfjs-dist": "5.4.530",
|
|
46
46
|
"react-virtualized-auto-sizer": "^1.0.24",
|
|
47
47
|
"react-window": "^1.8.10"
|
|
48
48
|
},
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"pdfjs-dist": "5.4.530",
|
|
81
80
|
"react": "^18.2.0 || ^19.0.0",
|
|
82
81
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
83
82
|
},
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as R, useContext as T, useState as p, useRef as i, useCallback as g, useEffect as f, useMemo as S } from "react";
|
|
3
|
-
import { useZoomContext as v } from "./ZoomContext.js";
|
|
4
|
-
import "../utils/types.js";
|
|
5
|
-
import "../de_DE-a553b162.js";
|
|
6
|
-
import "../utils/appConsole.js";
|
|
7
|
-
import "./InitialStateContext.js";
|
|
8
|
-
import "./RPDocumentContext.js";
|
|
9
|
-
import "../utils/hooks/useLoadPdf.js";
|
|
10
|
-
import "pdfjs-dist";
|
|
11
|
-
import "../utils/getThumbnailViewport.js";
|
|
12
|
-
import "./ConfigContext.js";
|
|
13
|
-
import "./DocumentPasswordContext.js";
|
|
14
|
-
import "../utils/hooks/usePdfProperties.js";
|
|
15
|
-
import "../utils/convertPdfDate.js";
|
|
16
|
-
import "../utils/formatFileSize.js";
|
|
17
|
-
import "../utils/constants.js";
|
|
18
|
-
import "../utils/getZoomLevel.js";
|
|
19
|
-
import "./LayoutContainerContext.js";
|
|
20
|
-
import "./ViewModeContext.js";
|
|
21
|
-
import "./RotationContext.js";
|
|
22
|
-
import "./GlobalCurrentPage.js";
|
|
23
|
-
import "./EventCallbackContext.js";
|
|
24
|
-
import "../utils/hooks/useDebounce.js";
|
|
25
|
-
const w = 300, x = R(null), N = () => {
|
|
26
|
-
const o = T(x);
|
|
27
|
-
if (!o)
|
|
28
|
-
throw new Error("useSmoothScaleContext must be used within a SmoothScaleProvider");
|
|
29
|
-
return o;
|
|
30
|
-
}, Q = ({ children: o }) => {
|
|
31
|
-
const { currentZoom: t } = v(), [e, m] = p(t), [s, c] = p(!1), r = i(null), n = i(t), l = i(!1), d = i(null), u = g(() => {
|
|
32
|
-
m(n.current), c(!1);
|
|
33
|
-
}, []);
|
|
34
|
-
f(() => {
|
|
35
|
-
if (t !== 0) {
|
|
36
|
-
if (!l.current) {
|
|
37
|
-
l.current = !0, n.current = t, m(t);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (n.current = t, t === e) {
|
|
41
|
-
c(!1), r.current && (clearTimeout(r.current), r.current = null);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
c(!0), r.current && clearTimeout(r.current), r.current = setTimeout(() => {
|
|
45
|
-
r.current = null, u();
|
|
46
|
-
}, w);
|
|
47
|
-
}
|
|
48
|
-
}, [t]), f(() => () => {
|
|
49
|
-
r.current && clearTimeout(r.current);
|
|
50
|
-
}, []);
|
|
51
|
-
const a = S(() => e === 0 ? 1 : t / e, [e, t]), C = S(
|
|
52
|
-
() => ({
|
|
53
|
-
isTransitioning: s,
|
|
54
|
-
renderedScale: e,
|
|
55
|
-
targetScale: n.current,
|
|
56
|
-
transformRatio: a,
|
|
57
|
-
commitScale: u,
|
|
58
|
-
zoomOriginRef: d
|
|
59
|
-
}),
|
|
60
|
-
[s, e, a, u]
|
|
61
|
-
);
|
|
62
|
-
return /* @__PURE__ */ h(x.Provider, { value: C, children: o });
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
Q as SmoothScaleProvider,
|
|
66
|
-
N as useSmoothScaleContext
|
|
67
|
-
};
|