react-pdfjs-multi 0.5.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -34
- package/dist/assets/secondaryToolbarButton-rotateCcw.png +0 -0
- package/dist/assets/secondaryToolbarButton-rotateCcw@2x.png +0 -0
- package/dist/assets/secondaryToolbarButton-rotateCw.png +0 -0
- package/dist/assets/secondaryToolbarButton-rotateCw@2x.png +0 -0
- package/dist/assets/texture.png +0 -0
- package/dist/assets/toolbarButton-download.png +0 -0
- package/dist/assets/toolbarButton-download@2x.png +0 -0
- package/dist/assets/toolbarButton-menuArrows.png +0 -0
- package/dist/assets/toolbarButton-sidebarToggle.png +0 -0
- package/dist/assets/toolbarButton-sidebarToggle@2x.png +0 -0
- package/dist/assets/toolbarButton-zoomIn.png +0 -0
- package/dist/assets/toolbarButton-zoomIn@2x.png +0 -0
- package/dist/assets/toolbarButton-zoomOut.png +0 -0
- package/dist/assets/toolbarButton-zoomOut@2x.png +0 -0
- package/dist/components/PdfMultiViewer/PdfMultiViewer.d.ts +19 -0
- package/dist/components/PdfMultiViewer/PdfMultiViewerView.d.ts +20 -0
- package/dist/components/PdfMultiViewer/index.d.ts +4 -0
- package/dist/components/PdfMultiViewer/usePdfMultiViewer.d.ts +44 -0
- package/dist/components/PdfRenderer/PdfRenderer.d.ts +28 -0
- package/dist/{PdfRendererControls.d.ts → components/PdfRenderer/PdfRendererControls.d.ts} +14 -15
- package/dist/components/PdfRenderer/PdfRendererView.d.ts +20 -0
- package/dist/components/PdfRenderer/ZoomSelectBox.d.ts +9 -0
- package/dist/components/PdfRenderer/index.d.ts +7 -0
- package/dist/components/PdfRenderer/usePdfRenderer.d.ts +32 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/{I18nContext.d.ts → contexts/I18nContext.d.ts} +12 -12
- package/dist/contexts/index.d.ts +1 -0
- package/dist/index.css +6 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +816 -1820
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +826 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/filenameHelper.d.ts +1 -1
- package/dist/lib/iconStyles.d.ts +3 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/pdfjsLib.d.ts +2 -0
- package/dist/lib/resizeAutoZoomEvent.d.ts +0 -1
- package/dist/pdf.worker.min.mjs +28 -0
- package/dist/pdfjsLib-DFD5U54F.js +9 -0
- package/dist/pdfjsLib-DgdIcD_k.mjs +8 -0
- package/dist/pdfjsLib-DgdIcD_k.mjs.map +1 -0
- package/dist/pdfjsLib-cEuHH6WZ.mjs +3 -0
- package/dist/pdfjsLib-z4sS0gWp.js +41 -0
- package/dist/pdfjsLib-z4sS0gWp.js.map +1 -0
- package/dist/react-pdfjs-multi.css +4 -5
- package/dist/types/iconConfig.d.ts +10 -0
- package/package.json +46 -70
- package/dist/PdfMultiViewer.d.ts +0 -57
- package/dist/PdfRenderer.d.ts +0 -56
- package/dist/ZoomSelectBox.d.ts +0 -32
- package/dist/index.es.js +0 -1830
package/README.md
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
# react-pdfjs-multi
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.com/marcklei/react-pdfjs-multi)
|
|
4
|
-
[](https://david-dm.org/marcklei/react-pdfjs-multi)
|
|
5
|
-
[](https://coveralls.io/github/marcklei/react-pdfjs-multi?branch=master)
|
|
6
|
-
|
|
7
3
|
React wrapper for pdfjs with multiple file support.
|
|
8
4
|
|
|
9
5
|
This library uses [pdf.js][1].
|
|
10
6
|
|
|
11
|
-
For a preview of the current development visit [github pages][2].
|
|
12
|
-
|
|
13
7
|
> What does in development mean:
|
|
14
8
|
>
|
|
15
9
|
> 1. **MINOR** versions represent **breaking changes**
|
|
@@ -24,45 +18,171 @@ or
|
|
|
24
18
|
|
|
25
19
|
`npm i react-pdfjs-multi`
|
|
26
20
|
|
|
27
|
-
Example Usage:
|
|
21
|
+
Example Usage MultiViewer:
|
|
28
22
|
|
|
29
23
|
```javascript
|
|
30
|
-
import React
|
|
24
|
+
import React from 'react';
|
|
31
25
|
import { PdfMultiViewer } from 'react-pdfjs-multi';
|
|
32
26
|
import 'react-pdfjs-multi/dist/react-pdfjs-multi.css';
|
|
33
27
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
28
|
+
const MultiViewerExample = () => {
|
|
29
|
+
const pdfFiles = [
|
|
30
|
+
'pdfs/test-pdf-a.pdf',
|
|
31
|
+
{
|
|
32
|
+
title:
|
|
33
|
+
'Trace-based Just-in-Time Type Specialization for DynamicLanguages',
|
|
34
|
+
source: 'pdfs/compressed.tracemonkey-pldi-09.pdf',
|
|
35
|
+
},
|
|
36
|
+
'pdfs/test-pdf-b.pdf',
|
|
37
|
+
'pdfs/test-pdf-c.pdf',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<PdfMultiViewer
|
|
42
|
+
pdfs={pdfFiles}
|
|
43
|
+
i18nData={{
|
|
44
|
+
download: 'Herunterladen',
|
|
45
|
+
scaleDown: 'Verkleinern',
|
|
46
|
+
scaleUp: 'Vergrößern',
|
|
47
|
+
originalSize: 'Originalgröße',
|
|
48
|
+
pages: 'Seiten',
|
|
49
|
+
zoom: 'Automatischer Zoom',
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
49
54
|
|
|
50
55
|
export default MultiViewerExample;
|
|
51
56
|
```
|
|
52
57
|
|
|
58
|
+
Example Usage Renderer (Typescript)
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import React, { FC, useState, useEffect } from 'react';
|
|
62
|
+
import { PdfRenderer, PdfjsLib, PDFDocumentProxy } from 'react-pdfjs-multi';
|
|
63
|
+
import workerSrc from 'react-pdfjs-multi/dist/pdf.worker.min.mjs?url';
|
|
64
|
+
|
|
65
|
+
PdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;
|
|
66
|
+
|
|
67
|
+
const RendererExample: FC = () => {
|
|
68
|
+
const [pdfDoc, setPdfDoc] = useState<PDFDocumentProxy>();
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const getPdfDoc = async () => {
|
|
72
|
+
const doc = await PdfjsLib.getDocument({
|
|
73
|
+
url: 'pdfs/compressed.tracemonkey-pldi-09.pdf',
|
|
74
|
+
}).promise;
|
|
75
|
+
|
|
76
|
+
setPdfDoc(doc);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
getPdfDoc();
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
if (!pdfDoc) return null;
|
|
83
|
+
|
|
84
|
+
return <PdfRenderer pdfDoc={pdfDoc} downloadBtn={false} />;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default RendererExample;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Example App
|
|
91
|
+
|
|
92
|
+
A minimal workspace example lives at `apps/example`.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pnpm install
|
|
96
|
+
pnpm start
|
|
97
|
+
pnpm dev:example
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Run `pnpm start` and `pnpm dev:example` in separate terminals during development.
|
|
101
|
+
|
|
102
|
+
### Styling
|
|
103
|
+
|
|
104
|
+
This library ships with optional default styles in
|
|
105
|
+
`react-pdfjs-multi/dist/react-pdfjs-multi.css`. You can:
|
|
106
|
+
|
|
107
|
+
- Use the defaults as-is.
|
|
108
|
+
- Skip the CSS import and provide your own styles.
|
|
109
|
+
- Override the defaults via CSS variables.
|
|
110
|
+
|
|
111
|
+
Example override:
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
.pdfjs-multi {
|
|
115
|
+
--pdfjs-multi-bg: #f7f7f7;
|
|
116
|
+
--pdfjs-multi-text: #1f2933;
|
|
117
|
+
--pdfjs-multi-surface: #ffffff;
|
|
118
|
+
--pdfjs-multi-texture: none;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Available variables (non-exhaustive):
|
|
123
|
+
|
|
124
|
+
| Scope | Variable | Default | Purpose |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| MultiViewer | `--pdfjs-multi-bg` | `#404040` | Base background |
|
|
127
|
+
| MultiViewer | `--pdfjs-multi-text` | `#fff` | Text color |
|
|
128
|
+
| MultiViewer | `--pdfjs-multi-surface` | `#565656` | List background |
|
|
129
|
+
| MultiViewer | `--pdfjs-multi-surface-active` | `#474747` | Active list item |
|
|
130
|
+
| MultiViewer | `--pdfjs-multi-muted-text` | `#cecece` | Metadata text |
|
|
131
|
+
| MultiViewer | `--pdfjs-multi-divider` | `rgba(53, 52, 52, 0.81)` | List divider |
|
|
132
|
+
| MultiViewer | `--pdfjs-multi-list-width` | `300px` | List width |
|
|
133
|
+
| MultiViewer | `--pdfjs-multi-list-item-padding` | `25px 35px` | List item padding |
|
|
134
|
+
| MultiViewer | `--pdfjs-multi-option-bar-height` | `33px` | Option bar height |
|
|
135
|
+
| MultiViewer | `--pdfjs-multi-option-bar-padding` | `4px 2px 4px 10px` | Option bar padding |
|
|
136
|
+
| MultiViewer | `--pdfjs-multi-min-height` | `360px` | Minimum viewer height |
|
|
137
|
+
| Shared | `--pdfjs-multi-texture` | `url("./assets/texture.png")` | Background texture |
|
|
138
|
+
| Controls | `--pdfjs-multi-controls-bg` | `#474747` | Controls background |
|
|
139
|
+
| Controls | `--pdfjs-multi-controls-text` | `hsla(0, 0%, 100%, 0.8)` | Controls text |
|
|
140
|
+
| Controls | `--pdfjs-multi-control-icon-zoom-out` | `image-set(...)` | Zoom out icon |
|
|
141
|
+
| Controls | `--pdfjs-multi-control-icon-zoom-in` | `image-set(...)` | Zoom in icon |
|
|
142
|
+
| Controls | `--pdfjs-multi-control-icon-rotate-left` | `image-set(...)` | Rotate left icon |
|
|
143
|
+
| Controls | `--pdfjs-multi-control-icon-rotate-right` | `image-set(...)` | Rotate right icon |
|
|
144
|
+
| Controls | `--pdfjs-multi-control-icon-download` | `image-set(...)` | Download icon |
|
|
145
|
+
| Controls | `--pdfjs-multi-control-icon-toggle-list` | `image-set(...)` | Toggle list icon |
|
|
146
|
+
| Select | `--pdfjs-multi-select-icon` | `url("./assets/toolbarButton-menuArrows.png")` | Select icon |
|
|
147
|
+
|
|
148
|
+
### Icons
|
|
149
|
+
|
|
150
|
+
Use the `icons` prop to override the default PNGs. Values can be plain
|
|
151
|
+
URLs (wrapped as `url(...)`) or full CSS values (e.g. `image-set(...)` or
|
|
152
|
+
`url(...)`).
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import type { IconConfig } from 'react-pdfjs-multi';
|
|
156
|
+
|
|
157
|
+
const icons: IconConfig = {
|
|
158
|
+
zoomIn: '/icons/zoom-in.svg',
|
|
159
|
+
zoomOut: '/icons/zoom-out.svg',
|
|
160
|
+
rotateLeft: '/icons/rotate-left.svg',
|
|
161
|
+
rotateRight: '/icons/rotate-right.svg',
|
|
162
|
+
download: '/icons/download.svg',
|
|
163
|
+
toggleList: '/icons/toggle-list.svg',
|
|
164
|
+
selectArrow: '/icons/select-arrow.svg',
|
|
165
|
+
texture: 'none',
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
53
169
|
### PdfMultiViewer
|
|
54
170
|
|
|
55
|
-
The MultiViewer allows you to pass an array of source strings or an object definition and it
|
|
171
|
+
The MultiViewer allows you to pass an array of source strings or an object definition and it lazy-loads PDFs by default, showing the renderer as soon as the active PDF is loaded.
|
|
56
172
|
|
|
57
173
|
Props:
|
|
58
174
|
|
|
59
|
-
| Name
|
|
60
|
-
|
|
|
61
|
-
| pdfs
|
|
62
|
-
| autoZoom
|
|
63
|
-
| controls
|
|
64
|
-
|
|
|
65
|
-
|
|
|
175
|
+
| Name | Required | Default | Type | Description |
|
|
176
|
+
| --------------- | -------- | ------- | --------------- | -------------------------------------------------------------- |
|
|
177
|
+
| pdfs | true | | {array} | An array of strings or objects |
|
|
178
|
+
| autoZoom | | true | {boolean} | enables/disables autoZoom on component mount and window resize |
|
|
179
|
+
| controls | | true | {boolean} | enables/disables controls to e.g. change renderer zoom |
|
|
180
|
+
| icons | | | {IconConfig} | Override default icons and texture |
|
|
181
|
+
| i18nData | | {}\* | {I18nData} | An object of translated strings, default language is en |
|
|
182
|
+
| startIndex | | 0 | {number} | first pdf to display using array index |
|
|
183
|
+
| lazyLoad | | true | {boolean} | load only the active PDF until a list item is selected |
|
|
184
|
+
| initialLoadIndex| | startIndex | {number|string} | which PDF to prefetch on mount when lazyLoad is enabled |
|
|
185
|
+
| workerSrc | | | {string} | pdf.js worker URL |
|
|
66
186
|
|
|
67
187
|
### i18n
|
|
68
188
|
|
|
@@ -73,6 +193,7 @@ To be able to use different i18n libraries eg. i18next or react-intl you can pas
|
|
|
73
193
|
```javascript
|
|
74
194
|
{
|
|
75
195
|
// Viewer
|
|
196
|
+
loading: 'Loading...',
|
|
76
197
|
pages: 'Pages',
|
|
77
198
|
// Renderer
|
|
78
199
|
zoom: 'Automatic zoom',
|
|
@@ -87,7 +208,7 @@ To be able to use different i18n libraries eg. i18next or react-intl you can pas
|
|
|
87
208
|
|
|
88
209
|
### PdfRenderer
|
|
89
210
|
|
|
90
|
-
If you like to implement your own custom multi renderer logic you can use the PdfRenderer component.
|
|
211
|
+
If you like to implement your own custom multi renderer logic you can use the PdfRenderer component.
|
|
91
212
|
|
|
92
213
|
Props:
|
|
93
214
|
|
|
@@ -97,6 +218,7 @@ Props:
|
|
|
97
218
|
| autoZoom | | true | {boolean} | enables/disables autoZoom on component mount and window resize |
|
|
98
219
|
| controls | | true | {boolean} | enables/disables controls to e.g. change renderer zoom |
|
|
99
220
|
| downloadBtn | | true | {boolean} | enables/disables download button |
|
|
221
|
+
| icons | | | {IconConfig} | Override default icons and texture |
|
|
100
222
|
| i18nData | | {}\* | {I18nDataRenderer} | An object of translated strings, default language is en |
|
|
101
223
|
| zoom | | null | {number} | Initial Zoom |
|
|
102
224
|
| rotation | | null | {number} | Initial Rotation |
|
|
@@ -106,5 +228,3 @@ Props:
|
|
|
106
228
|
| pdfChangeHook | | null | {func} | Callback function which gets a position object |
|
|
107
229
|
|
|
108
230
|
[1]: https://mozilla.github.io/pdf.js/
|
|
109
|
-
[2]: https://marcklei.github.io/react-pdfjs-multi/
|
|
110
|
-
[3]: https://github.com/marcklei/react-pdfjs-multi/blob/master/examples/src/RendererExample.js
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import '@/components/PdfMultiViewer/PdfMultiViewer.css';
|
|
2
|
+
import { type I18nData, type PdfSource } from '@/components/PdfMultiViewer/usePdfMultiViewer';
|
|
3
|
+
import type { IconConfig } from '@/types/iconConfig';
|
|
4
|
+
type DefaultProps = {
|
|
5
|
+
autoZoom?: boolean;
|
|
6
|
+
controls?: boolean;
|
|
7
|
+
icons?: IconConfig;
|
|
8
|
+
lazyLoad?: boolean;
|
|
9
|
+
initialLoadIndex?: string | number;
|
|
10
|
+
startIndex?: string;
|
|
11
|
+
i18nData?: I18nData;
|
|
12
|
+
workerSrc?: string;
|
|
13
|
+
};
|
|
14
|
+
type Props = {
|
|
15
|
+
pdfs: PdfSource[];
|
|
16
|
+
} & Partial<DefaultProps>;
|
|
17
|
+
declare const PdfMultiViewer: ({ pdfs, autoZoom, controls, icons, lazyLoad, initialLoadIndex, startIndex, i18nData, workerSrc, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default PdfMultiViewer;
|
|
19
|
+
export type { I18nData };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import type { I18nData, PdfFile } from '@/components/PdfMultiViewer/usePdfMultiViewer';
|
|
3
|
+
import type { RendererDocumentPosition } from '@/components/PdfRenderer/usePdfRenderer';
|
|
4
|
+
type Props = {
|
|
5
|
+
activeIndex: string;
|
|
6
|
+
autoZoom: boolean;
|
|
7
|
+
controls: boolean;
|
|
8
|
+
files: PdfFile[];
|
|
9
|
+
iconStyles?: CSSProperties;
|
|
10
|
+
i18nData: I18nData;
|
|
11
|
+
listVisible: boolean;
|
|
12
|
+
overlayMode: boolean;
|
|
13
|
+
pdfToShow?: PdfFile;
|
|
14
|
+
viewerContainerRef: RefObject<HTMLDivElement>;
|
|
15
|
+
onRememberPosition: (index: string, position: RendererDocumentPosition) => void;
|
|
16
|
+
onSelectPdf: (nextIndex: string, file: PdfFile) => () => void;
|
|
17
|
+
onToggleList: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare const PdfMultiViewerView: ({ activeIndex, autoZoom, controls, files, iconStyles, i18nData, listVisible, overlayMode, pdfToShow, viewerContainerRef, onRememberPosition, onSelectPdf, onToggleList, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default PdfMultiViewerView;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default, default as PdfMultiViewer } from './PdfMultiViewer';
|
|
2
|
+
export { default as PdfMultiViewerView } from './PdfMultiViewerView';
|
|
3
|
+
export type { I18nData, PdfDefinition, PdfFile, PdfSource, } from './usePdfMultiViewer';
|
|
4
|
+
export { usePdfMultiViewer } from './usePdfMultiViewer';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import type { RendererDocumentPosition } from '@/components/PdfRenderer/usePdfRenderer';
|
|
3
|
+
import type { I18nDataRenderer } from '@/contexts';
|
|
4
|
+
export type PdfDefinition = {
|
|
5
|
+
title: string;
|
|
6
|
+
source: string;
|
|
7
|
+
};
|
|
8
|
+
export type PdfSource = string | PdfDefinition;
|
|
9
|
+
export type PdfFile = {
|
|
10
|
+
index?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
zoom?: number;
|
|
13
|
+
rotation?: number;
|
|
14
|
+
scrollTop?: number | null;
|
|
15
|
+
scrollLeft?: number | null;
|
|
16
|
+
isLoading?: boolean;
|
|
17
|
+
source: string;
|
|
18
|
+
pdfProxy: PDFDocumentProxy | null;
|
|
19
|
+
};
|
|
20
|
+
export type I18nData = {
|
|
21
|
+
loading?: string;
|
|
22
|
+
pages?: string;
|
|
23
|
+
} & I18nDataRenderer;
|
|
24
|
+
type UsePdfMultiViewerArgs = {
|
|
25
|
+
pdfs: PdfSource[];
|
|
26
|
+
startIndex: string;
|
|
27
|
+
i18nData: I18nData;
|
|
28
|
+
lazyLoad: boolean;
|
|
29
|
+
initialLoadIndex?: string | number;
|
|
30
|
+
workerSrc?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const usePdfMultiViewer: ({ pdfs, startIndex, i18nData, lazyLoad, initialLoadIndex, workerSrc, }: UsePdfMultiViewerArgs) => {
|
|
33
|
+
activeIndex: string;
|
|
34
|
+
files: PdfFile[];
|
|
35
|
+
i18nData: I18nData;
|
|
36
|
+
listVisible: boolean;
|
|
37
|
+
overlayMode: boolean;
|
|
38
|
+
pdfToShow: PdfFile;
|
|
39
|
+
rememberPosition: (index: string, position: RendererDocumentPosition) => void;
|
|
40
|
+
selectPdf: (nextIndex: string, file: PdfFile) => () => void;
|
|
41
|
+
toggleList: () => void;
|
|
42
|
+
viewerContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import type { PDFViewer } from 'pdfjs-dist/web/pdf_viewer.mjs';
|
|
3
|
+
import 'pdfjs-dist/web/pdf_viewer.css';
|
|
4
|
+
import '@/components/PdfRenderer/PdfRenderer.css';
|
|
5
|
+
import { type PdfChangeHook } from '@/components/PdfRenderer/usePdfRenderer';
|
|
6
|
+
import { type I18nDataRenderer } from '@/contexts';
|
|
7
|
+
import type { IconConfig } from '@/types/iconConfig';
|
|
8
|
+
export type { RendererDocumentPosition } from '@/components/PdfRenderer/usePdfRenderer';
|
|
9
|
+
type DefaultProps = {
|
|
10
|
+
activeIndex?: string;
|
|
11
|
+
autoZoom?: boolean;
|
|
12
|
+
controls?: boolean;
|
|
13
|
+
downloadBtn: boolean;
|
|
14
|
+
icons?: IconConfig;
|
|
15
|
+
i18nData?: I18nDataRenderer;
|
|
16
|
+
pdfChangeHook?: PdfChangeHook | null;
|
|
17
|
+
zoom?: number;
|
|
18
|
+
rotation?: number;
|
|
19
|
+
scrollTop?: number | null;
|
|
20
|
+
scrollLeft?: number | null;
|
|
21
|
+
};
|
|
22
|
+
export type PdfRendererHandle = {
|
|
23
|
+
pdfViewer: PDFViewer | null;
|
|
24
|
+
};
|
|
25
|
+
declare const PdfRenderer: import("react").ForwardRefExoticComponent<{
|
|
26
|
+
pdfDoc: PDFDocumentProxy;
|
|
27
|
+
} & Partial<DefaultProps> & import("react").RefAttributes<PdfRendererHandle>>;
|
|
28
|
+
export default PdfRenderer;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
scale: number;
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default PdfControls;
|
|
1
|
+
import '@/components/PdfRenderer/PdfRendererControls.css';
|
|
2
|
+
type Props = {
|
|
3
|
+
autoZoom?: boolean;
|
|
4
|
+
downloadBtn?: boolean;
|
|
5
|
+
onDownload: () => void;
|
|
6
|
+
onZoomIn: () => void;
|
|
7
|
+
onZoomOut: () => void;
|
|
8
|
+
onRotateRight: () => void;
|
|
9
|
+
onRotateLeft: () => void;
|
|
10
|
+
scale: number;
|
|
11
|
+
setScale: (scale: number) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const PdfControls: ({ autoZoom, downloadBtn, onDownload, onZoomIn, onZoomOut, onRotateRight, onRotateLeft, scale, setScale, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default PdfControls;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { type I18nDataRenderer } from '@/contexts';
|
|
3
|
+
type Props = {
|
|
4
|
+
autoZoom: boolean;
|
|
5
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
6
|
+
controls: boolean;
|
|
7
|
+
downloadBtn: boolean;
|
|
8
|
+
iconStyles?: CSSProperties;
|
|
9
|
+
i18nData?: I18nDataRenderer;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
scale: number;
|
|
12
|
+
setScale: (scale: number) => void;
|
|
13
|
+
onDownload: () => void;
|
|
14
|
+
onRotateLeft: () => void;
|
|
15
|
+
onRotateRight: () => void;
|
|
16
|
+
onZoomIn: () => void;
|
|
17
|
+
onZoomOut: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare const PdfRendererView: ({ autoZoom, containerRef, controls, downloadBtn, iconStyles, i18nData, isLoading, scale, setScale, onDownload, onRotateLeft, onRotateRight, onZoomIn, onZoomOut, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default PdfRendererView;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@/lib/resizeAutoZoomEvent';
|
|
2
|
+
import '@/components/PdfRenderer/ZoomSelectBox.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
autoZoom?: boolean;
|
|
5
|
+
scale: number;
|
|
6
|
+
setScale: (scale: number) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const ZoomSelectBox: ({ autoZoom, scale, setScale }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default ZoomSelectBox;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { PdfRendererHandle } from './PdfRenderer';
|
|
2
|
+
export { default, default as PdfRenderer } from './PdfRenderer';
|
|
3
|
+
export { default as PdfRendererControls } from './PdfRendererControls';
|
|
4
|
+
export { default as PdfRendererView } from './PdfRendererView';
|
|
5
|
+
export type { PdfChangeHook, RendererDocumentPosition, } from './usePdfRenderer';
|
|
6
|
+
export { usePdfRenderer } from './usePdfRenderer';
|
|
7
|
+
export { default as ZoomSelectBox } from './ZoomSelectBox';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import type { PDFViewer } from 'pdfjs-dist/web/pdf_viewer.mjs';
|
|
3
|
+
export type RendererDocumentPosition = {
|
|
4
|
+
zoom: number;
|
|
5
|
+
rotation: number;
|
|
6
|
+
scrollTop: number | null;
|
|
7
|
+
scrollLeft?: number | null;
|
|
8
|
+
};
|
|
9
|
+
export type PdfChangeHook = (documentIndex: string, position: RendererDocumentPosition) => void;
|
|
10
|
+
type UsePdfRendererArgs = {
|
|
11
|
+
activeIndex: string;
|
|
12
|
+
autoZoom: boolean;
|
|
13
|
+
pdfChangeHook?: PdfChangeHook | null;
|
|
14
|
+
pdfDoc: PDFDocumentProxy;
|
|
15
|
+
rotation: number;
|
|
16
|
+
scrollLeft?: number | null;
|
|
17
|
+
scrollTop?: number | null;
|
|
18
|
+
zoom?: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const usePdfRenderer: ({ activeIndex, autoZoom, pdfChangeHook, pdfDoc, rotation, scrollLeft, scrollTop, zoom, }: UsePdfRendererArgs) => {
|
|
21
|
+
containerRef: import("react").RefObject<HTMLDivElement>;
|
|
22
|
+
download: () => Promise<void>;
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
pdfViewerRef: import("react").MutableRefObject<PDFViewer | null>;
|
|
25
|
+
rotateLeft: () => void;
|
|
26
|
+
rotateRight: () => void;
|
|
27
|
+
scale: number;
|
|
28
|
+
setScale: (nextScaleValue: number) => void;
|
|
29
|
+
zoomIn: () => void;
|
|
30
|
+
zoomOut: () => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type I18nData, type PdfDefinition, type PdfFile, PdfMultiViewer, type PdfSource, usePdfMultiViewer, } from './PdfMultiViewer';
|
|
2
|
+
export { type PdfChangeHook, PdfRenderer, PdfRendererControls, type PdfRendererHandle, PdfRendererView, type RendererDocumentPosition, usePdfRenderer, ZoomSelectBox, } from './PdfRenderer';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
zoom?: string;
|
|
4
|
-
originalSize?: string;
|
|
5
|
-
scaleUp?: string;
|
|
6
|
-
scaleDown?: string;
|
|
7
|
-
rotateLeft?: string;
|
|
8
|
-
rotateRight?: string;
|
|
9
|
-
download?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const defaultI18n: I18nDataRenderer;
|
|
12
|
-
export declare const I18nContext: React.Context<I18nDataRenderer>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type I18nDataRenderer = {
|
|
3
|
+
zoom?: string;
|
|
4
|
+
originalSize?: string;
|
|
5
|
+
scaleUp?: string;
|
|
6
|
+
scaleDown?: string;
|
|
7
|
+
rotateLeft?: string;
|
|
8
|
+
rotateRight?: string;
|
|
9
|
+
download?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultI18n: I18nDataRenderer;
|
|
12
|
+
export declare const I18nContext: React.Context<I18nDataRenderer>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultI18n, I18nContext, type I18nDataRenderer, } from './I18nContext';
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.css","names":[],"sources":["../src/components/PdfMultiViewer/PdfMultiViewer.css","../src/components/PdfRenderer/PdfRenderer.css","../src/components/PdfRenderer/ZoomSelectBox.css","../src/components/PdfRenderer/PdfRendererControls.css"],"sourcesContent":["","","",""],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PdfMultiViewer,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export {
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import { type I18nData, PdfMultiViewer, PdfRenderer, type RendererDocumentPosition } from '@/components';
|
|
3
|
+
import { PdfjsLib } from '@/lib';
|
|
4
|
+
import type { IconConfig } from '@/types/iconConfig';
|
|
5
|
+
export { PdfMultiViewer, PdfRenderer, PdfjsLib };
|
|
6
|
+
export type { I18nData, IconConfig, PDFDocumentProxy, RendererDocumentPosition, };
|