@vue-pdf-viewer/viewer 1.3.0-beta.2 → 1.3.0-beta.21

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.
@@ -1,21 +1,7 @@
1
1
  interface OwnProps {
2
2
  pageIndex: number;
3
3
  searchKeyword: string;
4
- totalPages?: number;
5
4
  }
6
- interface FlagKeyword {
7
- keyword: string;
8
- matchCase?: boolean;
9
- wholeWords?: boolean;
10
- }
11
- type SingleKeyword = string | RegExp | FlagKeyword;
12
- interface NormalizedKeyword {
13
- keyword: string;
14
- regExp: RegExp;
15
- wholeWords: boolean;
16
- }
17
- export declare const normalizeFlagKeyword: (flagKeyword: FlagKeyword) => NormalizedKeyword;
18
- export declare const normalizeSingleKeyword: (keyword: SingleKeyword, matchCase?: boolean, wholeWords?: boolean) => NormalizedKeyword;
19
5
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<OwnProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<OwnProps>>>, {}, {}>;
20
6
  export default _default;
21
7
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,4 +1,4 @@
1
- import type { AnnotationEventPayload, HighlightEventPayload, TextLayerLoadedEventPayload, RotateEvent, ToolbarOptions, Localization } from '@/utils/types';
1
+ import type { AnnotationEventPayload, TextLayerLoadedEventPayload, RotateEvent, ToolbarOptions, Localization } from '@/utils/types';
2
2
  import { ScrollMode, ViewMode, ZoomLevel } from '@/utils/enumerators';
3
3
  import '../style.scss';
