@file-viewer/vue3 3.2.2 → 3.3.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/README.en.md +3 -1
- package/README.md +238 -239
- package/README.zh-CN.md +465 -0
- package/dist/components/export2.js +458 -425
- package/dist/components/image.js +130 -64
- package/dist/index.mjs +1143 -1098
- package/dist/src/package/components/FileViewer/hooks/useViewerSourceLoading.d.ts +2 -1
- package/dist/src/package/components/FileViewer/hooks/useViewerToolbar.d.ts +1 -0
- package/dist/vue3.css +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @file-viewer/vue3
|
|
2
2
|
|
|
3
|
+
[English](https://github.com/flyfish-dev/file-viewer/blob/main/packages/components/vue3/README.md) · [简体中文](https://github.com/flyfish-dev/file-viewer/blob/main/packages/components/vue3/README.zh-CN.md)
|
|
4
|
+
|
|
3
5
|
<!-- FILE_VIEWER_PACKAGE_HEADER -->
|
|
4
6
|
<p>
|
|
5
7
|
<a href="https://www.npmjs.com/package/@file-viewer/vue3"><img src="https://img.shields.io/npm/v/@file-viewer%2Fvue3?logo=npm" alt="npm version"></a>
|
|
@@ -9,16 +11,16 @@
|
|
|
9
11
|
</p>
|
|
10
12
|
|
|
11
13
|
<p>
|
|
12
|
-
<a href="https://github.com/flyfish-dev/file-viewer">GitHub</a> · <a href="https://doc.file-viewer.app/
|
|
14
|
+
<a href="https://github.com/flyfish-dev/file-viewer">GitHub</a> · <a href="https://doc.file-viewer.app/">Docs</a> · <a href="https://demo.file-viewer.app/">Live demo</a> · <a href="https://doc.file-viewer.app/guide/formats">Format matrix</a> · <a href="https://github.com/flyfish-dev/file-viewer/issues">Issues</a> · <a href="https://github.com/flyfish-dev/file-viewer/blob/main/packages/components/vue3/README.zh-CN.md">简体中文</a>
|
|
13
15
|
</p>
|
|
14
16
|
|
|
15
17
|
<p>
|
|
16
|
-
<a href="https://demo.file-viewer.app/"><img src="https://raw.githubusercontent.com/flyfish-dev/file-viewer/main/docs/public/_media/file-viewer-demo-v3-
|
|
18
|
+
<a href="https://demo.file-viewer.app/"><img src="https://raw.githubusercontent.com/flyfish-dev/file-viewer/main/docs/public/_media/file-viewer-demo-v3-en.webp" width="760" alt="File Viewer live demo: Word, Excel, PowerPoint, 3D model, CAD drawing and binary inspector"></a>
|
|
17
19
|
</p>
|
|
18
20
|
|
|
19
|
-
> ⭐
|
|
21
|
+
> ⭐ If File Viewer helps you, please [star the repo on GitHub](https://github.com/flyfish-dev/file-viewer).
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
The standard Vue 3 native component package for Flyfish File Viewer. It owns the Vue 3 component lifecycle and local controller while consuming the shared `@file-viewer/core` contracts and core browser engine. It exposes plugin install, component props, lifecycle events, search, zoom, print, export, and document-location ref APIs.
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
26
|
npm install vue @file-viewer/vue3
|
|
@@ -50,100 +52,97 @@ createApp(App).use(FileViewer).mount('#app')
|
|
|
50
52
|
</template>
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Vue3 组件会跟随宿主生命周期自动释放资源。放在 Element Plus `el-dialog destroy-on-close`、`v-if`、路由页签或抽屉中时,组件卸载会取消当前加载、销毁 renderer session、清空预览 DOM,并触发 `unload-complete`,`reason` 为 `component-unmount`。如果弹窗只是隐藏组件,例如 `v-show` 或未开启 `destroy-on-close`,预览器会继续保留当前文档;需要主动释放时可通过模板 `ref` 调用 `viewerRef.value?.destroy()`。
|
|
56
|
-
|
|
57
|
-
PPTX 图表同样遵循这套生命周期。图表会绑定当前预览根节点(包括 Shadow DOM);组件卸载、主动 `destroy()`、切换文件或幻灯片窗口回收时都会销毁图表实例,不会向 `document.body` 泄漏图表 DOM。
|
|
55
|
+
The component instance exposes `destroy()`, `downloadOriginalFile()`, `printRenderedHtml()`, `exportRenderedHtml()`, `zoomIn()`, `zoomOut()`, `resetZoom()`, `searchDocument()`, `clearDocumentSearch()`, `nextSearchResult()`, `previousSearchResult()`, `collectDocumentAnchors()`, `scrollToAnchor()`, `scrollToLine()`, and `getDocumentTextChunks()`. The historical packages `@flyfish-group/file-viewer3` and `file-viewer3` remain supported for compatibility with existing projects; new integrations should prefer the standard component package package `@file-viewer/vue3`.
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
The Vue 3 component follows host lifecycle teardown. Inside Element Plus `el-dialog destroy-on-close`, `v-if`, route tabs, or drawers, unmounting the component cancels active loading, destroys the renderer session, clears the rendered DOM, and emits `unload-complete` with `reason: "component-unmount"`. If a dialog only hides the component, such as `v-show` or no `destroy-on-close`, the active document stays mounted. For explicit cleanup while keeping the surrounding component alive, call `viewerRef.value?.destroy()` through the template ref.
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
PPTX charts follow the same lifecycle. They stay bound to the active viewer root, including Shadow DOM, and their chart instances are destroyed on component unmount, explicit `destroy()`, source replacement, or slide-window eviction. No chart nodes are left under `document.body`.
|
|
62
60
|
|
|
61
|
+
## Capabilities
|
|
63
62
|
|
|
64
|
-
|
|
63
|
+
`@file-viewer/vue3` shares the same `@file-viewer/core` contracts with the Pure Web, Vue 2, React, jQuery, and Svelte standard component packages. It supports PDF, Word, Excel, PowerPoint, OFD, CAD/DWG/DXF/DWF, EPUB/UMD, archives, email, Markdown, highlighted code, images, audio, video, 3D models, geospatial files, and structured data assets. See the complete format matrix and option reference at https://doc.file-viewer.app/guide/formats
|
|
65
64
|
|
|
66
65
|
<!-- FILE_VIEWER_GENERATED:START -->
|
|
67
|
-
##
|
|
66
|
+
## Ecosystem Matrix
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
Every standard component package shares `@file-viewer/core` as the only common foundation, and no framework component package depends on another framework implementation. Core owns format metadata, source loading, the renderer protocol, events, operation APIs, search, zoom, print, export, and the framework-neutral browser shell. Heavy PDF, Word, PPT/PPTX, CAD, Typst, and similar pipelines are assembled explicitly through renderer packages or presets; each framework package owns its component lifecycle, type exports, compatibility defaults, and ecosystem-specific interaction layer.
|
|
70
69
|
|
|
71
|
-
|
|
|
70
|
+
| Framework | Standard npm package | Entrypoints | GitHub | Gitee | Historical aliases |
|
|
72
71
|
| --- | --- | --- | --- | --- | --- |
|
|
73
|
-
| Vanilla JS / Pure Web | `@file-viewer/web` | ESM,
|
|
74
|
-
| Vanilla JS / Pure Web Full | `@file-viewer/web-full` | ESM,
|
|
75
|
-
| Vue 3 | `@file-viewer/vue3` | ESM,
|
|
76
|
-
| Vue 3 Full | `@file-viewer/vue3-full` | ESM,
|
|
77
|
-
| Vue 2.7 | `@file-viewer/vue2.7` | ESM,
|
|
78
|
-
| Vue 2.7 Full | `@file-viewer/vue2.7-full` | ESM,
|
|
79
|
-
| Vue 2.6 | `@file-viewer/vue2.6` | ESM,
|
|
80
|
-
| Vue 2.6 Full | `@file-viewer/vue2.6-full` | ESM,
|
|
81
|
-
| React 18/19 | `@file-viewer/react` | ESM,
|
|
82
|
-
| React 18/19 Full | `@file-viewer/react-full` | ESM,
|
|
83
|
-
| React 16.8/17 | `@file-viewer/react-legacy` | ESM,
|
|
84
|
-
| React 16.8/17 Full | `@file-viewer/react-legacy-full` | ESM,
|
|
85
|
-
| jQuery | `@file-viewer/jquery` | ESM,
|
|
86
|
-
| jQuery Full | `@file-viewer/jquery-full` | ESM,
|
|
87
|
-
| Svelte | `@file-viewer/svelte` | Svelte
|
|
88
|
-
| Svelte Full | `@file-viewer/svelte-full` | Svelte
|
|
89
|
-
|
|
90
|
-
##
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
|
72
|
+
| Vanilla JS / Pure Web | `@file-viewer/web` | ESM, type declarations, script tag IIFE, RequireJS AMD | [file-viewer-web](https://github.com/flyfish-dev/file-viewer-web) | [file-viewer-web](https://gitee.com/flyfish-dev/file-viewer-web) | `@flyfish-group/file-viewer-web` |
|
|
73
|
+
| Vanilla JS / Pure Web Full | `@file-viewer/web-full` | ESM, type declarations, script tag IIFE, RequireJS AMD | [file-viewer-web-full](https://github.com/flyfish-dev/file-viewer-web-full) | [file-viewer-web-full](https://gitee.com/flyfish-dev/file-viewer-web-full) | none |
|
|
74
|
+
| Vue 3 | `@file-viewer/vue3` | ESM, type declarations | [file-viewer-vue3](https://github.com/flyfish-dev/file-viewer-vue3) | [file-viewer-vue3](https://gitee.com/flyfish-dev/file-viewer-vue3) | `@flyfish-group/file-viewer3`, `file-viewer3` |
|
|
75
|
+
| Vue 3 Full | `@file-viewer/vue3-full` | ESM, type declarations | [file-viewer-vue3-full](https://github.com/flyfish-dev/file-viewer-vue3-full) | [file-viewer-vue3-full](https://gitee.com/flyfish-dev/file-viewer-vue3-full) | none |
|
|
76
|
+
| Vue 2.7 | `@file-viewer/vue2.7` | ESM, type declarations | [file-viewer-vue2.7](https://github.com/flyfish-dev/file-viewer-vue2.7) | [file-viewer-vue2.7](https://gitee.com/flyfish-dev/file-viewer-vue2.7) | `@flyfish-group/file-viewer` |
|
|
77
|
+
| Vue 2.7 Full | `@file-viewer/vue2.7-full` | ESM, type declarations | [file-viewer-vue2.7-full](https://github.com/flyfish-dev/file-viewer-vue2.7-full) | [file-viewer-vue2.7-full](https://gitee.com/flyfish-dev/file-viewer-vue2.7-full) | none |
|
|
78
|
+
| Vue 2.6 | `@file-viewer/vue2.6` | ESM, type declarations | [file-viewer-vue2.6](https://github.com/flyfish-dev/file-viewer-vue2.6) | [file-viewer-vue2.6](https://gitee.com/flyfish-dev/file-viewer-vue2.6) | none |
|
|
79
|
+
| Vue 2.6 Full | `@file-viewer/vue2.6-full` | ESM, type declarations | [file-viewer-vue2.6-full](https://github.com/flyfish-dev/file-viewer-vue2.6-full) | [file-viewer-vue2.6-full](https://gitee.com/flyfish-dev/file-viewer-vue2.6-full) | none |
|
|
80
|
+
| React 18/19 | `@file-viewer/react` | ESM, type declarations | [file-viewer-react](https://github.com/flyfish-dev/file-viewer-react) | [file-viewer-react](https://gitee.com/flyfish-dev/file-viewer-react) | `@flyfish-group/file-viewer-react` |
|
|
81
|
+
| React 18/19 Full | `@file-viewer/react-full` | ESM, type declarations | [file-viewer-react-full](https://github.com/flyfish-dev/file-viewer-react-full) | [file-viewer-react-full](https://gitee.com/flyfish-dev/file-viewer-react-full) | none |
|
|
82
|
+
| React 16.8/17 | `@file-viewer/react-legacy` | ESM, type declarations | [file-viewer-react-legacy](https://github.com/flyfish-dev/file-viewer-react-legacy) | [file-viewer-react-legacy](https://gitee.com/flyfish-dev/file-viewer-react-legacy) | none |
|
|
83
|
+
| React 16.8/17 Full | `@file-viewer/react-legacy-full` | ESM, type declarations | [file-viewer-react-legacy-full](https://github.com/flyfish-dev/file-viewer-react-legacy-full) | [file-viewer-react-legacy-full](https://gitee.com/flyfish-dev/file-viewer-react-legacy-full) | none |
|
|
84
|
+
| jQuery | `@file-viewer/jquery` | ESM, type declarations | [file-viewer-jquery](https://github.com/flyfish-dev/file-viewer-jquery) | [file-viewer-jquery](https://gitee.com/flyfish-dev/file-viewer-jquery) | none |
|
|
85
|
+
| jQuery Full | `@file-viewer/jquery-full` | ESM, type declarations | [file-viewer-jquery-full](https://github.com/flyfish-dev/file-viewer-jquery-full) | [file-viewer-jquery-full](https://gitee.com/flyfish-dev/file-viewer-jquery-full) | none |
|
|
86
|
+
| Svelte | `@file-viewer/svelte` | Svelte component, ESM, type declarations | [file-viewer-svelte](https://github.com/flyfish-dev/file-viewer-svelte) | [file-viewer-svelte](https://gitee.com/flyfish-dev/file-viewer-svelte) | none |
|
|
87
|
+
| Svelte Full | `@file-viewer/svelte-full` | Svelte component, ESM, type declarations | [file-viewer-svelte-full](https://github.com/flyfish-dev/file-viewer-svelte-full) | [file-viewer-svelte-full](https://gitee.com/flyfish-dev/file-viewer-svelte-full) | none |
|
|
88
|
+
|
|
89
|
+
## Format Support Matrix
|
|
90
|
+
|
|
91
|
+
The shared catalog registers 275 file extensions (225 stable and 50 experimental) across 47 preview pipelines. Experimental formats do not count toward stable support; full capability is assembled through renderer packages or presets.
|
|
92
|
+
|
|
93
|
+
| Preview pipeline | Category | Extensions | Level / status | Capabilities | Loading |
|
|
95
94
|
| --- | --- | --- | --- | --- | --- |
|
|
96
|
-
| Word OpenXML | office | `.docx`, `.docm`, `.dotx`, `.dotm` | high-fidelity / stable |
|
|
97
|
-
| Word Binary | office | `.doc`, `.dot` | structured / stable |
|
|
98
|
-
| PowerPoint 97–2003 | office | `.ppt`, `.pot` | structured / stable |
|
|
99
|
-
| PowerPoint OpenXML | office | `.pptx`, `.pptm`, `.potx`, `.potm`, `.ppsx`, `.ppsm` | high-fidelity / stable |
|
|
100
|
-
| Open Document | office | `.rtf`, `.odt`, `.odp` | structured / stable |
|
|
101
|
-
| Spreadsheet | office | `.xlsx`, `.xltx`, `.xlsm`, `.xlsb`, `.xls`, `.xlt`, `.xla`, `.xlam`, `.xltm`, `.csv`, `.tsv`, `.ods`, `.fods` | structured / stable |
|
|
102
|
-
| Apple Pages | office | `.pages` | high-fidelity / stable |
|
|
103
|
-
| Apple Numbers | office | `.numbers` | high-fidelity / stable |
|
|
104
|
-
| Apple Keynote | office | `.key` | high-fidelity / stable |
|
|
105
|
-
| WordPerfect | office | `.wpd`, `.wp`, `.wp5`, `.wp6` | structured / stable |
|
|
106
|
-
| dBASE Table | office | `.dbf` | structured / stable |
|
|
107
|
-
| PDF | document | `.pdf` | high-fidelity / stable |
|
|
108
|
-
| OFD | document | `.ofd` | structured / stable |
|
|
109
|
-
| Hancom Hangul | office | `.hwp`, `.hwpx` | structured / stable |
|
|
110
|
-
| Typst | document | `.typ`, `.typst` | high-fidelity / stable |
|
|
111
|
-
| Archive | archive | `.zip`, `.zipx`, `.7z`, `.rar`, `.tar`, `.gz`, `.gzip`, `.tgz`, `.bz2`, `.bzip2`, `.tbz`, `.tbz2`, `.xz`, `.txz`, `.lzma`, `.zst`, `.tzst`, `.cab`, `.ar`, `.cpio`, `.iso`, `.xar`, `.lha`, `.lzh`, `.jar`, `.war`, `.ear`, `.apk`, `.cbz`, `.cbr` | structured / stable |
|
|
112
|
-
| Compiled HTML Help | ebook | `.chm` | structured / stable |
|
|
113
|
-
| Email | email | `.eml`, `.msg`, `.mbox` | structured / stable |
|
|
114
|
-
| EDA | eda | `.olb`, `.dra`, `.gds`, `.oas`, `.oasis` | structured / stable |
|
|
115
|
-
| CAD | cad | `.dxf`, `.dwg`, `.dwf`, `.dwfx`, `.xps` | high-fidelity / stable |
|
|
116
|
-
| 3D Model | model | `.glb`, `.gltf`, `.obj`, `.stl`, `.ply`, `.fbx`, `.dae`, `.3ds`, `.3mf`, `.amf`, `.usd`, `.usda`, `.usdc`, `.usdz`, `.kmz`, `.step`, `.stp`, `.iges`, `.igs`, `.ifc`, `.3dm`, `.brep`, `.pcd`, `.wrl`, `.vrml`, `.xyz`, `.vtk`, `.vtp` | structured / stable |
|
|
117
|
-
| Geospatial | geo | `.geojson`, `.kml`, `.gpx`, `.shp` | structured / stable |
|
|
118
|
-
| Drawing | drawing | `.excalidraw`, `.drawio`, `.dio`, `.mermaid`, `.mmd`, `.plantuml`, `.puml` | structured / stable |
|
|
119
|
-
| BPMN 2.0 | drawing | `.bpmn` | structured / experimental |
|
|
120
|
-
| Mind Map | mindmap | `.xmind` | structured / stable |
|
|
121
|
-
| EPUB | ebook | `.epub` | high-fidelity / stable |
|
|
122
|
-
| FictionBook | ebook | `.fb2` | structured / stable |
|
|
123
|
-
| UMD | ebook | `.umd` | structured / stable |
|
|
124
|
-
| Image | image | `.gif`, `.jpg`, `.jpeg`, `.bmp`, `.tiff`, `.tif`, `.png`, `.svg`, `.webp`, `.avif`, `.ico`, `.heic`, `.heif`, `.jxl` | high-fidelity / stable |
|
|
125
|
-
| DICOM | medical-image | `.dcm`, `.dicom` | basic / experimental |
|
|
126
|
-
| Digital signatures and evidence containers | cryptographic-container | `.p7m`, `.p7s`, `.p7c`, `.p7b`, `.pkcs7`, `.cms`, `.cmsc`, `.tsd`, `.tst`, `.tsq`, `.tsr`, `.asics`, `.scs`, `.asice`, `.sce`, `.ers`, `.asc`, `.sig`, `.pgp`, `.gpg`, `.jws` | structured / experimental |
|
|
127
|
-
| Markdown | markdown | `.md`, `.markdown` | structured / stable |
|
|
128
|
-
| Code and Text | code | `.txt`, `.lrc`, `.json`, `.js`, `.mjs`, `.cjs`, `.css`, `.java`, `.py`, `.html`, `.htm`, `.jsx`, `.ts`, `.tsx`, `.xml`, `.log`, `.vue`, `.yaml`, `.yml`, `.ini`, `.sh`, `.bash`, `.sql`, `.go`, `.rs`, `.php`, `.c`, `.cpp`, `.cc`, `.h`, `.hpp`, `.cs`, `.diff`, `.patch`, `.bundle`, `.bdl`, `.jsonc`, `.json5`, `.ipynb`, `.toml`, `.proto`, `.hcl`, `.tex`, `.gv`, `.http`, `.react`, `.rb`, `.swift`, `.kt` | structured / stable |
|
|
129
|
-
| Video | media | `.mp4`, `.webm`, `.m3u8` | high-fidelity / stable |
|
|
130
|
-
| Audio | media | `.mp3`, `.mpeg`, `.wav`, `.ogg`, `.oga`, `.opus`, `.m4a`, `.aac`, `.flac`, `.weba`, `.midi`, `.mid` | high-fidelity / stable |
|
|
131
|
-
| Adobe Photoshop | asset | `.psb`, `.pdd`, `.psdt`, `.psd
|
|
132
|
-
| Adobe Illustrator AI/AIT | asset | `.ait`, `.ai
|
|
133
|
-
| Adobe InDesign IDML | asset | `.idml` | experimental / experimental |
|
|
134
|
-
| Adobe InCopy and InDesign Exchange | asset | `.icml`, `.idms`, `.inx` | structured / experimental |
|
|
135
|
-
| Adobe Animate XFL | asset | `.fla`, `.xfl` | structured / experimental |
|
|
136
|
-
| Adobe XD Package | asset | `.xd` | structured / experimental |
|
|
137
|
-
| Adobe InDesign Native | asset | `.indd`, `.indt` | structured / experimental |
|
|
138
|
-
| Adobe EPS and PostScript | asset | `.ps`, `.eps
|
|
139
|
-
| Adobe Color Palettes | asset | `.ase`, `.aco` | structured / stable |
|
|
140
|
-
| Adobe Photoshop Resources and Presets | asset | `.abr`, `.csh`, `.pat`, `.grd`, `.asl` | structured / experimental |
|
|
141
|
-
| Data Asset | asset | `.ttf`, `.otf`, `.woff`, `.woff2`, `.psd`, `.ai`, `.eps`, `.sqlite`, `.wasm`, `.parquet`, `.avro`, `.webarchive` | structured / stable |
|
|
142
|
-
| Binary Inspector | asset | `.bin`, `.hex`, `.elf`, `.exe`, `.dll`, `.class`, `.macho` | structured / experimental |
|
|
143
|
-
|
|
144
|
-
##
|
|
145
|
-
|
|
146
|
-
|
|
95
|
+
| Word OpenXML | office | `.docx`, `.docm`, `.dotx`, `.dotm` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
96
|
+
| Word Binary | office | `.doc`, `.dot` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
97
|
+
| PowerPoint 97–2003 | office | `.ppt`, `.pot` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider) | lazy async |
|
|
98
|
+
| PowerPoint OpenXML | office | `.pptx`, `.pptm`, `.potx`, `.potm`, `.ppsx`, `.ppsm` | high-fidelity / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
99
|
+
| Open Document | office | `.rtf`, `.odt`, `.odp` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
100
|
+
| Spreadsheet | office | `.xlsx`, `.xltx`, `.xlsm`, `.xlsb`, `.xls`, `.xlt`, `.xla`, `.xlam`, `.xltm`, `.csv`, `.tsv`, `.ods`, `.fods` | structured / stable | download, zoom(provider), search | lazy async |
|
|
101
|
+
| Apple Pages | office | `.pages` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
102
|
+
| Apple Numbers | office | `.numbers` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
103
|
+
| Apple Keynote | office | `.key` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
104
|
+
| WordPerfect | office | `.wpd`, `.wp`, `.wp5`, `.wp6` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
105
|
+
| dBASE Table | office | `.dbf` | structured / stable | download, zoom(provider), search | lazy async |
|
|
106
|
+
| PDF | document | `.pdf` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search(provider) | lazy async |
|
|
107
|
+
| OFD | document | `.ofd` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
108
|
+
| Hancom Hangul | office | `.hwp`, `.hwpx` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
109
|
+
| Typst | document | `.typ`, `.typst` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
|
|
110
|
+
| Archive | archive | `.zip`, `.zipx`, `.7z`, `.rar`, `.tar`, `.gz`, `.gzip`, `.tgz`, `.bz2`, `.bzip2`, `.tbz`, `.tbz2`, `.xz`, `.txz`, `.lzma`, `.zst`, `.tzst`, `.cab`, `.ar`, `.cpio`, `.iso`, `.xar`, `.lha`, `.lzh`, `.jar`, `.war`, `.ear`, `.apk`, `.cbz`, `.cbr` | structured / stable | download, search | lazy async |
|
|
111
|
+
| Compiled HTML Help | ebook | `.chm` | structured / stable | download, print(adapter), HTML export(adapter), search | lazy async |
|
|
112
|
+
| Email | email | `.eml`, `.msg`, `.mbox` | structured / stable | download, HTML export, search | lazy async |
|
|
113
|
+
| EDA | eda | `.olb`, `.dra`, `.gds`, `.oas`, `.oasis` | structured / stable | download, print, HTML export, search | lazy async |
|
|
114
|
+
| CAD | cad | `.dxf`, `.dwg`, `.dwf`, `.dwfx`, `.xps` | high-fidelity / stable | download, print, HTML export, zoom(provider) | lazy async |
|
|
115
|
+
| 3D Model | model | `.glb`, `.gltf`, `.obj`, `.stl`, `.ply`, `.fbx`, `.dae`, `.3ds`, `.3mf`, `.amf`, `.usd`, `.usda`, `.usdc`, `.usdz`, `.kmz`, `.step`, `.stp`, `.iges`, `.igs`, `.ifc`, `.3dm`, `.brep`, `.pcd`, `.wrl`, `.vrml`, `.xyz`, `.vtk`, `.vtp` | structured / stable | download, zoom(provider) | lazy async |
|
|
116
|
+
| Geospatial | geo | `.geojson`, `.kml`, `.gpx`, `.shp` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
117
|
+
| Drawing | drawing | `.excalidraw`, `.drawio`, `.dio`, `.mermaid`, `.mmd`, `.plantuml`, `.puml` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
118
|
+
| BPMN 2.0 | drawing | `.bpmn` | structured / experimental | download, zoom(provider) | lazy async |
|
|
119
|
+
| Mind Map | mindmap | `.xmind` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
120
|
+
| EPUB | ebook | `.epub` | high-fidelity / stable | download, HTML export, search(provider) | lazy async |
|
|
121
|
+
| FictionBook | ebook | `.fb2` | structured / stable | download, print, HTML export, search | lazy async |
|
|
122
|
+
| UMD | ebook | `.umd` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
|
|
123
|
+
| Image | image | `.gif`, `.jpg`, `.jpeg`, `.bmp`, `.tiff`, `.tif`, `.png`, `.svg`, `.webp`, `.avif`, `.ico`, `.heic`, `.heif`, `.jxl` | high-fidelity / stable | download, print, HTML export, zoom(provider) | lazy async |
|
|
124
|
+
| DICOM | medical-image | `.dcm`, `.dicom` | basic / experimental | download, zoom(provider) | lazy async |
|
|
125
|
+
| Digital signatures and evidence containers | cryptographic-container | `.p7m`, `.p7s`, `.p7c`, `.p7b`, `.pkcs7`, `.cms`, `.cmsc`, `.tsd`, `.tst`, `.tsq`, `.tsr`, `.asics`, `.scs`, `.asice`, `.sce`, `.ers`, `.asc`, `.sig`, `.pgp`, `.gpg`, `.jws` | structured / experimental | download | lazy async |
|
|
126
|
+
| Markdown | markdown | `.md`, `.markdown` | structured / stable | download, print, HTML export, search | lazy async |
|
|
127
|
+
| Code and Text | code | `.txt`, `.lrc`, `.json`, `.js`, `.mjs`, `.cjs`, `.css`, `.java`, `.py`, `.html`, `.htm`, `.jsx`, `.ts`, `.tsx`, `.xml`, `.log`, `.vue`, `.yaml`, `.yml`, `.ini`, `.sh`, `.bash`, `.sql`, `.go`, `.rs`, `.php`, `.c`, `.cpp`, `.cc`, `.h`, `.hpp`, `.cs`, `.diff`, `.patch`, `.bundle`, `.bdl`, `.jsonc`, `.json5`, `.ipynb`, `.toml`, `.proto`, `.hcl`, `.tex`, `.gv`, `.http`, `.react`, `.rb`, `.swift`, `.kt` | structured / stable | download, print, HTML export, search | lazy async |
|
|
128
|
+
| Video | media | `.mp4`, `.webm`, `.m3u8` | high-fidelity / stable | download | lazy async |
|
|
129
|
+
| Audio | media | `.mp3`, `.mpeg`, `.wav`, `.ogg`, `.oga`, `.opus`, `.m4a`, `.aac`, `.flac`, `.weba`, `.midi`, `.mid` | high-fidelity / stable | download | lazy async |
|
|
130
|
+
| Adobe Photoshop | asset | `.psb`, `.pdd`, `.psdt`, `.psd` (enhances `data-asset`) | experimental / experimental | download, print, zoom | lazy async |
|
|
131
|
+
| Adobe Illustrator AI/AIT | asset | `.ait`, `.ai` (enhances `data-asset`) | experimental / experimental | download, print, zoom, search | lazy async |
|
|
132
|
+
| Adobe InDesign IDML | asset | `.idml` | experimental / experimental | download, print, zoom | lazy async |
|
|
133
|
+
| Adobe InCopy and InDesign Exchange | asset | `.icml`, `.idms`, `.inx` | structured / experimental | download, print, HTML export, search | lazy async |
|
|
134
|
+
| Adobe Animate XFL | asset | `.fla`, `.xfl` | structured / experimental | download | lazy async |
|
|
135
|
+
| Adobe XD Package | asset | `.xd` | structured / experimental | download | lazy async |
|
|
136
|
+
| Adobe InDesign Native | asset | `.indd`, `.indt` | structured / experimental | download | lazy async |
|
|
137
|
+
| Adobe EPS and PostScript | asset | `.ps`, `.eps` (enhances `data-asset`) | experimental / experimental | download, print, zoom | lazy async |
|
|
138
|
+
| Adobe Color Palettes | asset | `.ase`, `.aco` | structured / stable | download, print, HTML export, search | lazy async |
|
|
139
|
+
| Adobe Photoshop Resources and Presets | asset | `.abr`, `.csh`, `.pat`, `.grd`, `.asl` | structured / experimental | download, print, search | lazy async |
|
|
140
|
+
| Data Asset | asset | `.ttf`, `.otf`, `.woff`, `.woff2`, `.psd`, `.ai`, `.eps`, `.sqlite`, `.wasm`, `.parquet`, `.avro`, `.webarchive` | structured / stable | download, HTML export, search | lazy async |
|
|
141
|
+
| Binary Inspector | asset | `.bin`, `.hex`, `.elf`, `.exe`, `.dll`, `.class`, `.macho` | structured / experimental | download | lazy async |
|
|
142
|
+
|
|
143
|
+
## Engineering-Grade On-Demand Renderer Assembly
|
|
144
|
+
|
|
145
|
+
The quickstart flow is: get the component running first, then make the format boundary explicit. Install the component package for the current ecosystem, then choose `@file-viewer/preset-lite`, `@file-viewer/preset-office`, `@file-viewer/preset-engineering`, or `@file-viewer/preset-all`. For Webpack, Rspack, Rollup, Umi, classic multi-page apps, and other non-Vite stacks, pass capability explicitly through `options.preset` or `options.renderers`. The Vite plugin is an optional convenience layer that removes manual imports and copies offline assets.
|
|
147
146
|
|
|
148
147
|
```bash
|
|
149
148
|
npm i @file-viewer/vue3 @file-viewer/preset-office
|
|
@@ -158,7 +157,7 @@ const options = {
|
|
|
158
157
|
}
|
|
159
158
|
```
|
|
160
159
|
|
|
161
|
-
|
|
160
|
+
When a product combines Office documents with engineering drawings, keep the same `preset` field and pass an array:
|
|
162
161
|
|
|
163
162
|
```ts
|
|
164
163
|
import officePreset from '@file-viewer/preset-office'
|
|
@@ -170,7 +169,7 @@ const options = {
|
|
|
170
169
|
}
|
|
171
170
|
```
|
|
172
171
|
|
|
173
|
-
|
|
172
|
+
For exact small cuts, install one renderer and pass it through `options.renderers`:
|
|
174
173
|
|
|
175
174
|
```ts
|
|
176
175
|
import { pdfRenderer } from '@file-viewer/renderer-pdf'
|
|
@@ -181,7 +180,7 @@ const options = {
|
|
|
181
180
|
}
|
|
182
181
|
```
|
|
183
182
|
|
|
184
|
-
Vite
|
|
183
|
+
Vite projects can add the plugin. It auto-discovers installed presets, injects the virtual module, and copies matching Worker / WASM / font / vendor assets:
|
|
185
184
|
|
|
186
185
|
```bash
|
|
187
186
|
npm i -D @file-viewer/vite-plugin
|
|
@@ -194,31 +193,31 @@ export default {
|
|
|
194
193
|
plugins: [
|
|
195
194
|
fileViewerRenderers({
|
|
196
195
|
copyAssets: true
|
|
197
|
-
//
|
|
196
|
+
// No preset option required: the plugin discovers installed @file-viewer/preset-office.
|
|
198
197
|
})
|
|
199
198
|
]
|
|
200
199
|
}
|
|
201
200
|
```
|
|
202
201
|
|
|
203
|
-
|
|
202
|
+
Heavy users that want the complete official demo capability can switch to the full preset. Non-Vite projects keep `options.preset`; the Vite config stays the same:
|
|
204
203
|
|
|
205
204
|
```bash
|
|
206
205
|
npm i @file-viewer/vue3 @file-viewer/preset-all
|
|
207
206
|
```
|
|
208
207
|
|
|
209
|
-
|
|
208
|
+
Use explicit plugin options only when you need customization:
|
|
210
209
|
|
|
211
210
|
```ts
|
|
212
211
|
fileViewerRenderers({
|
|
213
|
-
preset: 'auto', //
|
|
214
|
-
scan: true, //
|
|
215
|
-
formats: ['pdf'], //
|
|
212
|
+
preset: 'auto', // keep installed preset auto-discovery while scanning source hints
|
|
213
|
+
scan: true, // detects fileViewerFormats, data-file-viewer-formats, and accept
|
|
214
|
+
formats: ['pdf'], // adds exact renderers outside the installed preset
|
|
216
215
|
copyAssets: true,
|
|
217
216
|
chunkStrategy: 'renderer'
|
|
218
217
|
})
|
|
219
218
|
```
|
|
220
219
|
|
|
221
|
-
|
|
220
|
+
For strict custom cuts or component-library tests, disable injection and pass the virtual module explicitly:
|
|
222
221
|
|
|
223
222
|
```ts
|
|
224
223
|
// vite.config.ts
|
|
@@ -226,7 +225,7 @@ fileViewerRenderers({ formats: ['pdf'], inject: false, copyAssets: true })
|
|
|
226
225
|
```
|
|
227
226
|
|
|
228
227
|
```ts
|
|
229
|
-
//
|
|
228
|
+
// Application viewer entry
|
|
230
229
|
import { configuredFileViewerRenderers } from 'virtual:file-viewer-renderers'
|
|
231
230
|
|
|
232
231
|
const options = {
|
|
@@ -235,81 +234,81 @@ const options = {
|
|
|
235
234
|
}
|
|
236
235
|
```
|
|
237
236
|
|
|
238
|
-
- Vue
|
|
239
|
-
- `preset-lite`
|
|
240
|
-
-
|
|
241
|
-
- `fileViewerRenderers()`
|
|
242
|
-
- `scan:true`
|
|
243
|
-
- `copyAssets:true`
|
|
244
|
-
- `builtinRenderers`
|
|
245
|
-
-
|
|
246
|
-
- `@file-viewer/preset-all`
|
|
237
|
+
- Vue, React, Svelte, jQuery, and Vanilla JavaScript / Pure Web all receive the same `options`; each package maps them to native props, hooks, actions, plugins, or `mountViewer(...)` parameters.
|
|
238
|
+
- `preset-lite` covers text, Markdown, code, images, audio, and video; `preset-office` covers PDF / Word / Excel / PowerPoint / OFD; `preset-engineering` covers CAD / 3D / drawing / XMind / Geo / Typst / EDA / Data.
|
|
239
|
+
- For the smallest custom bundle, skip presets, install individual renderers such as `@file-viewer/renderer-pdf` or `@file-viewer/renderer-word`, and pass them through `options.renderers`.
|
|
240
|
+
- `fileViewerRenderers()` or `fileViewerRenderers({ copyAssets:true })` auto-discovers installed presets without explicit configuration. When `scan:true` is also enabled, use `preset:'auto'` or `autoPresets:true` to keep preset auto-discovery.
|
|
241
|
+
- `scan:true` detects `fileViewerFormats`, `data-file-viewer-formats`, and upload `accept` hints so development and production builds select matching renderers automatically.
|
|
242
|
+
- `copyAssets:true` copies PDF/CAD/Typst/Archive/Data workers, WASM, and vendor assets for offline and enterprise intranet deployment; archive directories use `vendor/libarchive/worker-bundle.js` / `libarchive.wasm` first, while the compatibility path only covers ZIP/TAR/GZIP when the Worker cannot start.
|
|
243
|
+
- `builtinRenderers` remains available for advanced baseline control or historical compatibility. Normal quick starts only need `preset` / `renderers` plus `rendererMode`.
|
|
244
|
+
- If a file is in the supported matrix but its renderer is not assembled, the viewer shows the recommended preset / renderer package. Truly unknown extensions still show an unsupported-format state.
|
|
245
|
+
- `@file-viewer/preset-all` provides the published compatibility renderer matrix; Worker, WASM, font, and vendor assets still need to be deployed by the Vite plugin or `file-viewer-copy-assets`. `*-full` packages already include this preset and must not install it again. DICOM and signature containers are later explicit opt-ins.
|
|
247
246
|
|
|
248
|
-
##
|
|
247
|
+
## Shared Options And Events
|
|
249
248
|
|
|
250
|
-
|
|
249
|
+
Every ecosystem package uses the same `ViewerMountOptions` and `FileViewerOptions` semantics, mapped to framework-native props, events, refs, actions, or plugin APIs.
|
|
251
250
|
|
|
252
|
-
|
|
|
251
|
+
| Option | Description |
|
|
253
252
|
| --- | --- |
|
|
254
|
-
| `url` |
|
|
255
|
-
| `file` | `File
|
|
256
|
-
| `buffer` |
|
|
257
|
-
| `name` / `filename` |
|
|
258
|
-
| `type` |
|
|
259
|
-
| `size` |
|
|
260
|
-
| `options` |
|
|
261
|
-
| `options.styleIsolation` | `auto
|
|
262
|
-
| `onEvent` / `onStateChange` | Vanilla
|
|
253
|
+
| `url` | Remote file URL from object storage, business APIs, or intranet file services. |
|
|
254
|
+
| `file` | `File`, `Blob`, or `ArrayBuffer` for uploads, local selection, or already-fetched binary data. |
|
|
255
|
+
| `buffer` | Direct `ArrayBuffer` input after custom download, authorization, or decryption. |
|
|
256
|
+
| `name` / `filename` | Display name and extension hint. Pass it explicitly when the URL has no useful extension. |
|
|
257
|
+
| `type` | Explicit extension or MIME hint that overrides automatic detection. |
|
|
258
|
+
| `size` | File size hint used in lifecycle context, loading states, and safety limits. |
|
|
259
|
+
| `options` | The shared `FileViewerOptions` surface. Every component package keeps the same semantics. |
|
|
260
|
+
| `options.styleIsolation` | `auto`, `shadow`, `scoped`, or `none`. `auto` uses Shadow DOM for every standard component so host-page global CSS cannot break the toolbar or document; legacy projects can explicitly use `none`. |
|
|
261
|
+
| `onEvent` / `onStateChange` | Unified event and state subscriptions for imperative wrappers such as Vanilla JavaScript / Pure Web, React, and Svelte. Vue maps the same events to native emits. |
|
|
263
262
|
|
|
264
|
-
##
|
|
263
|
+
## Actual Component Props
|
|
265
264
|
|
|
266
|
-
|
|
265
|
+
The table below lists the real props, event channel, and customization entry for every standard package. If you need imperative mount fields such as `buffer`, `name`, `type`, or `size`, prefer Vanilla JavaScript / Pure Web, React, Svelte, jQuery, or Vue 2. The Vue 3 declarative component intentionally keeps the compact `url` / `file` / `options` entry; wrap raw binary input as a named `File` when extension detection matters.
|
|
267
266
|
|
|
268
|
-
|
|
|
267
|
+
| Component | Actual props / entry | Event channel | Customization entry |
|
|
269
268
|
| --- | --- | --- | --- |
|
|
270
|
-
| Vanilla JS / Pure Web `@file-viewer/web` | `<flyfish-file-viewer>`
|
|
271
|
-
| Vue 3 `@file-viewer/vue3` | `url
|
|
272
|
-
| Vue 2.7 `@file-viewer/vue2.7` | `url
|
|
273
|
-
| Vue 2.6 `@file-viewer/vue2.6` |
|
|
274
|
-
| React `@file-viewer/react` | `ViewerMountOptions`
|
|
275
|
-
| React Legacy `@file-viewer/react-legacy` |
|
|
276
|
-
| jQuery `@file-viewer/jquery` | `$(el).fileViewer(ViewerMountOptions & { replace?: boolean })` | `onEvent
|
|
277
|
-
| Svelte `@file-viewer/svelte` | `ViewerMountOptions`
|
|
278
|
-
|
|
279
|
-
| Options
|
|
269
|
+
| Vanilla JS / Pure Web `@file-viewer/web` | `<flyfish-file-viewer>` attributes: `src/url`, `filename/name`, `type`, `size`, `theme`, `toolbar`, `toolbar-position`, `watermark`, `search`, `options`; also supports `mountViewer(...)` | `viewer-ready`, `viewer-event`, `viewer-state-change`, `viewer-error`, `onEvent`, `onStateChange`, `controller.subscribe()` | The Custom Element instance exposes the full controller handle; the IIFE script auto-registers it while keeping imperative `mountViewer` and the asset copy CLI. |
|
|
270
|
+
| Vue 3 `@file-viewer/vue3` | `url`, `file`, `options` | `load-start`, `load-complete`, `unload-start`, `unload-complete`, `operation-before`, `operation-cancel`, `operation-availability-change`, `search-change`, `location-change`, `zoom-change`, `view-state-change`, `theme-change` | Template refs expose `FileViewerExpose`. For `Blob` / `ArrayBuffer`, prefer wrapping it as a named `File` so extension detection stays deterministic. |
|
|
271
|
+
| Vue 2.7 `@file-viewer/vue2.7` | `url`, `file`, `buffer`, `name`, `filename`, `type`, `size`, `options`, `containerClass`, `containerStyle` | `viewer-event` / `viewerEvent` | The component instance exposes the full controller handle. This is the Vue 2.7 line behind the historical `@flyfish-group/file-viewer` package. |
|
|
272
|
+
| Vue 2.6 `@file-viewer/vue2.6` | Same as Vue 2.7 | `viewer-event` / `viewerEvent` | Separate Vue 2.6 build for long-lived applications that cannot move to Vue 2.7. |
|
|
273
|
+
| React `@file-viewer/react` | `ViewerMountOptions` plus native `div` props such as `className`, `style`, `data-*`, and `aria-*` | `onEvent`, `onStateChange` | `ref` exposes `FileViewerHandle`; `useFileViewer()` returns `ref`, `props`, `state`, and `handle` for custom toolbars. |
|
|
274
|
+
| React Legacy `@file-viewer/react-legacy` | Same as the React package | `onEvent`, `onStateChange` | Targets React 16.8 / 17 with a legacy-friendly component export. |
|
|
275
|
+
| jQuery `@file-viewer/jquery` | `$(el).fileViewer(ViewerMountOptions & { replace?: boolean })` | `onEvent`, `onStateChange`, or `getFileViewerController(el).subscribe()` | Plugin methods include `zoomIn`, `printRenderedHtml`, and `searchDocument`; `replace:false` updates the same node in place. |
|
|
276
|
+
| Svelte `@file-viewer/svelte` | `ViewerMountOptions` plus `className` and `containerStyle` | `on:viewerEvent`, `onEvent`, `onStateChange` | `bind:this` exposes the controller handle; the `use:fileViewer` action is also available and adds `replace`. |
|
|
277
|
+
|
|
278
|
+
| Options Field | Description |
|
|
280
279
|
| --- | --- |
|
|
281
|
-
| `theme` | `light
|
|
282
|
-
| `styleIsolation` | `auto
|
|
283
|
-
| `watermark` |
|
|
284
|
-
| `toolbar` |
|
|
285
|
-
| `search` |
|
|
286
|
-
| `ai` |
|
|
287
|
-
| `archive` |
|
|
288
|
-
| `pdf` |
|
|
289
|
-
| `docx` / `spreadsheet` | DOCX
|
|
290
|
-
| `iwork` |
|
|
291
|
-
| `hangul` |
|
|
292
|
-
| `wordPerfect` |
|
|
293
|
-
| `presentation` | standard/full
|
|
294
|
-
| `typst` / `data` / `cad` |
|
|
295
|
-
| `hooks` / `beforeOperation` |
|
|
296
|
-
|
|
297
|
-
##
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
|
280
|
+
| `theme` | `light`, `dark`, or `system`. This takes precedence over browser `prefers-color-scheme`. |
|
|
281
|
+
| `styleIsolation` | `auto`, `shadow`, `scoped`, or `none`. With `auto`, Web Component, IIFE, Vue, React, Svelte, jQuery, and full packages all use Shadow DOM by default. Legacy integrations that depend on deep class overrides can explicitly use `none`. |
|
|
282
|
+
| `watermark` | Text or image watermark with opacity, rotation, gap, size, font, and color controls. |
|
|
283
|
+
| `toolbar` | Controls the theme toggle, download, print, HTML export, zoom, item order, toolbar position, and operation-level preflight checks. |
|
|
284
|
+
| `search` | Document search, highlight class names, case sensitivity, whole-word matching, max matches, and debounce. |
|
|
285
|
+
| `ai` | Text collection, chunk size, and max text length for provenance, location, vectorization, and external AI workflows. |
|
|
286
|
+
| `archive` | Archive Worker/WASM URLs, timeout, cache, archive limits, nested entry preview limits, and legacy GBK/GB18030 ZIP filename decoding. |
|
|
287
|
+
| `pdf` | PDF.js worker, navigation pane, outline, thumbnails, rotation, streaming, range chunk size, and credentials. |
|
|
288
|
+
| `docx` / `spreadsheet` | DOCX is provided by @file-viewer/renderer-word and uses the self-maintained @file-viewer/docx engine with automatic worker/main-thread selection, continuous flow reading, and async rendering by default; visual pagination is opt-in. Spreadsheet is provided by @file-viewer/renderer-spreadsheet with fidelity-first parsing, automatic Worker use for large files, and opt-in header drag column resizing. |
|
|
289
|
+
| `iwork` | After explicitly installing the iWork capability, configure its Pages / Numbers / Keynote module Worker, timeout, ZIP/Snappy/IWA safety limits, and Quick Look fallback policy. It is not in the standard/full default closure. |
|
|
290
|
+
| `hangul` | After explicitly installing the Hangul capability, configure its HWP/HWPX module Worker, timeout, ZIP limits, and HWP record limits. It is not in the standard/full default closure. |
|
|
291
|
+
| `wordPerfect` | After explicitly installing the WordPerfect capability, configure its Worker, libwpd/librevenge WASM URL, and timeout. It is not in the standard/full default closure. |
|
|
292
|
+
| `presentation` | The standard/full default includes only the PPTX/OpenXML `@file-viewer/pptx` Worker, with optional `workerUrl` / `workerType` overrides. Binary PowerPoint 97–2003 `.ppt` is a separate heavy capability; run `file-viewer add ppt --write` to install its Worker/WASM and assets explicitly. |
|
|
293
|
+
| `typst` / `data` / `cad` | After explicitly installing the matching capability, configure Typst, SQLite, or CAD/DWG/DXF/DWF WASM, worker, encoding, and rendering options. These capabilities are not in the standard/full default closure. |
|
|
294
|
+
| `hooks` / `beforeOperation` | Shared lifecycle hooks and operation preflight checks for audit, permission, telemetry, and safety controls. |
|
|
295
|
+
|
|
296
|
+
## Style Isolation And Theme Customization
|
|
297
|
+
|
|
298
|
+
Every standard component uses strong Shadow DOM isolation by default. Host-page global rules for `*`, `button`, `table`, `img`, `svg`, `canvas`, and similar selectors should not leak into the viewer toolbar or rendered content, and viewer resets should not pollute the host page.
|
|
299
|
+
|
|
300
|
+
| Mode | Description |
|
|
302
301
|
| --- | --- |
|
|
303
|
-
| `auto` |
|
|
304
|
-
| `shadow` |
|
|
305
|
-
| `scoped` |
|
|
306
|
-
| `none` |
|
|
302
|
+
| `auto` | Default. Web Component, IIFE, Vue, React, Svelte, jQuery, and full packages all use Shadow DOM so host-page CSS cannot break the toolbar or renderer content. |
|
|
303
|
+
| `shadow` | Creates an explicit ShadowRoot render surface. Use it when host CSS is uncontrolled, micro-frontends are mixed, low-code platforms inject global resets, or design systems have aggressive base styles. |
|
|
304
|
+
| `scoped` | Does not create a ShadowRoot. Uses a stable root selector and local resets to limit its impact while keeping controlled inheritance from the host. |
|
|
305
|
+
| `none` | Historical light-DOM behavior for projects that depend on deep class overrides, old theme CSS, or snapshot tests. |
|
|
307
306
|
|
|
308
|
-
`styleIsolation`
|
|
307
|
+
`styleIsolation` is a mount-time boundary. Remount the component when changing modes. Both `scoped` and `none` use Light DOM, so high-specificity or `!important` host rules can still override them.
|
|
309
308
|
|
|
310
|
-
|
|
309
|
+
Customization should start with `--file-viewer-*` CSS variables for color, typography, spacing, radius, toolbar, and button styling. Use stable Shadow Parts only when a specific internal surface needs styling. The current Web shell exposes `host`, `shell`, `toolbar`, `toolbar-group`, `toolbar-status`, `button`, `input`, and `content`; renderer extensions should keep using stable names such as `state-panel` and `watermark`. Do not depend on internal class names; they are implementation details.
|
|
311
310
|
|
|
312
|
-
|
|
311
|
+
In this example, `file-viewer-host` is the class on the actual Shadow host. Pass it as `class` in Vue 3, `containerClass` in Vue 2, `className` in React / Svelte, or add it to the element initialized by jQuery.
|
|
313
312
|
|
|
314
313
|
```css
|
|
315
314
|
.file-viewer-host {
|
|
@@ -329,7 +328,7 @@ const options = {
|
|
|
329
328
|
}
|
|
330
329
|
```
|
|
331
330
|
|
|
332
|
-
|
|
331
|
+
Framework packages use Shadow DOM without extra configuration; set it explicitly when you want to lock the policy:
|
|
333
332
|
|
|
334
333
|
```ts
|
|
335
334
|
const options = {
|
|
@@ -339,89 +338,89 @@ const options = {
|
|
|
339
338
|
}
|
|
340
339
|
```
|
|
341
340
|
|
|
342
|
-
##
|
|
341
|
+
## Toolbar Customization
|
|
343
342
|
|
|
344
|
-
|
|
|
343
|
+
| Config | Description |
|
|
345
344
|
| --- | --- |
|
|
346
|
-
| `toolbar: false` |
|
|
347
|
-
| `toolbar: true` |
|
|
348
|
-
| `download` / `print` / `exportHtml` / `zoom` |
|
|
349
|
-
| `theme` |
|
|
350
|
-
| `order` |
|
|
351
|
-
| `position` | `auto
|
|
352
|
-
| `beforeOperation` |
|
|
353
|
-
| `beforeDownload` / `beforePrint` / `beforeExportHtml` |
|
|
345
|
+
| `toolbar: false` | Hides the built-in toolbar without disabling controller APIs such as download, print, export, and zoom. Use this for a fully custom business toolbar. |
|
|
346
|
+
| `toolbar: true` | Uses the default built-in toolbar. The theme toggle is visible by default; download, print, HTML export, and zoom remain capability-aware. |
|
|
347
|
+
| `download` / `print` / `exportHtml` / `zoom` | Expresses whether the host allows a button. Final availability is still computed from file type, render readiness, export adapter, and zoom provider state. |
|
|
348
|
+
| `theme` | Controls the light/dark toggle and defaults to `true`. A change emits `theme-change`; set it to `false` to hide the button. |
|
|
349
|
+
| `order` | Orders built-in groups with `search`, `zoom`, `download`, `print`, `exportHtml`, and `theme`. Omitted items keep their default relative order. |
|
|
350
|
+
| `position` | `auto`, `top`, `top-center`, or `bottom-right`. The default `auto` floats PDF actions at bottom right and keeps other formats top-right; use `top-center` for a centered top toolbar. |
|
|
351
|
+
| `beforeOperation` | Toolbar-level preflight that runs after `options.beforeOperation`. Returning `false` or throwing cancels the operation. |
|
|
352
|
+
| `beforeDownload` / `beforePrint` / `beforeExportHtml` | Operation-specific preflight for download permission, print audit, export confirmation, and similar business rules. |
|
|
354
353
|
|
|
355
|
-
|
|
354
|
+
For fully custom toolbars, hide the built-in toolbar and call the standard ref / controller APIs from your own UI. Do not implement zoom with an outer CSS `transform: scale()`; PDF, Excel, CAD, canvas-based, and text-layer renderers should use their internal zoom providers to keep coordinates correct.
|
|
356
355
|
|
|
357
|
-
|
|
356
|
+
Zoom state is reported by each renderer provider. After first-screen fit, container resize, or asynchronous PDF / Word / image layout, built-in toolbars show the real scale instead of assuming `100%`. Custom toolbars should listen to `zoom-change` / `operation-availability-change`, or read `getZoomState()` / `getOperationAvailability()`.
|
|
358
357
|
|
|
359
|
-
|
|
358
|
+
View-state sync is designed for projection systems, remote-control displays, side-by-side review, and reading-position restore. Every standard renderer loader gets a generic view-state provider that records at least `renderer`, zoom, and scroll position; PDF, XMind, Geo, 3D, and CAD add page, navigation, canvas pan, map center, camera, or native view snapshots. Pass `options.initialViewState` for first render, listen to `view-state-change` while running, and use `getViewState()` / `applyViewState(state, { source: "api", action: "restore" })` on Pure Web / Vue3 controllers when an imperative restore API is needed.
|
|
360
359
|
|
|
361
|
-
|
|
|
360
|
+
| Ecosystem | Recommended pattern |
|
|
362
361
|
| --- | --- |
|
|
363
|
-
| Vanilla JS / Pure Web | `<flyfish-file-viewer toolbar="false">`
|
|
364
|
-
| Vue 3 |
|
|
365
|
-
| Vue 2.7 / 2.6 |
|
|
366
|
-
| React / React Legacy |
|
|
367
|
-
| jQuery | `$("#viewer").fileViewer({ options:{ toolbar:false } })
|
|
368
|
-
| Svelte | `<FileViewer bind:this={viewer} options={{ toolbar:false }}
|
|
362
|
+
| Vanilla JS / Pure Web | Use `<flyfish-file-viewer toolbar="false">` or `mountViewer(container, { options:{ toolbar:false }, onStateChange })`; custom DOM buttons can call `zoomIn()`, `printRenderedHtml()`, `searchDocument()`, and other element / controller methods directly. Use `viewer-state-change` or `controller.subscribe()` for advanced state sync. |
|
|
363
|
+
| Vue 3 | Pass `:options="{ toolbar: false }"`, call `downloadOriginalFile()`, `printRenderedHtml()`, `exportRenderedHtml()`, `zoomIn()`, `zoomOut()`, and `resetZoom()` through the template ref, and sync buttons with `@operation-availability-change` plus `@zoom-change`. |
|
|
364
|
+
| Vue 2.7 / 2.6 | Use `toolbar:false`, call instance methods through `$refs.viewer`, and listen to `@viewer-event` for `operation-availability-change` or `zoom-change`. |
|
|
365
|
+
| React / React Legacy | Prefer `useFileViewer({ options:{ toolbar:false } })`; pass `viewer.props` to the component, bind custom buttons to `viewer.handle`, and read `viewer.state.availability` / `viewer.state.zoom`. |
|
|
366
|
+
| jQuery | Use `$("#viewer").fileViewer({ options:{ toolbar:false } })`; buttons can call `$("#viewer").fileViewer("zoomIn")` or read capability state through `getFileViewerController($("#viewer")).subscribe()`. |
|
|
367
|
+
| Svelte | Use `<FileViewer bind:this={viewer} options={{ toolbar:false }} />`; buttons call `viewer.zoomIn()` / `viewer.printRenderedHtml()`, with `on:viewerEvent` or `onStateChange` for state sync. |
|
|
369
368
|
|
|
370
|
-
##
|
|
369
|
+
## Lifecycle And Operation Events
|
|
371
370
|
|
|
372
|
-
|
|
|
371
|
+
| Event / hook | Description |
|
|
373
372
|
| --- | --- |
|
|
374
|
-
| `load-start` / `hooks.onLoadStart` |
|
|
375
|
-
| `load-complete` / `hooks.onLoadComplete` |
|
|
376
|
-
| `unload-start` / `hooks.onUnloadStart` |
|
|
377
|
-
| `unload-complete` / `hooks.onUnloadComplete` |
|
|
378
|
-
| `operation-before` / `operation-cancel` |
|
|
379
|
-
| `operation-availability-change` |
|
|
380
|
-
| `theme-change` |
|
|
381
|
-
| `search-change` / `location-change` / `zoom-change` / `view-state-change` |
|
|
382
|
-
|
|
383
|
-
##
|
|
384
|
-
|
|
385
|
-
| API |
|
|
373
|
+
| `load-start` / `hooks.onLoadStart` | Fires when parsing or downloading starts. Context includes filename, type, source, version, URL, File, and size. |
|
|
374
|
+
| `load-complete` / `hooks.onLoadComplete` | Fires when the current document has rendered. Context includes duration, source data, and version. |
|
|
375
|
+
| `unload-start` / `hooks.onUnloadStart` | Fires before replace, reset, or component unmount so external state or resources can be saved. |
|
|
376
|
+
| `unload-complete` / `hooks.onUnloadComplete` | Fires after the previous document is released. The reason is `replace`, `reset`, or `component-unmount`. |
|
|
377
|
+
| `operation-before` / `operation-cancel` | Fires around download, print, HTML export, and zoom actions. Returning `false` from `beforeOperation` cancels the action. |
|
|
378
|
+
| `operation-availability-change` | Fires when download, print, HTML export, or zoom support changes for the active format. |
|
|
379
|
+
| `theme-change` | Fires when the built-in control selects light or dark mode. The payload is `light` or `dark`. |
|
|
380
|
+
| `search-change` / `location-change` / `zoom-change` / `view-state-change` | Fires when search matches, document anchors, zoom state, or full view-state snapshots change so host UIs, display screens, and reading-position restore flows can stay in sync. |
|
|
381
|
+
|
|
382
|
+
## Public Operation API
|
|
383
|
+
|
|
384
|
+
| API | Description |
|
|
386
385
|
| --- | --- |
|
|
387
|
-
| `load` / `update` / `reload` / `destroy` |
|
|
388
|
-
| `downloadOriginalFile()` |
|
|
389
|
-
| `printRenderedHtml(options?)` |
|
|
390
|
-
| `printWithMask(options?)` |
|
|
391
|
-
| `exportRenderedHtml()` |
|
|
392
|
-
| `zoomIn()` / `zoomOut()` / `resetZoom()` |
|
|
393
|
-
| `searchDocument()` / `nextSearchResult()` / `previousSearchResult()` |
|
|
394
|
-
| `collectDocumentAnchors()` / `scrollToAnchor()` / `scrollToLine()` |
|
|
395
|
-
| `getDocumentTextChunks()` |
|
|
396
|
-
| `getOperationAvailability()` / `getZoomState()` / `getSearchState()` |
|
|
397
|
-
|
|
398
|
-
##
|
|
399
|
-
|
|
400
|
-
|
|
|
386
|
+
| `load` / `update` / `reload` / `destroy` | Imperatively load, update, reload, and destroy the viewer. |
|
|
387
|
+
| `downloadOriginalFile()` | Downloads the original file while respecting toolbar and `beforeOperation` checks. |
|
|
388
|
+
| `printRenderedHtml(options?)` | Prints the complete rendered document using the best available per-format print adapter. Enabled watermarks are included; pass `mask` for cover regions. |
|
|
389
|
+
| `printWithMask(options?)` | Opens the black-cover mask designer, then prints. The designer is async-loaded inside core and works out of the box with component packages. |
|
|
390
|
+
| `exportRenderedHtml()` | Exports rendered HTML for archiving, audit, or offline review. |
|
|
391
|
+
| `zoomIn()` / `zoomOut()` / `resetZoom()` | Uses the active renderer zoom provider instead of outer CSS transforms that can break coordinates. |
|
|
392
|
+
| `searchDocument()` / `nextSearchResult()` / `previousSearchResult()` | Runs document-level search and navigates highlighted matches. |
|
|
393
|
+
| `collectDocumentAnchors()` / `scrollToAnchor()` / `scrollToLine()` | Collects pages, outline items, headings, or code-line anchors and scrolls to them. |
|
|
394
|
+
| `getDocumentTextChunks()` | Returns structured text chunks for search, AI provenance, vectorization, and external indexes. |
|
|
395
|
+
| `getOperationAvailability()` / `getZoomState()` / `getSearchState()` | Reads current capability, zoom, and search state for custom toolbars. |
|
|
396
|
+
|
|
397
|
+
## Workers, WASM, And Private Deployment
|
|
398
|
+
|
|
399
|
+
| Asset | Description |
|
|
401
400
|
| --- | --- |
|
|
402
|
-
| Standard
|
|
403
|
-
|
|
|
404
|
-
| PDF / DOCX / Excel / PPTX |
|
|
405
|
-
| Archive /
|
|
406
|
-
| Draw.io |
|
|
407
|
-
|
|
|
408
|
-
|
|
|
401
|
+
| Standard assets | `@file-viewer/assets-standard` copies only the workers, WASM, fonts, and vendor files required by the frozen standard profile: PDF, DOCX, PPTX, spreadsheet/OpenXML, and archives. Its transactional receipt records package version, profile hash, per-file SHA-256, and ownership. |
|
|
402
|
+
| Specialist asset owners | CAD, Typst, iWork, 3D, Data, Drawing, Hangul, WordPerfect, and legacy PPT each use an independent `@file-viewer/assets-*` package. `@file-viewer/cli add <format> --write` selects only that capability and its assets. |
|
|
403
|
+
| PDF / DOCX / Excel / PPTX | Standard self-hosts the PDF.js worker/fonts, DOCX worker, spreadsheet worker, and PPTX worker. PPTX charts and PDF Identity-font repair are explicit standard correctness capabilities, so charts and font repair are never silently omitted. |
|
|
404
|
+
| Archive / email / native media | The archive libarchive Worker/WASM is in standard assets. Email, common images, and browser-native media use lazy-loaded code. HLS, MIDI, RTF, Mermaid, patch, and git bundle remain explicit capabilities and are not auto-installed as npm peers. |
|
|
405
|
+
| Draw.io | The safe project-maintained Drawing fallback ships with its renderer. The official diagrams.net viewer is a separate heavy `drawio-official` capability and is not in the standard profile for new projects. The published capability boundary of historical `*-full` packages remains compatible. |
|
|
406
|
+
| Offline deployment | Runtime code does not use public CDNs. Vite `copyAssets:true` publishes installed asset owners; other tools use `file-viewer install --yes` or `file-viewer assets --write`. Owners merge transactionally into one deterministic runtime manifest independent of install order. |
|
|
407
|
+
| Deployment principle | New formats are opt-in by default and never expand an already published `*-full` package automatically. Specialist workers, WASM, and parsers load only when their format is used. New projects should prefer standard or selected capabilities; historical full integrations retain their existing matrix. |
|
|
409
408
|
|
|
410
409
|
|
|
411
|
-
##
|
|
410
|
+
## Quality Gates
|
|
412
411
|
|
|
413
|
-
-
|
|
414
|
-
-
|
|
415
|
-
-
|
|
412
|
+
- Component packages only depend on `@file-viewer/core` and their own ecosystem dependencies. They do not nest through another framework component package.
|
|
413
|
+
- Format parsing, search, zoom, print, export, watermark, lifecycle, and beforeOperation semantics all come from the same core.
|
|
414
|
+
- Releases should pass type checks, component API verification, README generation checks, format-matrix verification, standalone repository export, and browser smoke tests.
|
|
416
415
|
|
|
417
|
-
|
|
416
|
+
See the official documentation for options, lifecycle hooks, beforeOperation, theme, watermark, search, zoom, print, and export APIs: https://doc.file-viewer.app/
|
|
418
417
|
|
|
419
|
-
|
|
418
|
+
Online demo: https://demo.file-viewer.app/. File Viewer-authored source and component packages generated by this repository use Apache-2.0. Any distribution that includes the `@file-viewer/ppt` runtime retains its independent LICENSE and NOTICE and does not relicense it under Apache-2.0. For derivative or commercial use, keep clear Flyfish Viewer attribution; shared compatibility fixes are welcome in the matching component repository.
|
|
420
419
|
<!-- FILE_VIEWER_GENERATED:END -->
|
|
421
420
|
|
|
422
|
-
##
|
|
421
|
+
## Extending the native toolbar
|
|
423
422
|
|
|
424
|
-
Vue 3
|
|
423
|
+
The Vue 3 component exposes `toolbar-start` and `toolbar-end` slots. They preserve the native search, zoom, download, print, and theme controls while allowing host applications to add navigation, file metadata, fullscreen, approval, and other business actions. Slot props update reactively:
|
|
425
424
|
|
|
426
425
|
```vue
|
|
427
426
|
<FileViewer
|
|
@@ -433,31 +432,31 @@ Vue 3 组件提供 `toolbar-start` 与 `toolbar-end` 插槽。它们保留内置
|
|
|
433
432
|
}"
|
|
434
433
|
>
|
|
435
434
|
<template #toolbar-start="{ api, availability, zoomState, searchState }">
|
|
436
|
-
<button type="button" @click="goBack"
|
|
435
|
+
<button type="button" @click="goBack">Back</button>
|
|
437
436
|
<span>{{ file.name }}</span>
|
|
438
437
|
</template>
|
|
439
438
|
|
|
440
439
|
<template #toolbar-end="{ api }">
|
|
441
|
-
<button type="button" @click="toggleFullscreen"
|
|
440
|
+
<button type="button" @click="toggleFullscreen">Fullscreen</button>
|
|
442
441
|
</template>
|
|
443
442
|
</FileViewer>
|
|
444
443
|
```
|
|
445
444
|
|
|
446
|
-
- `api
|
|
447
|
-
- `availability
|
|
448
|
-
- `zoomState
|
|
449
|
-
- `searchState
|
|
445
|
+
- `api`: the complete `FileViewer` instance API.
|
|
446
|
+
- `availability`: current download, print, export, and zoom availability.
|
|
447
|
+
- `zoomState`: current scale and zoom button state.
|
|
448
|
+
- `searchState`: query, total matches, and current match position.
|
|
450
449
|
|
|
451
|
-
|
|
450
|
+
Set `styleIsolation: 'none'` when slot content is styled by host-page CSS. In Shadow DOM mode, use inline styles or File Viewer CSS variables.
|
|
452
451
|
|
|
453
|
-
##
|
|
452
|
+
## Formats and related packages
|
|
454
453
|
|
|
455
|
-
File Viewer
|
|
454
|
+
File Viewer previews 275+ file extensions in the browser, covering Office, PDF/OFD, CAD, 3D, archives, email, images, media and code, without server-side conversion. See the [format matrix](https://doc.file-viewer.app/guide/formats) for the full list.
|
|
456
455
|
|
|
457
|
-
-
|
|
458
|
-
-
|
|
459
|
-
-
|
|
456
|
+
- Components: `@file-viewer/web`, `@file-viewer/vue3`, `@file-viewer/vue2.7`, `@file-viewer/vue2.6`, `@file-viewer/react`, `@file-viewer/react-legacy`, `@file-viewer/svelte`, `@file-viewer/jquery`, plus their `-full` packages
|
|
457
|
+
- Presets: `@file-viewer/preset-lite`, `@file-viewer/preset-office`, `@file-viewer/preset-engineering`, `@file-viewer/preset-all`
|
|
458
|
+
- Build: `@file-viewer/vite-plugin`, `file-viewer-copy-assets`
|
|
460
459
|
|
|
461
|
-
##
|
|
460
|
+
## License
|
|
462
461
|
|
|
463
|
-
|
|
462
|
+
This package is Apache-2.0. See [LICENSE](https://github.com/flyfish-dev/file-viewer/blob/main/LICENSE).
|