@vue-pdf-viewer/viewer 1.2.0-rc.0 → 1.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5455 -4737
- package/dist/index.umd.cjs +11 -11
- package/dist/page-view-dual-DzyLa1r0.js +21 -0
- package/dist/page-view-single-CAQXbP-i.js +21 -0
- package/dist/scrolling-horizontal-D1qDwmpQ.js +23 -0
- package/dist/scrolling-page-lV73lZIc.js +23 -0
- package/dist/scrolling-vertical-DzrChdnV.js +23 -0
- package/dist/scrolling-wrapped-CvhUpxbI.js +23 -0
- package/dist/types/components/LayerCanvas.vue.d.ts +22 -0
- package/dist/types/components/LayerPage.vue.d.ts +30 -0
- package/dist/types/components/{layers/TextLayer.vue.d.ts → LayerText.vue.d.ts} +1 -1
- package/dist/types/components/LayerTextSearchHighlight.vue.d.ts +29 -0
- package/dist/types/components/ToolMenuOthers.vue.d.ts +2 -2
- package/dist/types/components/ToolPrint.vue.d.ts +1 -1
- package/dist/types/components/ToolZoom.vue.d.ts +5 -5
- package/dist/types/components/ToolZoomPercentageMenu.vue.d.ts +3 -3
- package/dist/types/components/VPdfPage.vue.d.ts +2 -2
- package/dist/types/components/VPdfThumbnails.vue.d.ts +1 -1
- package/dist/types/components/VPdfViewer.vue.d.ts +257 -67
- package/dist/types/components/index.d.ts +2 -1
- package/dist/types/components/layers/AnnotationLayer.vue.d.ts +1 -1
- package/dist/types/components/utils/annotations.d.ts +1 -11
- package/dist/types/components/utils/destination.d.ts +1 -1
- package/dist/types/components/utils/highlight.d.ts +1 -1
- package/dist/types/composables/useLicense.d.ts +1 -1
- package/dist/types/composables/usePDF.d.ts +3 -1
- package/dist/types/composables/usePdfPagesSizes.d.ts +8 -0
- package/dist/types/composables/useRenderQueue.d.ts +13 -0
- package/dist/types/composables/useRequestAnimationFrame.d.ts +1 -0
- package/dist/types/composables/useRotation.d.ts +2 -2
- package/dist/types/composables/useSearch.d.ts +12 -21
- package/dist/types/composables/useVirtual.d.ts +36 -0
- package/dist/types/composables/useVirtualPages.d.ts +29 -0
- package/dist/types/composables/useVirtualScroll.d.ts +18 -0
- package/dist/types/const.d.ts +21 -3
- package/dist/types/utils/enumerators.d.ts +35 -0
- package/dist/types/utils/smoothScroll.d.ts +2 -0
- package/dist/types/{components → utils}/types.d.ts +81 -25
- package/dist/types/utils/validators.d.ts +4 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +2 -2
- package/dist/types/composables/useCalculatePages.d.ts +0 -12
package/dist/types/const.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
|
|
2
|
+
import type { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces';
|
|
1
3
|
import type { InjectionKey, Slot, Ref, ComponentPublicInstance, ShallowRef } from 'vue';
|
|
2
|
-
import
|
|
4
|
+
import { Destination, HighlightMatchPosition, License, Localization, Offset, ToolbarOptions, ViewerPdfPage } from './components';
|
|
3
5
|
export declare const DEFAULT_TOOLBAR_OPTIONS: ToolbarOptions;
|
|
4
6
|
export declare const Locales: Record<string, Localization>;
|
|
7
|
+
export declare const DEFAULT_OFFSET: Offset;
|
|
5
8
|
export declare const PERCENTAGE = 100;
|
|
6
9
|
export declare const MIN_ZOOM_SCALE = 0.25;
|
|
7
10
|
export declare const MAX_ZOOM_SCALE = 10;
|
|
8
11
|
export declare const SCROLL_BAR_WIDTH = 20;
|
|
9
|
-
export declare const PAGE_PADDING =
|
|
12
|
+
export declare const PAGE_PADDING = 1;
|
|
13
|
+
export declare const PAGE_OFFSET = 5;
|
|
14
|
+
export declare const LAST_PAGE_OFFSET = 4;
|
|
10
15
|
export declare const FILE_INPUT: InjectionKey<Ref<ComponentPublicInstance<import("vue").DefineComponent<{}, {
|
|
11
16
|
triggerClick: () => void;
|
|
12
17
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -44,11 +49,23 @@ export declare const FILE_INPUT: InjectionKey<Ref<ComponentPublicInstance<import
|
|
|
44
49
|
onChange?: ((file: string) => any) | undefined;
|
|
45
50
|
onFilenameChange?: ((file: string) => any) | undefined;
|
|
46
51
|
}, {}, {}>, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | undefined>>;
|
|
52
|
+
export declare const LATEST_MATCH_POSITION: InjectionKey<Ref<HighlightMatchPosition | undefined, HighlightMatchPosition | undefined>>;
|
|
53
|
+
export declare const GET_PAGE: InjectionKey<(doc: PDFDocumentProxy, pageIndex: number) => Promise<PDFPageProxy>>;
|
|
54
|
+
export declare const VIEWER_STATE: InjectionKey<{
|
|
55
|
+
pdfDocument: PDFDocumentProxy | undefined;
|
|
56
|
+
pagesContainerRef: HTMLElement | undefined;
|
|
57
|
+
pageIndex: number;
|
|
58
|
+
viewMode: import("./components").ViewMode;
|
|
59
|
+
scrollMode: import("./components").ScrollMode;
|
|
60
|
+
scale: number | undefined;
|
|
61
|
+
rotation: number;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const LATEST_DESTINATION: InjectionKey<Ref<Destination | undefined, Destination | undefined>>;
|
|
47
64
|
export declare const TOOLBAR_OPTIONS: InjectionKey<Ref<ToolbarOptions | undefined, ToolbarOptions | undefined>>;
|
|
48
65
|
export declare const TOTAL_TOOL_OTHERS_MENU: InjectionKey<Ref<number, number>>;
|
|
49
66
|
export declare const IS_DARK: InjectionKey<Ref<boolean, boolean>>;
|
|
50
67
|
export declare const IS_MOBILE_VIEW: InjectionKey<Ref<boolean, boolean>>;
|
|
51
|
-
export declare const PAGES_CONTAINER: InjectionKey<ShallowRef<HTMLDivElement |
|
|
68
|
+
export declare const PAGES_CONTAINER: InjectionKey<ShallowRef<HTMLDivElement | undefined>>;
|
|
52
69
|
export declare const pdfPagesKey: InjectionKey<ViewerPdfPage[] | null>;
|
|
53
70
|
export declare const FOCUSED_PAGE_NUMBER: InjectionKey<Ref<number, number>>;
|
|
54
71
|
export declare const ROTATION_DEGREE: InjectionKey<Ref<number, number>>;
|
|
@@ -62,3 +79,4 @@ export declare const SLOT_ICON_DOWNLOAD: InjectionKey<Slot<any> | undefined>;
|
|
|
62
79
|
export declare const SLOT_ICON_PRINT: InjectionKey<Slot<any> | undefined>;
|
|
63
80
|
export declare const SLOT_ICON_FULLSCREEN: InjectionKey<Slot<any> | undefined>;
|
|
64
81
|
export declare const LANG: InjectionKey<Ref<Localization, Localization> | undefined>;
|
|
82
|
+
export declare const FUNC_GO_TO_PAGE: InjectionKey<(page: number) => void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare enum ScrollMode {
|
|
2
|
+
Vertical = "Vertical",
|
|
3
|
+
Horizontal = "Horizontal",
|
|
4
|
+
Page = "Page",
|
|
5
|
+
Wrapped = "Wrapped"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ViewMode {
|
|
8
|
+
SinglePage = "SinglePage",
|
|
9
|
+
DualPage = "DualPage",
|
|
10
|
+
DualPageWithCover = "DualPageWithCover"
|
|
11
|
+
}
|
|
12
|
+
export declare enum ZoomLevel {
|
|
13
|
+
ActualSize = "actualSize",
|
|
14
|
+
PageFit = "pageFit",
|
|
15
|
+
PageWidth = "pageWidth"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ScrollDirection {
|
|
18
|
+
Horizontal = "Horizontal",
|
|
19
|
+
Vertical = "Vertical",
|
|
20
|
+
Both = "Both"
|
|
21
|
+
}
|
|
22
|
+
export declare enum VPVAnnotationType {
|
|
23
|
+
INTERNAL_LINK = "internal-link",
|
|
24
|
+
LINK = "link",
|
|
25
|
+
FILE_ATTACHMENT = "file-attachment",
|
|
26
|
+
FORM_TEXT = "form-text",
|
|
27
|
+
FORM_SELECT = "form-select",
|
|
28
|
+
FORM_CHECKBOX = "form-checkbox",
|
|
29
|
+
FORM_RADIO = "form-radio",
|
|
30
|
+
FORM_BUTTON = "form-button"
|
|
31
|
+
}
|
|
32
|
+
export declare enum LayerRenderStatus {
|
|
33
|
+
PreRender = 0,
|
|
34
|
+
DidRender = 1
|
|
35
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { ExtractPublicPropTypes, MaybeRef, PropType, Ref, ShallowRef } from 'vue';
|
|
1
2
|
import type { PageViewport } from 'pdfjs-dist';
|
|
2
|
-
import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TextContent, TypedArray, PDFPageProxy } from 'pdfjs-dist/types/src/display/api';
|
|
3
|
+
import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TextContent, TypedArray, PDFPageProxy, PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
|
|
3
4
|
import type { Metadata } from 'pdfjs-dist/types/src/display/metadata';
|
|
4
|
-
import { VPVAnnotationType } from './
|
|
5
|
-
import { ExtractPublicPropTypes, MaybeRef, PropType } from 'vue';
|
|
5
|
+
import { ZoomLevel, ViewMode, ScrollMode, VPVAnnotationType } from './enumerators';
|
|
6
6
|
export interface Match {
|
|
7
7
|
start: {
|
|
8
8
|
idx: number;
|
|
@@ -50,6 +50,7 @@ export interface HighlightEventPayload {
|
|
|
50
50
|
export interface TextLayerLoadedEventPayload {
|
|
51
51
|
textDivs: HTMLElement[];
|
|
52
52
|
textContent: TextContent | undefined;
|
|
53
|
+
textLayerRef?: HTMLElement;
|
|
53
54
|
}
|
|
54
55
|
export interface HighlightOptions {
|
|
55
56
|
ignoreCase?: boolean;
|
|
@@ -97,35 +98,30 @@ export interface PDFInfo {
|
|
|
97
98
|
javascript: string[] | null;
|
|
98
99
|
outline: any;
|
|
99
100
|
}
|
|
100
|
-
export interface PageSize {
|
|
101
|
-
height: number;
|
|
102
|
-
width: number;
|
|
103
|
-
rotation: number;
|
|
104
|
-
}
|
|
105
101
|
export interface AppPdfPage {
|
|
106
102
|
page: PDFPageProxy;
|
|
107
103
|
viewport: PageViewport;
|
|
108
104
|
height: number;
|
|
109
105
|
scale: number;
|
|
110
106
|
}
|
|
111
|
-
export interface
|
|
112
|
-
page: PDFPageProxy;
|
|
113
|
-
viewport: PageViewport;
|
|
107
|
+
export interface Rect {
|
|
114
108
|
height: number;
|
|
109
|
+
width: number;
|
|
110
|
+
}
|
|
111
|
+
export interface PdfPageSize {
|
|
112
|
+
rotation: number;
|
|
113
|
+
pageRect: Rect;
|
|
115
114
|
}
|
|
116
115
|
export interface VPVThumbnail {
|
|
117
116
|
page: PDFPageProxy;
|
|
118
117
|
}
|
|
119
|
-
export declare enum ZoomLevel {
|
|
120
|
-
ActualSize = "actualSize",
|
|
121
|
-
PageFit = "pageFit",
|
|
122
|
-
PageWidth = "pageWidth"
|
|
123
|
-
}
|
|
124
118
|
export interface Offset {
|
|
125
119
|
left: number;
|
|
126
120
|
top: number;
|
|
127
121
|
}
|
|
128
|
-
export interface
|
|
122
|
+
export interface ViewerPdfPage {
|
|
123
|
+
page: PDFPageProxy;
|
|
124
|
+
viewport: PageViewport;
|
|
129
125
|
height: number;
|
|
130
126
|
width: number;
|
|
131
127
|
}
|
|
@@ -136,14 +132,37 @@ export interface ItemMeasurement {
|
|
|
136
132
|
end: Offset;
|
|
137
133
|
visibility: number;
|
|
138
134
|
}
|
|
135
|
+
export interface VirtualItem extends ItemMeasurement {
|
|
136
|
+
pdfPage: ViewerPdfPage;
|
|
137
|
+
}
|
|
139
138
|
export type DestinationOffsetFromViewport = (viewportWidth: number, viewportHeight: number) => number;
|
|
140
139
|
export interface Destination {
|
|
140
|
+
pageIndex: number;
|
|
141
141
|
bottomOffset: number | DestinationOffsetFromViewport;
|
|
142
|
-
label?: string;
|
|
143
142
|
leftOffset: number | DestinationOffsetFromViewport;
|
|
144
|
-
|
|
143
|
+
label?: string;
|
|
145
144
|
scaleTo?: number | ZoomLevel;
|
|
146
145
|
}
|
|
146
|
+
export interface PageDimensionsWithSummation {
|
|
147
|
+
pageNumber: number;
|
|
148
|
+
dimension: {
|
|
149
|
+
width: number;
|
|
150
|
+
height: number;
|
|
151
|
+
};
|
|
152
|
+
summation: {
|
|
153
|
+
totalWidth: number;
|
|
154
|
+
totalHeight: number;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface ViewerState {
|
|
158
|
+
pdfDocument: ShallowRef<PDFDocumentProxy | undefined>;
|
|
159
|
+
pagesContainerRef: ShallowRef<HTMLElement | undefined>;
|
|
160
|
+
pageIndex: Ref<number>;
|
|
161
|
+
viewMode: Ref<ViewMode>;
|
|
162
|
+
scrollMode: Ref<ScrollMode>;
|
|
163
|
+
scale: Ref<number | undefined>;
|
|
164
|
+
rotation: Ref<number>;
|
|
165
|
+
}
|
|
147
166
|
export interface ToolbarOptions {
|
|
148
167
|
/**
|
|
149
168
|
* Determines whether the toolbar includes a search functionality.
|
|
@@ -209,12 +228,20 @@ export interface ToolbarOptions {
|
|
|
209
228
|
* Determines whether top page & last page menu are a part of the others dropdown menu.
|
|
210
229
|
*/
|
|
211
230
|
jumpNavigatable: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Indicates whether the viewer's scrolling modes can be toggled via the more options dropdown menu.
|
|
233
|
+
*/
|
|
234
|
+
scrollingSwitchable: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Indicates whether the viewer's page view modes can be toggled via the more options dropdown menu.
|
|
237
|
+
*/
|
|
238
|
+
pageViewSwitchable: boolean;
|
|
212
239
|
}
|
|
213
240
|
export interface License {
|
|
214
241
|
isValidKey: boolean;
|
|
215
242
|
licenseKey: string | null;
|
|
216
243
|
}
|
|
217
|
-
type VPVSrc = Omit<PDFSrc, 'DocumentInitParameters' | 'PDFDataRangeTransport'>;
|
|
244
|
+
export type VPVSrc = Omit<PDFSrc, 'DocumentInitParameters' | 'PDFDataRangeTransport'>;
|
|
218
245
|
export interface VPdfViewerProps {
|
|
219
246
|
src: MaybeRef<VPVSrc>;
|
|
220
247
|
/**
|
|
@@ -230,7 +257,15 @@ export interface VPdfViewerProps {
|
|
|
230
257
|
* The initial zoom level default
|
|
231
258
|
* If unspecified, the initial zoom level is determined by the page dimensions and the width of the container
|
|
232
259
|
*/
|
|
233
|
-
initialScale?: number;
|
|
260
|
+
initialScale?: number | ZoomLevel;
|
|
261
|
+
/**
|
|
262
|
+
* The initial scroll mode of PDF viewer
|
|
263
|
+
*/
|
|
264
|
+
initialScrollMode?: ScrollMode;
|
|
265
|
+
/**
|
|
266
|
+
* The initial viewer mode
|
|
267
|
+
*/
|
|
268
|
+
initialViewMode?: ViewMode;
|
|
234
269
|
/**
|
|
235
270
|
* The initial rotation must be divisible by 90
|
|
236
271
|
*/
|
|
@@ -260,9 +295,17 @@ export interface VPdfViewerProps {
|
|
|
260
295
|
*/
|
|
261
296
|
localization?: Record<string, Localization>;
|
|
262
297
|
}
|
|
298
|
+
export interface HighlightMatchPosition {
|
|
299
|
+
matchIdx: number;
|
|
300
|
+
pageIdx: number;
|
|
301
|
+
}
|
|
302
|
+
export interface HighlightMatchPosition {
|
|
303
|
+
matchIdx: number;
|
|
304
|
+
pageIdx: number;
|
|
305
|
+
}
|
|
263
306
|
export declare const VPVBaseProps: {
|
|
264
307
|
readonly src: {
|
|
265
|
-
readonly type: PropType<string |
|
|
308
|
+
readonly type: PropType<string | VPVSrc>;
|
|
266
309
|
readonly required: true;
|
|
267
310
|
};
|
|
268
311
|
readonly workerUrl: {
|
|
@@ -274,8 +317,18 @@ export declare const VPVBaseProps: {
|
|
|
274
317
|
readonly default: () => number;
|
|
275
318
|
};
|
|
276
319
|
readonly initialScale: {
|
|
277
|
-
readonly type: PropType<number>;
|
|
278
|
-
readonly default:
|
|
320
|
+
readonly type: PropType<number | ZoomLevel>;
|
|
321
|
+
readonly default: () => ZoomLevel;
|
|
322
|
+
};
|
|
323
|
+
readonly initialScrollMode: {
|
|
324
|
+
readonly type: PropType<ScrollMode>;
|
|
325
|
+
readonly default: () => ScrollMode;
|
|
326
|
+
readonly validator: (initialScrollMode: ScrollMode, args: unknown) => boolean;
|
|
327
|
+
};
|
|
328
|
+
readonly initialViewMode: {
|
|
329
|
+
readonly type: PropType<ViewMode>;
|
|
330
|
+
readonly default: () => ViewMode;
|
|
331
|
+
readonly validator: (initialViewMode: ViewMode, args: unknown) => boolean;
|
|
279
332
|
};
|
|
280
333
|
readonly initialRotation: {
|
|
281
334
|
readonly type: PropType<number>;
|
|
@@ -370,4 +423,7 @@ export type Localization = {
|
|
|
370
423
|
dragDropFileMessage: string;
|
|
371
424
|
};
|
|
372
425
|
export type VPdfViewerBasePropsType = ExtractPublicPropTypes<typeof VPVBaseProps>;
|
|
373
|
-
export {
|
|
426
|
+
export interface HighlightMatchPosition {
|
|
427
|
+
matchIdx: number;
|
|
428
|
+
pageIdx: number;
|
|
429
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ScrollMode, ViewMode } from './enumerators';
|
|
2
|
+
import { VPdfViewerProps } from './types';
|
|
3
|
+
export declare function getValidScrollMode(args: Pick<VPdfViewerProps, 'initialViewMode' | 'initialScrollMode'>, warn?: boolean): ScrollMode;
|
|
4
|
+
export declare function getValidViewMode(args: Pick<VPdfViewerProps, 'initialViewMode' | 'initialScrollMode'>, warn?: boolean): ViewMode;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClassValue } from 'clsx';
|
|
2
2
|
import type { PageViewport } from 'pdfjs-dist';
|
|
3
|
+
import { ViewMode, ZoomLevel } from './utils/enumerators';
|
|
3
4
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
4
5
|
export declare function formatNumber(value?: string): string;
|
|
5
6
|
export declare function formatFileSize(bytes: number, decimalPoint?: number): string;
|
|
@@ -10,3 +11,4 @@ export declare const PrintElement: {
|
|
|
10
11
|
print: (elements: HTMLElement[]) => void;
|
|
11
12
|
};
|
|
12
13
|
export declare const dateFormatter: (date: string) => string;
|
|
14
|
+
export declare function calculateScale(container: HTMLElement, pageHeight: number, pageWidth: number, scale: ZoomLevel, viewMode: ViewMode, numPages: number): number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-pdf-viewer/viewer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"eslint-plugin-prettier": "^5.1.3",
|
|
89
89
|
"eslint-plugin-vue": "^9.25.0",
|
|
90
90
|
"happy-dom": "^14.7.1",
|
|
91
|
-
"husky": "^9.
|
|
91
|
+
"husky": "^9.1.4",
|
|
92
92
|
"jest": "^29.7.0",
|
|
93
93
|
"jsdom": "^24.0.0",
|
|
94
94
|
"lint-staged": "^15.2.5",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MaybeRef, ShallowRef, UnwrapNestedRefs } from 'vue';
|
|
2
|
-
import { ViewerPdfPage } from '@/components/types';
|
|
3
|
-
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
4
|
-
export interface UseCalculatePagesDto {
|
|
5
|
-
pdfDocument: ShallowRef<PDFDocumentProxy | undefined>;
|
|
6
|
-
rootPagesContainer: ShallowRef<HTMLDivElement | null>;
|
|
7
|
-
scale?: MaybeRef<number>;
|
|
8
|
-
rotation?: MaybeRef<number>;
|
|
9
|
-
}
|
|
10
|
-
export declare function useCalculatePages(props: UnwrapNestedRefs<UseCalculatePagesDto>): {
|
|
11
|
-
pdfPages: ShallowRef<ViewerPdfPage[]>;
|
|
12
|
-
};
|