@open-file-viewer/core 0.1.1 → 0.1.3

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.d.cts CHANGED
@@ -4,6 +4,8 @@ type PreviewSource = File | Blob | string | ArrayBuffer;
4
4
  type PreviewFit = "contain" | "cover" | "width" | "height" | "actual" | "scale-down";
5
5
  type PreviewFallback = "inline" | "download" | "custom";
6
6
  type PreviewTheme = "light" | "dark" | "auto";
7
+ type PreviewToolbarBuiltInAction = "previous" | "next" | "queue" | "zoom-out" | "zoom-in" | "zoom-reset" | "rotate-right" | "download" | "fullscreen" | "print" | "search";
8
+ type PreviewToolbarActionId = PreviewToolbarBuiltInAction | (string & {});
7
9
  interface PreviewFile {
8
10
  source: PreviewSource;
9
11
  name: string;
@@ -29,6 +31,43 @@ interface PreviewToolbarOptions {
29
31
  fullscreen?: boolean;
30
32
  print?: boolean;
31
33
  search?: boolean;
34
+ order?: PreviewToolbarActionId[];
35
+ labels?: Partial<Record<PreviewToolbarBuiltInAction, string>>;
36
+ titles?: Partial<Record<PreviewToolbarBuiltInAction, string>>;
37
+ icons?: Partial<Record<PreviewToolbarBuiltInAction, string | HTMLElement | SVGElement>>;
38
+ actions?: PreviewToolbarCustomAction[];
39
+ render?: (ctx: PreviewToolbarRenderContext) => HTMLElement | void;
40
+ }
41
+ interface PreviewToolbarCustomAction {
42
+ id: string;
43
+ label: string;
44
+ title?: string;
45
+ icon?: string | HTMLElement | SVGElement;
46
+ order?: number;
47
+ disabled?: boolean | ((ctx: PreviewToolbarRenderContext) => boolean);
48
+ hidden?: boolean | ((ctx: PreviewToolbarRenderContext) => boolean);
49
+ className?: string;
50
+ onClick: (ctx: PreviewToolbarRenderContext) => void | Promise<void>;
51
+ }
52
+ interface PreviewToolbarRenderContext {
53
+ file?: PreviewFile;
54
+ index: number;
55
+ length: number;
56
+ viewport: HTMLElement;
57
+ canPrevious: boolean;
58
+ canNext: boolean;
59
+ zoom?: number;
60
+ zoomLabel?: string;
61
+ previous: () => Promise<void>;
62
+ next: () => Promise<void>;
63
+ command: (command: PreviewCommand) => void | boolean | undefined;
64
+ canCommand: (command: PreviewCommand) => boolean;
65
+ setZoom: (zoom?: number) => void;
66
+ download: () => void;
67
+ fullscreen: () => void;
68
+ print: () => void;
69
+ search: (query: string) => number;
70
+ clearSearch: () => void;
32
71
  }
33
72
  interface PreviewOptions {
34
73
  container: HTMLElement | string;
@@ -56,6 +95,7 @@ interface PreviewContext {
56
95
  file: PreviewFile;
57
96
  size: PreviewSize;
58
97
  options: Required<Pick<PreviewOptions, "fit" | "fallback">> & PreviewOptions;
98
+ toolbar?: PreviewToolbarRenderContext;
59
99
  setLoading: (loading: boolean) => void;
60
100
  setError: (error: Error | string) => void;
61
101
  }
@@ -95,6 +135,10 @@ type PdfJsModule = typeof pdfjs_dist;
95
135
  interface PdfPluginOptions {
96
136
  pdfjs?: PdfJsModule;
97
137
  workerSrc?: string;
138
+ cMapUrl?: string;
139
+ cMapPacked?: boolean;
140
+ standardFontDataUrl?: string;
141
+ useSystemFonts?: boolean;
98
142
  }
99
143
  declare function pdfPlugin(options?: PdfJsModule | PdfPluginOptions): PreviewPlugin;
100
144
 
@@ -122,4 +166,4 @@ declare function assetPlugin(): PreviewPlugin;
122
166
 
123
167
  declare function fallbackPlugin(): PreviewPlugin;
124
168
 
125
- export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarOptions, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };
169
+ export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarActionId, type PreviewToolbarBuiltInAction, type PreviewToolbarCustomAction, type PreviewToolbarOptions, type PreviewToolbarRenderContext, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ type PreviewSource = File | Blob | string | ArrayBuffer;
4
4
  type PreviewFit = "contain" | "cover" | "width" | "height" | "actual" | "scale-down";
5
5
  type PreviewFallback = "inline" | "download" | "custom";
6
6
  type PreviewTheme = "light" | "dark" | "auto";
7
+ type PreviewToolbarBuiltInAction = "previous" | "next" | "queue" | "zoom-out" | "zoom-in" | "zoom-reset" | "rotate-right" | "download" | "fullscreen" | "print" | "search";
8
+ type PreviewToolbarActionId = PreviewToolbarBuiltInAction | (string & {});
7
9
  interface PreviewFile {
8
10
  source: PreviewSource;
9
11
  name: string;
@@ -29,6 +31,43 @@ interface PreviewToolbarOptions {
29
31
  fullscreen?: boolean;
30
32
  print?: boolean;
31
33
  search?: boolean;
34
+ order?: PreviewToolbarActionId[];
35
+ labels?: Partial<Record<PreviewToolbarBuiltInAction, string>>;
36
+ titles?: Partial<Record<PreviewToolbarBuiltInAction, string>>;
37
+ icons?: Partial<Record<PreviewToolbarBuiltInAction, string | HTMLElement | SVGElement>>;
38
+ actions?: PreviewToolbarCustomAction[];
39
+ render?: (ctx: PreviewToolbarRenderContext) => HTMLElement | void;
40
+ }
41
+ interface PreviewToolbarCustomAction {
42
+ id: string;
43
+ label: string;
44
+ title?: string;
45
+ icon?: string | HTMLElement | SVGElement;
46
+ order?: number;
47
+ disabled?: boolean | ((ctx: PreviewToolbarRenderContext) => boolean);
48
+ hidden?: boolean | ((ctx: PreviewToolbarRenderContext) => boolean);
49
+ className?: string;
50
+ onClick: (ctx: PreviewToolbarRenderContext) => void | Promise<void>;
51
+ }
52
+ interface PreviewToolbarRenderContext {
53
+ file?: PreviewFile;
54
+ index: number;
55
+ length: number;
56
+ viewport: HTMLElement;
57
+ canPrevious: boolean;
58
+ canNext: boolean;
59
+ zoom?: number;
60
+ zoomLabel?: string;
61
+ previous: () => Promise<void>;
62
+ next: () => Promise<void>;
63
+ command: (command: PreviewCommand) => void | boolean | undefined;
64
+ canCommand: (command: PreviewCommand) => boolean;
65
+ setZoom: (zoom?: number) => void;
66
+ download: () => void;
67
+ fullscreen: () => void;
68
+ print: () => void;
69
+ search: (query: string) => number;
70
+ clearSearch: () => void;
32
71
  }
33
72
  interface PreviewOptions {
34
73
  container: HTMLElement | string;
@@ -56,6 +95,7 @@ interface PreviewContext {
56
95
  file: PreviewFile;
57
96
  size: PreviewSize;
58
97
  options: Required<Pick<PreviewOptions, "fit" | "fallback">> & PreviewOptions;
98
+ toolbar?: PreviewToolbarRenderContext;
59
99
  setLoading: (loading: boolean) => void;
60
100
  setError: (error: Error | string) => void;
61
101
  }
@@ -95,6 +135,10 @@ type PdfJsModule = typeof pdfjs_dist;
95
135
  interface PdfPluginOptions {
96
136
  pdfjs?: PdfJsModule;
97
137
  workerSrc?: string;
138
+ cMapUrl?: string;
139
+ cMapPacked?: boolean;
140
+ standardFontDataUrl?: string;
141
+ useSystemFonts?: boolean;
98
142
  }
99
143
  declare function pdfPlugin(options?: PdfJsModule | PdfPluginOptions): PreviewPlugin;
100
144
 
@@ -122,4 +166,4 @@ declare function assetPlugin(): PreviewPlugin;
122
166
 
123
167
  declare function fallbackPlugin(): PreviewPlugin;
124
168
 
125
- export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarOptions, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };
169
+ export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarActionId, type PreviewToolbarBuiltInAction, type PreviewToolbarCustomAction, type PreviewToolbarOptions, type PreviewToolbarRenderContext, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };