@relevaince/document-viewer 0.1.1 → 0.2.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.d.mts +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +560 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +545 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
package/dist/index.d.mts
CHANGED
|
@@ -10,24 +10,28 @@ type BBox = {
|
|
|
10
10
|
x2: number;
|
|
11
11
|
y2: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* All supported document types. Use `getFileType(url)` when omitted.
|
|
15
|
+
*/
|
|
16
|
+
type ViewerFileType = "pdf" | "docx" | "image" | "json" | "eml";
|
|
13
17
|
/**
|
|
14
18
|
* Describes *what* to show and optionally *where* to focus.
|
|
15
19
|
*
|
|
16
20
|
* Consumers pass a `ViewerTarget` to `<DocumentViewer>` each time
|
|
17
|
-
* the user clicks a citation.
|
|
21
|
+
* the user clicks a citation or opens a document.
|
|
18
22
|
*/
|
|
19
23
|
type ViewerTarget = {
|
|
20
|
-
/** Public URL of the document
|
|
24
|
+
/** Public URL of the document. */
|
|
21
25
|
url: string;
|
|
22
26
|
/** Explicit file type — auto-detected from URL extension when omitted. */
|
|
23
|
-
fileType?:
|
|
24
|
-
/** 1-indexed page to scroll to. */
|
|
27
|
+
fileType?: ViewerFileType;
|
|
28
|
+
/** 1-indexed page to scroll to (PDF). */
|
|
25
29
|
page?: number;
|
|
26
|
-
/** Bounding box to highlight (normalised 0–1 coords). */
|
|
30
|
+
/** Bounding box to highlight (normalised 0–1 coords, PDF). */
|
|
27
31
|
bbox?: BBox;
|
|
28
32
|
/** Cited text snippet — for future text-search highlighting. */
|
|
29
33
|
text?: string;
|
|
30
|
-
/** Display title shown in the viewer
|
|
34
|
+
/** Display title shown in the viewer. */
|
|
31
35
|
title?: string;
|
|
32
36
|
};
|
|
33
37
|
|
|
@@ -70,6 +74,6 @@ declare function DocumentViewer({ target, pdfWorkerUrl, loadingComponent, errorC
|
|
|
70
74
|
* Infer document type from URL extension.
|
|
71
75
|
* Strips query-strings and fragments before matching.
|
|
72
76
|
*/
|
|
73
|
-
declare function getFileType(url: string):
|
|
77
|
+
declare function getFileType(url: string): ViewerFileType | "unknown";
|
|
74
78
|
|
|
75
|
-
export { type BBox, DocumentViewer, type DocumentViewerProps, type ViewerTarget, getFileType };
|
|
79
|
+
export { type BBox, DocumentViewer, type DocumentViewerProps, type ViewerFileType, type ViewerTarget, getFileType };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,24 +10,28 @@ type BBox = {
|
|
|
10
10
|
x2: number;
|
|
11
11
|
y2: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* All supported document types. Use `getFileType(url)` when omitted.
|
|
15
|
+
*/
|
|
16
|
+
type ViewerFileType = "pdf" | "docx" | "image" | "json" | "eml";
|
|
13
17
|
/**
|
|
14
18
|
* Describes *what* to show and optionally *where* to focus.
|
|
15
19
|
*
|
|
16
20
|
* Consumers pass a `ViewerTarget` to `<DocumentViewer>` each time
|
|
17
|
-
* the user clicks a citation.
|
|
21
|
+
* the user clicks a citation or opens a document.
|
|
18
22
|
*/
|
|
19
23
|
type ViewerTarget = {
|
|
20
|
-
/** Public URL of the document
|
|
24
|
+
/** Public URL of the document. */
|
|
21
25
|
url: string;
|
|
22
26
|
/** Explicit file type — auto-detected from URL extension when omitted. */
|
|
23
|
-
fileType?:
|
|
24
|
-
/** 1-indexed page to scroll to. */
|
|
27
|
+
fileType?: ViewerFileType;
|
|
28
|
+
/** 1-indexed page to scroll to (PDF). */
|
|
25
29
|
page?: number;
|
|
26
|
-
/** Bounding box to highlight (normalised 0–1 coords). */
|
|
30
|
+
/** Bounding box to highlight (normalised 0–1 coords, PDF). */
|
|
27
31
|
bbox?: BBox;
|
|
28
32
|
/** Cited text snippet — for future text-search highlighting. */
|
|
29
33
|
text?: string;
|
|
30
|
-
/** Display title shown in the viewer
|
|
34
|
+
/** Display title shown in the viewer. */
|
|
31
35
|
title?: string;
|
|
32
36
|
};
|
|
33
37
|
|
|
@@ -70,6 +74,6 @@ declare function DocumentViewer({ target, pdfWorkerUrl, loadingComponent, errorC
|
|
|
70
74
|
* Infer document type from URL extension.
|
|
71
75
|
* Strips query-strings and fragments before matching.
|
|
72
76
|
*/
|
|
73
|
-
declare function getFileType(url: string):
|
|
77
|
+
declare function getFileType(url: string): ViewerFileType | "unknown";
|
|
74
78
|
|
|
75
|
-
export { type BBox, DocumentViewer, type DocumentViewerProps, type ViewerTarget, getFileType };
|
|
79
|
+
export { type BBox, DocumentViewer, type DocumentViewerProps, type ViewerFileType, type ViewerTarget, getFileType };
|