4
4
  declare const _default: {
@@ -54,7 +54,6 @@ declare const _default: {
54
54
  readonly default: () => Record<string, Localization>;
55
55
  };
56
56
  }>> & {
57
- onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
58
57
  onTextLoaded?: ((payload: TextLayerLoadedEventPayload) => any) | undefined;
59
58
  onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined;
60
59
  onAnnotationLoaded?: ((payload: any[]) => any) | undefined;
@@ -66,8 +65,6 @@ declare const _default: {
66
65
  goToPage: (page: number) => void;
67
66
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
68
67
  annotation: (payload: AnnotationEventPayload) => void;
69
- } & {
70
- highlight: (payload: HighlightEventPayload) => void;
71
68
  } & {
72
69
  loaded: () => void;
73
70
  } & {
@@ -132,7 +129,6 @@ declare const _default: {
132
129
  readonly default: () => Record<string, Localization>;
133
130
  };
134
131
  }>> & {
135
- onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
136
132
  onTextLoaded?: ((payload: TextLayerLoadedEventPayload) => any) | undefined;
137
133
  onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined;
138
134
  onAnnotationLoaded?: ((payload: any[]) => any) | undefined;
@@ -211,7 +207,6 @@ declare const _default: {
211
207
  readonly default: () => Record<string, Localization>;
212
208
  };
213
209
  }>> & {
214
- onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
215
210
  onTextLoaded?: ((payload: TextLayerLoadedEventPayload) => any) | undefined;
216
211
  onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined;
217
212
  onAnnotationLoaded?: ((payload: any[]) => any) | undefined;
@@ -289,7 +284,6 @@ declare const _default: {
289
284
  readonly default: () => Record<string, Localization>;
290
285
  };
291
286
  }>> & {
292
- onHighlight?: ((payload: HighlightEventPayload) => any) | undefined;
293
287
  onTextLoaded?: ((payload: TextLayerLoadedEventPayload) => any) | undefined;
294
288
  onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined;
295
289
  onAnnotationLoaded?: ((payload: any[]) => any) | undefined;
@@ -301,8 +295,6 @@ declare const _default: {
301
295
  goToPage: (page: number) => void;
302
296
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
303
297
  annotation: (payload: AnnotationEventPayload) => void;
304
- } & {
305
- highlight: (payload: HighlightEventPayload) => void;
306
298
  } & {
307
299
  loaded: () => void;
308
300
  } & {
@@ -2,7 +2,7 @@ import { MaybeRef, UnwrapRef } from 'vue';
2
2
  import { ViewerPdfPage, ViewerState } from '@/utils/types';
3
3
  import { ZoomLevel } from '@/utils/enumerators';
4
4
  export declare function usePdfPageSizes(props: UnwrapRef<ViewerState>, initialScale: MaybeRef<number | ZoomLevel>): {
5
- pdfPages: import("vue").ShallowRef<ViewerPdfPage[]>;
5
+ pdfPages: import("vue").ComputedRef<ViewerPdfPage[]>;
6
6
  actualPdfPages: import("vue").ShallowRef<ViewerPdfPage[]>;
7
7
  defaultScale: import("vue").Ref<number, number>;
8
8
  };
@@ -1,11 +1,11 @@
1
1
  import { Match, PdfPageSize } from '@/components';
2
- import { MaybeRef, Ref, ShallowRef } from 'vue';
2
+ import { Ref, ShallowRef } from 'vue';
3
3
  import type { PDFDocumentProxy } from 'pdfjs-dist';
4
4
  interface MatchValue extends Match {
5
5
  page: number;
6
6
  pageMatchIdx: number;
7
7
  }
8
- export declare const useSearch: (pdfDoc: ShallowRef<PDFDocumentProxy | undefined>, pageSizes: Ref<PdfPageSize[] | undefined>, elementRef: MaybeRef<HTMLElement | undefined>) => {
8
+ export declare const useSearch: (pdfDoc: ShallowRef<PDFDocumentProxy | undefined>, pageSizes: Ref<PdfPageSize[] | undefined>) => {
9
9
  searchValue: Ref<string, string>;
10
10
  matches: Ref<{
11
11
  page: number;
@@ -1,6 +1,7 @@
1
1
  import { ComputedRef, CSSProperties, Ref, StyleValue, UnwrapRef } from 'vue';
2
- import { ViewerPdfPage, ScrollMode, ViewMode } from '..';
3
- export interface UseVirtualListItem<T> {
2
+ import type { ViewerPdfPage, VirtualRange } from '@/utils/types';
3
+ import { ScrollMode, ViewMode } from '@/utils/enumerators';
4
+ interface UseVirtualListItem<T> {
4
5
  data: T;
5
6
  index: number;
6
7
  }
@@ -16,6 +17,8 @@ export interface UseVirtualListReturn {
16
17
  wrapperProps: ComputedRef<{
17
18
  style: CSSProperties;
18
19
  }>;
20
+ range: Ref<VirtualRange>;
21
+ pagesPerRow: Ref<number>;
19
22
  }
20
23
  interface UseVirtualPagesProps {
21
24
  pages: Ref<ViewerPdfPage[]>;
@@ -1,8 +1,8 @@
1
1
  import { type Ref } from 'vue';
2
- import { VisibilityInfo } from '@/utils/types';
2
+ import { VirtualRange, VisibilityInfo } from '@/utils/types';
3
3
  export declare function useVisibilities(totalPages: Ref<number>): {
4
4
  resetVisibility: () => void;
5
5
  updateVisibility: (info: VisibilityInfo) => void;
6
6
  currentPage: Ref<number, number>;
7
- calculateCurrentPage: () => number;
7
+ calculateCurrentPage: (range?: VirtualRange) => number;
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
2
2
  import type { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces';
3
3
  import type { InjectionKey, Slot, Ref, ComponentPublicInstance, ShallowRef } from 'vue';
4
- import type { Destination, HighlightMatchPosition, License, Localization, Offset, ToolbarOptions, ViewerPdfPage } from './utils/types';
4
+ import type { HighlightMatchPosition, License, Localization, NormalizedKeyword, Offset, ToolbarOptions, ViewerPdfPage } from './utils/types';
5
5
  export declare const DEFAULT_TOOLBAR_OPTIONS: ToolbarOptions;
6
6
  export declare const Locales: Record<string, Localization>;
7
7
  export declare const DEFAULT_OFFSET: Offset;
@@ -49,6 +49,8 @@ export declare const FILE_INPUT: InjectionKey<Ref<ComponentPublicInstance<import
49
49
  onChange?: ((file: string) => any) | undefined;
50
50
  onFilenameChange?: ((file: string) => any) | undefined;
51
51
  }, {}, {}>, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}> | undefined>>;
52
+ export declare const EMPTY_KEYWORD_REGEXP: NormalizedKeyword;
53
+ export declare const CURRENT_MATCH_CSS_CLASS = "vpv-highlight__text-current";
52
54
  export declare const LATEST_MATCH_POSITION: InjectionKey<Ref<HighlightMatchPosition | undefined, HighlightMatchPosition | undefined>>;
53
55
  export declare const GET_PAGE: InjectionKey<(doc: PDFDocumentProxy, pageIndex: number) => Promise<PDFPageProxy>>;
54
56
  export declare const VIEWER_STATE: InjectionKey<{
@@ -60,7 +62,7 @@ export declare const VIEWER_STATE: InjectionKey<{
60
62
  scale: number | undefined;
61
63
  rotation: number;
62
64
  }>;
63
- export declare const LATEST_DESTINATION: InjectionKey<Ref<Destination | undefined, Destination | undefined>>;
65
+ export declare const VIEWER_PAGES_PER_ROW: InjectionKey<Ref<number, number>>;
64
66
  export declare const TOOLBAR_OPTIONS: InjectionKey<Ref<ToolbarOptions | undefined, ToolbarOptions | undefined>>;
65
67
  export declare const TOTAL_TOOL_OTHERS_MENU: InjectionKey<Ref<number, number>>;
66
68
  export declare const IS_DARK: InjectionKey<Ref<boolean, boolean>>;
@@ -5,8 +5,8 @@ export declare enum ScrollMode {
5
5
  Wrapped = "Wrapped"
6
6
  }
7
7
  export declare enum ViewMode {
8
- SinglePage = "SinglePage",
9
- DualPage = "DualPage"
8
+ SinglePage = "Single",
9
+ DualPage = "Dual"
10
10
  }
11
11
  export declare enum ZoomLevel {
12
12
  ActualSize = "actualSize",
@@ -0,0 +1,9 @@
1
+ import type { CSSProperties } from 'vue';
2
+ import type { FlagKeyword, HighlightArea, HighlightMatchPosition, NormalizedKeyword, SingleKeyword } from './types';
3
+ export declare const normalizeFlagKeyword: (flagKeyword: FlagKeyword) => NormalizedKeyword;
4
+ export declare const normalizeSingleKeyword: (keyword: SingleKeyword, matchCase?: boolean, wholeWords?: boolean) => NormalizedKeyword;
5
+ export declare const sortHighlightPosition: (a: HighlightArea, b: HighlightArea) => 0 | 1 | -1;
6
+ export declare const getHighlightStyle: (area: HighlightArea) => CSSProperties;
7
+ export declare const unwrap: (ele: Node) => void;
8
+ export declare const getHighlightElement: (layerRef: HTMLElement, query: HighlightMatchPosition) => HTMLElement;
9
+ export declare function scrollHighlightIntoView(highlightEle: HTMLElement, pageContainer: HTMLElement, viewerContainer: HTMLElement): void;
@@ -3,6 +3,10 @@ import type { PageViewport } from 'pdfjs-dist';
3
3
  import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TextContent, TypedArray, PDFPageProxy, PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
4
4
  import type { Metadata } from 'pdfjs-dist/types/src/display/metadata';
5
5
  import { ZoomLevel, ViewMode, ScrollMode, VPVAnnotationType } from './enumerators';
6
+ export interface VirtualRange {
7
+ start: number;
8
+ end: number;
9
+ }
6
10
  export interface Match {
7
11
  start: {
8
12
  idx: number;
@@ -41,6 +45,36 @@ export interface RotateEvent {
41
45
  direction: 'clockwise' | 'counterclockwise';
42
46
  rotate: number;
43
47
  }
48
+ export interface CharacterIndex {
49
+ char: string;
50
+ charIdxInSpan: number;
51
+ spanIdx: number;
52
+ }
53
+ export interface MatchRangeIndex {
54
+ keyword: RegExp;
55
+ startIndex: number;
56
+ endIndex: number;
57
+ }
58
+ export interface FlagKeyword {
59
+ keyword: string;
60
+ matchCase?: boolean;
61
+ wholeWords?: boolean;
62
+ }
63
+ export type SingleKeyword = string | RegExp | FlagKeyword;
64
+ export interface NormalizedKeyword {
65
+ keyword: string;
66
+ regExp: RegExp;
67
+ wholeWords: boolean;
68
+ }
69
+ export interface HighlightArea {
70
+ keywordStr: string;
71
+ left: number;
72
+ top: number;
73
+ height: number;
74
+ width: number;
75
+ pageHeight: number;
76
+ pageWidth: number;
77
+ }
44
78
  export interface HighlightEventPayload {
45
79
  matches: Match[];
46
80
  page: number;
@@ -303,10 +337,6 @@ export interface HighlightMatchPosition {
303
337
  matchIdx: number;
304
338
  pageIdx: number;
305
339
  }
306
- export interface HighlightMatchPosition {
307
- matchIdx: number;
308
- pageIdx: number;
309
- }
310
340
  export type Localization = {
311
341
  searchButtonTooltip: string;
312
342
  searchInputPlaceholder: string;
@@ -0,0 +1,2 @@
1
+ import { Offset } from './types';
2
+ export declare const calculateOffset: (children: HTMLElement, parent: HTMLElement) => Offset;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vue-pdf-viewer/viewer",
3
3
  "private": false,
4
- "version": "1.3.0-beta.2",
4
+ "version": "1.3.0-beta.21",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
7
7
  "module": "./dist/index.js",
@@ -1,36 +0,0 @@
1
- import { Ref, UnwrapRef, CSSProperties } from 'vue';
2
- import { ScrollMode, ViewMode } from '@/utils/enumerators';
3
- import { VirtualItem, Offset, ViewerPdfPage } from '@/utils/types';
4
- export interface VisiblePagesRange {
5
- endPage: number;
6
- numPages: number;
7
- startPage: number;
8
- }
9
- export type SetRenderRange = (visiblePagesRange: VisiblePagesRange) => {
10
- endPage: number;
11
- startPage: number;
12
- };
13
- interface UseVirtualProps {
14
- pages: Ref<ViewerPdfPage[]>;
15
- viewerRef: Ref<HTMLElement | undefined>;
16
- scrollMode: Ref<ScrollMode>;
17
- viewMode: Ref<ViewMode>;
18
- isRtl: boolean;
19
- smoothScroll: Ref<boolean>;
20
- }
21
- export declare const useVirtual: (props: UnwrapRef<UseVirtualProps>) => {
22
- visibilities: import("vue").WritableComputedRef<any[]>;
23
- virtualItems: import("vue").ComputedRef<VirtualItem[]>;
24
- getContainerStyles: () => CSSProperties;
25
- getItemContainerStyles: (item: VirtualItem) => CSSProperties;
26
- getItemStyles: (item: VirtualItem) => CSSProperties;
27
- virtualRangeState: import("vue").ComputedRef<{
28
- startPage: number;
29
- endPage: number;
30
- maxVisibilityIndex: number;
31
- } | undefined>;
32
- isScrolling: Ref<boolean, boolean>;
33
- scrollToItem: (index: number, offset?: Offset) => void;
34
- zoom: (scale: number, index: number) => void;
35
- };
36
- export {};
@@ -1,18 +0,0 @@
1
- import { Ref, UnwrapRef } from 'vue';
2
- import { Offset } from '../utils/types';
3
- import { ScrollDirection, ScrollMode, ViewMode } from '../utils/enumerators';
4
- interface UseScrollReturn {
5
- scrollOffset: Ref<Offset>;
6
- scrollDirection: Ref<ScrollDirection>;
7
- isScrolling: Ref<boolean>;
8
- scrollTo: (target: Offset, smooth?: boolean) => void;
9
- }
10
- interface UseScrollProps {
11
- viewerRef: Ref<HTMLElement | undefined>;
12
- scrollMode: Ref<ScrollMode>;
13
- viewMode: Ref<ViewMode>;
14
- isRtl: boolean;
15
- smooth: Ref<boolean>;
16
- }
17
- export declare const useVirtualScroll: (props: UnwrapRef<UseScrollProps>) => UseScrollReturn;
18
- export {};