@open-file-viewer/core 0.1.0 → 0.1.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 +102 -0
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# @open-file-viewer/core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic browser file preview core for Open File Viewer.
|
|
4
|
+
|
|
5
|
+
Open File Viewer renders files inside your own DOM container instead of opening a new window. It supports images, PDF, Office documents, audio, video, text/code, archives, email, drawings, CAD, 3D and GIS formats through a plugin-based pipeline.
|
|
6
|
+
|
|
7
|
+
- Website: https://open-file-viewer-workspace.void.app
|
|
8
|
+
- GitHub: https://github.com/xushanpei/open-file-viewer
|
|
9
|
+
- npm: https://www.npmjs.com/package/@open-file-viewer/core
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @open-file-viewer/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
PDF preview requires `pdfjs-dist`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install pdfjs-dist
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {
|
|
27
|
+
createViewer,
|
|
28
|
+
imagePlugin,
|
|
29
|
+
videoPlugin,
|
|
30
|
+
audioPlugin,
|
|
31
|
+
textPlugin,
|
|
32
|
+
pdfPlugin,
|
|
33
|
+
officePlugin,
|
|
34
|
+
archivePlugin,
|
|
35
|
+
emailPlugin,
|
|
36
|
+
drawingPlugin,
|
|
37
|
+
cadPlugin,
|
|
38
|
+
model3dPlugin,
|
|
39
|
+
gisPlugin,
|
|
40
|
+
fallbackPlugin
|
|
41
|
+
} from "@open-file-viewer/core";
|
|
42
|
+
import "@open-file-viewer/core/style.css";
|
|
43
|
+
import pdfWorkerSrc from "pdfjs-dist/build/pdf.worker.mjs?url";
|
|
44
|
+
|
|
45
|
+
const viewer = createViewer({
|
|
46
|
+
container: "#viewer",
|
|
47
|
+
file: fileOrUrl,
|
|
48
|
+
fileName: "contract.pdf",
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "70vh",
|
|
51
|
+
fit: "contain",
|
|
52
|
+
toolbar: true,
|
|
53
|
+
theme: "auto",
|
|
54
|
+
plugins: [
|
|
55
|
+
imagePlugin(),
|
|
56
|
+
videoPlugin(),
|
|
57
|
+
audioPlugin(),
|
|
58
|
+
textPlugin(),
|
|
59
|
+
pdfPlugin({ workerSrc: pdfWorkerSrc }),
|
|
60
|
+
officePlugin(),
|
|
61
|
+
archivePlugin(),
|
|
62
|
+
emailPlugin(),
|
|
63
|
+
drawingPlugin(),
|
|
64
|
+
cadPlugin(),
|
|
65
|
+
model3dPlugin(),
|
|
66
|
+
gisPlugin(),
|
|
67
|
+
fallbackPlugin()
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
viewer.resize();
|
|
72
|
+
viewer.destroy();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Supported Inputs
|
|
76
|
+
|
|
77
|
+
`createViewer` accepts local files and remote sources:
|
|
78
|
+
|
|
79
|
+
- `File`
|
|
80
|
+
- `Blob`
|
|
81
|
+
- URL string
|
|
82
|
+
- `ArrayBuffer`
|
|
83
|
+
- multiple files through `files`
|
|
84
|
+
|
|
85
|
+
## Package Notes
|
|
86
|
+
|
|
87
|
+
Import the stylesheet once in your app:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import "@open-file-viewer/core/style.css";
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
React and Vue adapters are available as separate packages:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install @open-file-viewer/react
|
|
97
|
+
npm install @open-file-viewer/vue
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-file-viewer/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Framework-agnostic browser file preview core.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"homepage": "https://open-file-viewer-workspace.void.app",
|
|
7
8
|
"repository": {
|
|
@@ -26,7 +27,8 @@
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
"files": [
|
|
29
|
-
"dist"
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
30
32
|
],
|
|
31
33
|
"publishConfig": {
|
|
32
34
|
"access": "public"
|