@file-viewer/vue3 3.2.2 → 3.3.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 CHANGED
@@ -1,5 +1,9 @@
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
+
5
+ Browser-side file preview for Vue 3. Use one component API for loading, search, zoom, page navigation, print and export where supported by the selected format. This is the lightweight package: add renderer presets for PDF, Office and other document formats.
6
+
3
7
  <!-- FILE_VIEWER_PACKAGE_HEADER -->
4
8
  <p>
5
9
  <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,19 +13,32 @@
9
13
  </p>
10
14
 
11
15
  <p>
12
- <a href="https://github.com/flyfish-dev/file-viewer">GitHub</a> · <a href="https://doc.file-viewer.app/zh/">文档</a> · <a href="https://demo.file-viewer.app/">在线 Demo</a> · <a href="https://doc.file-viewer.app/guide/formats">格式矩阵</a> · <a href="https://github.com/flyfish-dev/file-viewer/issues">问题反馈</a> · <a href="https://github.com/flyfish-dev/file-viewer/blob/main/packages/components/vue3/README.en.md">English</a>
16
+ <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
17
  </p>
14
18
 
15
19
  <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-zh.webp" width="760" alt="File Viewer 在线演示:Word、Excel、PPT、3D 模型、CAD 图纸与二进制检查器"></a>
20
+ <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
21
  </p>
18
22
 
19
- > ⭐ 如果 File Viewer 对你有帮助,欢迎到 [GitHub](https://github.com/flyfish-dev/file-viewer) 点个 Star。
23
+ > ⭐ If File Viewer helps you, please [star the repo on GitHub](https://github.com/flyfish-dev/file-viewer).
24
+
25
+ ## Quick start
26
+
27
+ Create an application with renderers and local assets configured:
28
+
29
+ ```bash
30
+ npx file-viewer-cli@latest create my-viewer --framework vue3 --profile standard
31
+ ```
32
+
33
+ For an existing project, use `npx file-viewer-cli@latest add .`, or follow the [manual integration guide](https://doc.file-viewer.app/guide/on-demand-renderers). The component alone does not install document engines or deploy their Worker/WASM files.
34
+
35
+ ## Manual integration
20
36
 
21
- 标准 Vue3 native 组件包。它维护 Vue3 组件生命周期和本地 controller,同时消费共享的 `@file-viewer/core` 底层契约与 core browser engine,提供插件安装、组件 props、生命周期事件、搜索/缩放/打印/导出等 ref API。
37
+ The examples below require the matching renderer preset and self-hosted assets. The CLI configures these for you; a bare component install is not a PDF or Office viewer.
22
38
 
23
39
  ```bash
24
- npm install vue @file-viewer/vue3
40
+ npm install vue @file-viewer/vue3 @file-viewer/preset-standard file-viewer-copy-assets
41
+ npx --no-install file-viewer-copy-assets ./public/file-viewer
25
42
  ```
26
43
 
27
44
  ```ts
@@ -35,115 +52,117 @@ createApp(App).use(FileViewer).mount('#app')
35
52
  ```
36
53
 
37
54
  ```vue
55
+ <script setup lang="ts">
56
+ import standardRenderers from '@file-viewer/preset-standard'
57
+
58
+ const viewerOptions = {
59
+ preset: standardRenderers,
60
+ theme: 'light' as const,
61
+ toolbar: { position: 'bottom-right' as const }
62
+ }
63
+ </script>
64
+
38
65
  <template>
39
66
  <section style="height: 100vh">
40
67
  <file-viewer
41
- ref="viewer"
42
68
  url="/example/demo.pdf"
43
- :options="{
44
- theme: 'light',
45
- toolbar: { position: 'bottom-right' }
46
- }"
47
- @load-complete="handleLoadComplete"
69
+ :options="viewerOptions"
48
70
  />
49
71
  </section>
50
72
  </template>
51
73
  ```
52
74
 
53
- 组件实例支持 `destroy()`、`downloadOriginalFile()`、`printRenderedHtml()`、`exportRenderedHtml()`、`zoomIn()`、`zoomOut()`、`resetZoom()`、`searchDocument()`、`clearDocumentSearch()`、`nextSearchResult()`、`previousSearchResult()`、`collectDocumentAnchors()`、`scrollToAnchor()`、`scrollToLine()` 和 `getDocumentTextChunks()`。历史包名 `@flyfish-group/file-viewer3` 和 `file-viewer3` 会继续同步维护,用于兼容旧项目;新项目建议优先使用标准组件包 `@file-viewer/vue3`。
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。
75
+ 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
76
 
59
- ## 能力范围
77
+ 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
78
 
61
- `@file-viewer/vue3` 与其他标准组件包共享同一套 core 接口和 renderer/preset 装配模型;完整能力可通过按需 renderer 或 `@file-viewer/preset-all` 覆盖 PDF、Word、Excel、PPT、OFD、CAD/DWG/DXF/DWF、EPUB/UMD、压缩包、邮件、Markdown、代码高亮、图片、音频、视频、3D 模型、地理数据和结构化数据资产等预览链路。完整格式矩阵和参数说明见官方文档: https://doc.file-viewer.app/guide/formats
79
+ 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
80
 
81
+ ## Capabilities
63
82
 
64
- English README: [README.en.md](./README.en.md)。
83
+ `@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
84
 
66
85
  <!-- FILE_VIEWER_GENERATED:START -->
67
- ## 生态包矩阵
86
+ ## Ecosystem Matrix
68
87
 
69
- 所有标准组件包都只共享 `@file-viewer/core` 这个总底座,不依赖其他框架组件实现。core 负责格式矩阵、资源解析、renderer 协议、事件、操作 API、搜索、缩放、打印和导出;PDF、Word、PPT/PPTX、CAD、Typst 等重型链路通过独立 renderer 或 preset 显式装配;各框架组件包自己维护本地 controller、组件生命周期、类型出口和生态交互。
88
+ 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
89
 
71
- | 框架 | 标准 npm 包 | 入口格式 | GitHub | Gitee | 兼容历史包 |
90
+ | Framework | Standard npm package | Entrypoints | GitHub | Gitee | Historical aliases |
72
91
  | --- | --- | --- | --- | --- | --- |
73
- | Vanilla JS / Pure Web | `@file-viewer/web` | ESM, 类型声明, script 标签 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` |
74
- | Vanilla JS / Pure Web Full | `@file-viewer/web-full` | ESM, 类型声明, script 标签 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) | 无 |
75
- | Vue 3 | `@file-viewer/vue3` | ESM, 类型声明 | [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` |
76
- | Vue 3 Full | `@file-viewer/vue3-full` | ESM, 类型声明 | [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) | 无 |
77
- | Vue 2.7 | `@file-viewer/vue2.7` | ESM, 类型声明 | [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` |
78
- | Vue 2.7 Full | `@file-viewer/vue2.7-full` | ESM, 类型声明 | [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) | 无 |
79
- | Vue 2.6 | `@file-viewer/vue2.6` | ESM, 类型声明 | [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) | 无 |
80
- | Vue 2.6 Full | `@file-viewer/vue2.6-full` | ESM, 类型声明 | [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) | 无 |
81
- | React 18/19 | `@file-viewer/react` | ESM, 类型声明 | [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` |
82
- | React 18/19 Full | `@file-viewer/react-full` | ESM, 类型声明 | [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) | 无 |
83
- | React 16.8/17 | `@file-viewer/react-legacy` | ESM, 类型声明 | [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) | 无 |
84
- | React 16.8/17 Full | `@file-viewer/react-legacy-full` | ESM, 类型声明 | [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) | 无 |
85
- | jQuery | `@file-viewer/jquery` | ESM, 类型声明 | [file-viewer-jquery](https://github.com/flyfish-dev/file-viewer-jquery) | [file-viewer-jquery](https://gitee.com/flyfish-dev/file-viewer-jquery) | 无 |
86
- | jQuery Full | `@file-viewer/jquery-full` | ESM, 类型声明 | [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) | 无 |
87
- | Svelte | `@file-viewer/svelte` | Svelte 组件, ESM, 类型声明 | [file-viewer-svelte](https://github.com/flyfish-dev/file-viewer-svelte) | [file-viewer-svelte](https://gitee.com/flyfish-dev/file-viewer-svelte) | 无 |
88
- | Svelte Full | `@file-viewer/svelte-full` | Svelte 组件, ESM, 类型声明 | [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) | 无 |
89
-
90
- ## 格式支持矩阵
91
-
92
- 共享格式目录当前注册 275 个扩展名(225 个稳定、50 个实验),映射到 47 条预览链路。实验格式不计入稳定支持数量;完整能力通过 renderer / preset 按需装配。
93
-
94
- | 预览链路 | 分类 | 扩展名 | 等级 / 状态 | 能力 | 加载 |
92
+ | 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` |
93
+ | 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 |
94
+ | 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` |
95
+ | 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 |
96
+ | 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` |
97
+ | 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 |
98
+ | 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 |
99
+ | 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 |
100
+ | 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` |
101
+ | 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 |
102
+ | 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 |
103
+ | 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 |
104
+ | 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 |
105
+ | 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 |
106
+ | 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 |
107
+ | 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 |
108
+
109
+ ## Format Support Matrix
110
+
111
+ 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.
112
+
113
+ | Preview pipeline | Category | Extensions | Level / status | Capabilities | Loading |
95
114
  | --- | --- | --- | --- | --- | --- |
96
- | Word OpenXML | office | `.docx`, `.docm`, `.dotx`, `.dotm` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
97
- | Word Binary | office | `.doc`, `.dot` | structured / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
98
- | PowerPoint 97–2003 | office | `.ppt`, `.pot` | structured / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider) | 按需异步 |
99
- | PowerPoint OpenXML | office | `.pptx`, `.pptm`, `.potx`, `.potm`, `.ppsx`, `.ppsm` | high-fidelity / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
100
- | Open Document | office | `.rtf`, `.odt`, `.odp` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
101
- | Spreadsheet | office | `.xlsx`, `.xltx`, `.xlsm`, `.xlsb`, `.xls`, `.xlt`, `.xla`, `.xlam`, `.xltm`, `.csv`, `.tsv`, `.ods`, `.fods` | structured / stable | 下载, 缩放(Provider), 搜索 | 按需异步 |
102
- | Apple Pages | office | `.pages` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
103
- | Apple Numbers | office | `.numbers` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
104
- | Apple Keynote | office | `.key` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
105
- | WordPerfect | office | `.wpd`, `.wp`, `.wp5`, `.wp6` | structured / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
106
- | dBASE Table | office | `.dbf` | structured / stable | 下载, 缩放(Provider), 搜索 | 按需异步 |
107
- | PDF | document | `.pdf` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索(Provider) | 按需异步 |
108
- | OFD | document | `.ofd` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
109
- | Hancom Hangul | office | `.hwp`, `.hwpx` | structured / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
110
- | Typst | document | `.typ`, `.typst` | high-fidelity / stable | 下载, 打印(适配器), HTML(适配器), 缩放(Provider), 搜索 | 按需异步 |
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 | 下载, 打印(适配器), HTML(适配器), 搜索 | 按需异步 |
113
- | Email | email | `.eml`, `.msg`, `.mbox` | structured / stable | 下载, HTML, 搜索 | 按需异步 |
114
- | EDA | eda | `.olb`, `.dra`, `.gds`, `.oas`, `.oasis` | structured / stable | 下载, 打印, HTML, 搜索 | 按需异步 |
115
- | CAD | cad | `.dxf`, `.dwg`, `.dwf`, `.dwfx`, `.xps` | high-fidelity / stable | 下载, 打印, HTML, 缩放(Provider) | 按需异步 |
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 | 下载, 缩放(Provider) | 按需异步 |
117
- | Geospatial | geo | `.geojson`, `.kml`, `.gpx`, `.shp` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
118
- | Drawing | drawing | `.excalidraw`, `.drawio`, `.dio`, `.mermaid`, `.mmd`, `.plantuml`, `.puml` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
119
- | BPMN 2.0 | drawing | `.bpmn` | structured / experimental | 下载, 缩放(Provider) | 按需异步 |
120
- | Mind Map | mindmap | `.xmind` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
121
- | EPUB | ebook | `.epub` | high-fidelity / stable | 下载, HTML, 搜索(Provider) | 按需异步 |
122
- | FictionBook | ebook | `.fb2` | structured / stable | 下载, 打印, HTML, 搜索 | 按需异步 |
123
- | UMD | ebook | `.umd` | structured / stable | 下载, 打印, HTML, 缩放(Provider), 搜索 | 按需异步 |
124
- | Image | image | `.gif`, `.jpg`, `.jpeg`, `.bmp`, `.tiff`, `.tif`, `.png`, `.svg`, `.webp`, `.avif`, `.ico`, `.heic`, `.heif`, `.jxl` | high-fidelity / stable | 下载, 打印, HTML, 缩放(Provider) | 按需异步 |
125
- | DICOM | medical-image | `.dcm`, `.dicom` | basic / experimental | 下载, 缩放(Provider) | 按需异步 |
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 | 下载, 打印, HTML, 搜索 | 按需异步 |
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 | 下载, 打印, HTML, 搜索 | 按需异步 |
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`(增强 `data-asset`) | experimental / experimental | 下载, 打印, 缩放 | 按需异步 |
132
- | Adobe Illustrator AI/AIT | asset | `.ait`, `.ai`(增强 `data-asset`) | experimental / experimental | 下载, 打印, 缩放, 搜索 | 按需异步 |
133
- | Adobe InDesign IDML | asset | `.idml` | experimental / experimental | 下载, 打印, 缩放 | 按需异步 |
134
- | Adobe InCopy and InDesign Exchange | asset | `.icml`, `.idms`, `.inx` | structured / experimental | 下载, 打印, HTML, 搜索 | 按需异步 |
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`(增强 `data-asset`) | experimental / experimental | 下载, 打印, 缩放 | 按需异步 |
139
- | Adobe Color Palettes | asset | `.ase`, `.aco` | structured / stable | 下载, 打印, HTML, 搜索 | 按需异步 |
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 | 下载, HTML, 搜索 | 按需异步 |
142
- | Binary Inspector | asset | `.bin`, `.hex`, `.elf`, `.exe`, `.dll`, `.class`, `.macho` | structured / experimental | 下载 | 按需异步 |
143
-
144
- ## 工程级按需 renderer 装配
145
-
146
- 快速开始的核心是先跑通组件,再明确格式能力边界。推荐先安装当前生态组件包,再按产品形态选择 `@file-viewer/preset-lite`、`@file-viewer/preset-office`、`@file-viewer/preset-engineering` 或 `@file-viewer/preset-all`。Webpack、Rspack、Rollup、Umi、传统多页应用等非 Vite 项目,优先通过 `options.preset` 或 `options.renderers` 显式注入能力;Vite 插件只是进一步省掉手动 import 并复制离线资产。
115
+ | Word OpenXML | office | `.docx`, `.docm`, `.dotx`, `.dotm` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
116
+ | Word Binary | office | `.doc`, `.dot` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
117
+ | PowerPoint 97–2003 | office | `.ppt`, `.pot` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider) | lazy async |
118
+ | PowerPoint OpenXML | office | `.pptx`, `.pptm`, `.potx`, `.potm`, `.ppsx`, `.ppsm` | high-fidelity / stable | download, print, HTML export, zoom(provider), search | lazy async |
119
+ | Open Document | office | `.rtf`, `.odt`, `.odp` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
120
+ | Spreadsheet | office | `.xlsx`, `.xltx`, `.xlsm`, `.xlsb`, `.xls`, `.xlt`, `.xla`, `.xlam`, `.xltm`, `.csv`, `.tsv`, `.ods`, `.fods` | structured / stable | download, zoom(provider), search | lazy async |
121
+ | Apple Pages | office | `.pages` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
122
+ | Apple Numbers | office | `.numbers` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
123
+ | Apple Keynote | office | `.key` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
124
+ | WordPerfect | office | `.wpd`, `.wp`, `.wp5`, `.wp6` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
125
+ | dBASE Table | office | `.dbf` | structured / stable | download, zoom(provider), search | lazy async |
126
+ | PDF | document | `.pdf` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search(provider) | lazy async |
127
+ | OFD | document | `.ofd` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
128
+ | Hancom Hangul | office | `.hwp`, `.hwpx` | structured / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
129
+ | Typst | document | `.typ`, `.typst` | high-fidelity / stable | download, print(adapter), HTML export(adapter), zoom(provider), search | lazy async |
130
+ | 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 |
131
+ | Compiled HTML Help | ebook | `.chm` | structured / stable | download, print(adapter), HTML export(adapter), search | lazy async |
132
+ | Email | email | `.eml`, `.msg`, `.mbox` | structured / stable | download, HTML export, search | lazy async |
133
+ | EDA | eda | `.olb`, `.dra`, `.gds`, `.oas`, `.oasis` | structured / stable | download, print, HTML export, search | lazy async |
134
+ | CAD | cad | `.dxf`, `.dwg`, `.dwf`, `.dwfx`, `.xps` | high-fidelity / stable | download, print, HTML export, zoom(provider) | lazy async |
135
+ | 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 |
136
+ | Geospatial | geo | `.geojson`, `.kml`, `.gpx`, `.shp` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
137
+ | Drawing | drawing | `.excalidraw`, `.drawio`, `.dio`, `.mermaid`, `.mmd`, `.plantuml`, `.puml` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
138
+ | BPMN 2.0 | drawing | `.bpmn` | structured / experimental | download, zoom(provider) | lazy async |
139
+ | Mind Map | mindmap | `.xmind` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
140
+ | EPUB | ebook | `.epub` | high-fidelity / stable | download, HTML export, search(provider) | lazy async |
141
+ | FictionBook | ebook | `.fb2` | structured / stable | download, print, HTML export, search | lazy async |
142
+ | UMD | ebook | `.umd` | structured / stable | download, print, HTML export, zoom(provider), search | lazy async |
143
+ | 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 |
144
+ | DICOM | medical-image | `.dcm`, `.dicom` | basic / experimental | download, zoom(provider) | lazy async |
145
+ | 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 |
146
+ | Markdown | markdown | `.md`, `.markdown` | structured / stable | download, print, HTML export, search | lazy async |
147
+ | 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 |
148
+ | Video | media | `.mp4`, `.webm`, `.m3u8` | high-fidelity / stable | download | lazy async |
149
+ | Audio | media | `.mp3`, `.mpeg`, `.wav`, `.ogg`, `.oga`, `.opus`, `.m4a`, `.aac`, `.flac`, `.weba`, `.midi`, `.mid` | high-fidelity / stable | download | lazy async |
150
+ | Adobe Photoshop | asset | `.psb`, `.pdd`, `.psdt`, `.psd` (enhances `data-asset`) | experimental / experimental | download, print, zoom | lazy async |
151
+ | Adobe Illustrator AI/AIT | asset | `.ait`, `.ai` (enhances `data-asset`) | experimental / experimental | download, print, zoom, search | lazy async |
152
+ | Adobe InDesign IDML | asset | `.idml` | experimental / experimental | download, print, zoom | lazy async |
153
+ | Adobe InCopy and InDesign Exchange | asset | `.icml`, `.idms`, `.inx` | structured / experimental | download, print, HTML export, search | lazy async |
154
+ | Adobe Animate XFL | asset | `.fla`, `.xfl` | structured / experimental | download | lazy async |
155
+ | Adobe XD Package | asset | `.xd` | structured / experimental | download | lazy async |
156
+ | Adobe InDesign Native | asset | `.indd`, `.indt` | structured / experimental | download | lazy async |
157
+ | Adobe EPS and PostScript | asset | `.ps`, `.eps` (enhances `data-asset`) | experimental / experimental | download, print, zoom | lazy async |
158
+ | Adobe Color Palettes | asset | `.ase`, `.aco` | structured / stable | download, print, HTML export, search | lazy async |
159
+ | Adobe Photoshop Resources and Presets | asset | `.abr`, `.csh`, `.pat`, `.grd`, `.asl` | structured / experimental | download, print, search | lazy async |
160
+ | Data Asset | asset | `.ttf`, `.otf`, `.woff`, `.woff2`, `.psd`, `.ai`, `.eps`, `.sqlite`, `.wasm`, `.parquet`, `.avro`, `.webarchive` | structured / stable | download, HTML export, search | lazy async |
161
+ | Binary Inspector | asset | `.bin`, `.hex`, `.elf`, `.exe`, `.dll`, `.class`, `.macho` | structured / experimental | download | lazy async |
162
+
163
+ ## Engineering-Grade On-Demand Renderer Assembly
164
+
165
+ 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
166
 
148
167
  ```bash
149
168
  npm i @file-viewer/vue3 @file-viewer/preset-office
@@ -158,7 +177,7 @@ const options = {
158
177
  }
159
178
  ```
160
179
 
161
- 需要组合办公文档与工程图纸等能力时,继续使用同一个 `preset` 字段传数组即可:
180
+ When a product combines Office documents with engineering drawings, keep the same `preset` field and pass an array:
162
181
 
163
182
  ```ts
164
183
  import officePreset from '@file-viewer/preset-office'
@@ -170,7 +189,7 @@ const options = {
170
189
  }
171
190
  ```
172
191
 
173
- 如果只需要少数格式,也可以安装单 renderer 并传给 `options.renderers`:
192
+ For exact small cuts, install one renderer and pass it through `options.renderers`:
174
193
 
175
194
  ```ts
176
195
  import { pdfRenderer } from '@file-viewer/renderer-pdf'
@@ -181,7 +200,7 @@ const options = {
181
200
  }
182
201
  ```
183
202
 
184
- Vite 项目可以再加插件,插件会免配置发现已安装 preset、注入 virtual module,并按命中格式复制 Worker / WASM / 字体 / vendor 资源:
203
+ Vite projects can add the plugin. It auto-discovers installed presets, injects the virtual module, and copies matching Worker / WASM / font / vendor assets:
185
204
 
186
205
  ```bash
187
206
  npm i -D @file-viewer/vite-plugin
@@ -194,31 +213,31 @@ export default {
194
213
  plugins: [
195
214
  fileViewerRenderers({
196
215
  copyAssets: true
197
- // 无需 preset 配置:插件会自动发现已安装的 @file-viewer/preset-office。
216
+ // No preset option required: the plugin discovers installed @file-viewer/preset-office.
198
217
  })
199
218
  ]
200
219
  }
201
220
  ```
202
221
 
203
- 重度用户需要一次拥有官方 Demo 的完整能力时,直接把 preset 换成全量包;非 Vite 项目继续传 `options.preset`,Vite 配置也保持不变:
222
+ 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
223
 
205
224
  ```bash
206
225
  npm i @file-viewer/vue3 @file-viewer/preset-all
207
226
  ```
208
227
 
209
- 需要自定义装配时,再显式配置插件:
228
+ Use explicit plugin options only when you need customization:
210
229
 
211
230
  ```ts
212
231
  fileViewerRenderers({
213
- preset: 'auto', // 同时开启源码扫描时,仍自动发现已安装 preset
214
- scan: true, // 识别 fileViewerFormats、data-file-viewer-formats、accept
215
- formats: ['pdf'], // 在已安装 preset 之外额外补充精确 renderer
232
+ preset: 'auto', // keep installed preset auto-discovery while scanning source hints
233
+ scan: true, // detects fileViewerFormats, data-file-viewer-formats, and accept
234
+ formats: ['pdf'], // adds exact renderers outside the installed preset
216
235
  copyAssets: true,
217
236
  chunkStrategy: 'renderer'
218
237
  })
219
238
  ```
220
239
 
221
- 严格裁剪或组件库内部测试时,可以关闭自动注入并显式传入 virtual module:
240
+ For strict custom cuts or component-library tests, disable injection and pass the virtual module explicitly:
222
241
 
223
242
  ```ts
224
243
  // vite.config.ts
@@ -226,7 +245,7 @@ fileViewerRenderers({ formats: ['pdf'], inject: false, copyAssets: true })
226
245
  ```
227
246
 
228
247
  ```ts
229
- // 业务组件入口
248
+ // Application viewer entry
230
249
  import { configuredFileViewerRenderers } from 'virtual:file-viewer-renderers'
231
250
 
232
251
  const options = {
@@ -235,81 +254,81 @@ const options = {
235
254
  }
236
255
  ```
237
256
 
238
- - Vue、React、Svelte、jQuery、Vanilla JS / Pure Web 都传同一份 `options`,只是在各自生态中映射为 props、hook、action、plugin 或 `mountViewer(...)` 参数。
239
- - `preset-lite` 面向文本、Markdown、代码、图片和音视频;`preset-office` 面向 PDF / Word / Excel / PowerPoint / OFD;`preset-engineering` 面向 CAD / 3D / 绘图 / XMind / Geo / Typst / EDA / Data。
240
- - 想要最小包体时,可以不用 preset,直接安装 `@file-viewer/renderer-pdf`、`@file-viewer/renderer-word` 等单个 renderer,并通过 `options.renderers` 手动注入。
241
- - `fileViewerRenderers()` 或 `fileViewerRenderers({ copyAssets:true })` 会免配置自动发现已安装 preset;如果同时开启 `scan:true`,请使用 `preset:'auto'` 或 `autoPresets:true` 保留 preset 自动发现。
242
- - `scan:true` 会识别 `fileViewerFormats`、`data-file-viewer-formats` 和上传控件 `accept`,调试与打包时自动选择 renderer。
243
- - `copyAssets:true` 会复制 PDF/CAD/Typst/Archive/Data 等 worker、WASM 和 vendor 资源,满足离线和企业内网部署;压缩包目录会优先使用 `vendor/libarchive/worker-bundle.js` / `libarchive.wasm`,Worker 不可用时只对 ZIP/TAR/GZIP 进入兼容路径。
244
- - `builtinRenderers` 仍可用于高级基线控制或历史兼容;普通快速接入只需要 `preset` / `renderers` 与 `rendererMode`。
245
- - 如果打开的是支持矩阵内但未装配的格式,预览器会提示应安装的 preset / renderer;只有真正不在矩阵中的扩展名才提示不支持。
246
- - `@file-viewer/preset-all` 提供完整 renderer 矩阵;Worker、WASM、字体和 vendor 资源仍需通过 Vite 插件或 `file-viewer-copy-assets` 发布。`*-full` 包已内置该 preset,不要重复安装。
257
+ - 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.
258
+ - `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.
259
+ - 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`.
260
+ - `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.
261
+ - `scan:true` detects `fileViewerFormats`, `data-file-viewer-formats`, and upload `accept` hints so development and production builds select matching renderers automatically.
262
+ - `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.
263
+ - `builtinRenderers` remains available for advanced baseline control or historical compatibility. Normal quick starts only need `preset` / `renderers` plus `rendererMode`.
264
+ - 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.
265
+ - `@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
266
 
248
- ## 统一参数与事件
267
+ ## Shared Options And Events
249
268
 
250
- 所有生态组件都围绕同一套 `ViewerMountOptions` 与 `FileViewerOptions` 工作,只是映射到各自框架的 props、事件、ref、action 或插件 API。
269
+ Every ecosystem package uses the same `ViewerMountOptions` and `FileViewerOptions` semantics, mapped to framework-native props, events, refs, actions, or plugin APIs.
251
270
 
252
- | 参数 | 说明 |
271
+ | Option | Description |
253
272
  | --- | --- |
254
- | `url` | 远程文件地址,适合对象存储、业务接口或内网文件服务返回的文件链接。 |
255
- | `file` | `File`、`Blob` 或 `ArrayBuffer`,适合上传、本地选择和业务接口已取回的二进制。 |
256
- | `buffer` | 直接传入 `ArrayBuffer`,适合解密、鉴权或自定义下载后再预览。 |
257
- | `name` / `filename` | 显示文件名并辅助推断扩展名;当 URL 不含扩展名时建议显式传入。 |
258
- | `type` | 显式指定扩展名或 MIME 线索,覆盖自动识别结果。 |
259
- | `size` | 文件大小提示,用于生命周期上下文、加载状态和安全限制展示。 |
260
- | `options` | 完整 `FileViewerOptions`,所有框架包保持同一套参数语义。 |
261
- | `options.styleIsolation` | `auto`、`shadow`、`scoped` 或 `none`。所有标准组件的 `auto` 默认使用 Shadow DOM,阻止宿主全局样式破坏工具栏和正文;旧项目可显式使用 `none`。 |
262
- | `onEvent` / `onStateChange` | Vanilla JS / Pure Web、React、Svelte 等命令式包装层的统一事件和状态订阅;Vue 组件会映射为原生 emit。 |
273
+ | `url` | Remote file URL from object storage, business APIs, or intranet file services. |
274
+ | `file` | `File`, `Blob`, or `ArrayBuffer` for uploads, local selection, or already-fetched binary data. |
275
+ | `buffer` | Direct `ArrayBuffer` input after custom download, authorization, or decryption. |
276
+ | `name` / `filename` | Display name and extension hint. Pass it explicitly when the URL has no useful extension. |
277
+ | `type` | Explicit extension or MIME hint that overrides automatic detection. |
278
+ | `size` | File size hint used in lifecycle context, loading states, and safety limits. |
279
+ | `options` | The shared `FileViewerOptions` surface. Every component package keeps the same semantics. |
280
+ | `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`. |
281
+ | `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
282
 
264
- ## 实际组件属性
283
+ ## Actual Component Props
265
284
 
266
- 下面列的是每个标准组件包当前真实暴露的属性、事件和控制入口。需要 `buffer`、`name`、`type`、`size` 这类命令式挂载参数时,优先选择 Vanilla JS / Pure Web、React、Svelte、jQuery 或 Vue2 组件;Vue3 声明式组件保持 `url` / `file` / `options` 的简洁入口,复杂二进制来源请包装成带文件名的 `File`。
285
+ 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
286
 
268
- | 组件 | 实际属性 / 入口 | 事件入口 | 定制入口 |
287
+ | Component | Actual props / entry | Event channel | Customization entry |
269
288
  | --- | --- | --- | --- |
270
- | Vanilla JS / Pure Web `@file-viewer/web` | `<flyfish-file-viewer>` 属性 `src/url`、`filename/name`、`type`、`size`、`theme`、`toolbar`、`toolbar-position`、`watermark`、`search`、`options`;也支持 `mountViewer(...)` | `viewer-ready`、`viewer-event`、`viewer-state-change`、`viewer-error`、`onEvent`、`onStateChange`、`controller.subscribe()` | Custom Element 实例暴露完整 controller handle;IIFE script 标签会自动注册元素,同时保留 `mountViewer` 命令式挂载和资源复制 CLI。 |
271
- | 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` | 模板 `ref` 暴露 `FileViewerExpose`;适合声明式接入。`Blob` / `ArrayBuffer` 建议包装成带扩展名的 `File` 后传给 `file`。 |
272
- | Vue 2.7 `@file-viewer/vue2.7` | `url`、`file`、`buffer`、`name`、`filename`、`type`、`size`、`options`、`containerClass`、`containerStyle` | `viewer-event` / `viewerEvent` | 组件实例暴露 controller handle 全量方法;适合 Vue 2.7 项目和历史 `@flyfish-group/file-viewer` 平滑升级。 |
273
- | Vue 2.6 `@file-viewer/vue2.6` | 同 Vue 2.7 | `viewer-event` / `viewerEvent` | 独立 Vue 2.6 构建,不要求业务升级到 Vue 2.7。 |
274
- | React `@file-viewer/react` | `ViewerMountOptions` + `div` 原生属性,如 `className`、`style`、`data-*`、`aria-*` | `onEvent`、`onStateChange` | `ref` 暴露 `FileViewerHandle`;`useFileViewer()` 会返回 `ref`、`props`、`state`、`handle`,便于自定义工具栏。 |
275
- | React Legacy `@file-viewer/react-legacy` | 同 React 标准包 | `onEvent`、`onStateChange` | 面向 React 16.8 / 17;组件名和默认导出保持 legacy 生态友好。 |
276
- | jQuery `@file-viewer/jquery` | `$(el).fileViewer(ViewerMountOptions & { replace?: boolean })` | `onEvent`、`onStateChange` 或 `getFileViewerController(el).subscribe()` | 插件方法支持 `zoomIn`、`printRenderedHtml`、`searchDocument` 等;`replace:false` 可在同一节点上原地更新。 |
277
- | Svelte `@file-viewer/svelte` | `ViewerMountOptions` + `className`、`containerStyle` | `on:viewerEvent`、`onEvent`、`onStateChange` | `bind:this` 暴露 controller handle;也提供 `use:fileViewer` action,action 额外支持 `replace`。 |
278
-
279
- | Options 字段 | 说明 |
289
+ | 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. |
290
+ | 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. |
291
+ | 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. |
292
+ | 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. |
293
+ | 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. |
294
+ | React Legacy `@file-viewer/react-legacy` | Same as the React package | `onEvent`, `onStateChange` | Targets React 16.8 / 17 with a legacy-friendly component export. |
295
+ | 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. |
296
+ | 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`. |
297
+
298
+ | Options Field | Description |
280
299
  | --- | --- |
281
- | `theme` | `light`、`dark` 或 `system`,优先级高于浏览器 `prefers-color-scheme`。 |
282
- | `styleIsolation` | `auto`、`shadow`、`scoped` 或 `none`。`auto` 下 Web Component、IIFE、Vue、React、Svelte、jQuery 和 full 包均默认使用 Shadow DOM;依赖深层 class 覆盖的旧项目可显式使用 `none`。 |
283
- | `watermark` | 开启文字或图片水印,可设置透明度、旋转、间距、尺寸、字体和颜色。 |
284
- | `toolbar` | 控制主题切换、下载、打印、HTML 导出、缩放、按钮顺序和工具栏位置,并支持操作级前置校验。 |
285
- | `search` | 配置文档搜索、高亮 class、大小写、整词匹配、最大命中数和 debounce。 |
286
- | `ai` | 控制文本结构采集、分块大小和最大文本长度,为溯源、定位、向量化和外部 AI 流程提供基础。 |
287
- | `archive` | 配置压缩包 Worker/WASM、超时、缓存、包体限制和压缩包内单文件预览大小;旧 ZIP 中文文件名会自动按 GBK/GB18030 兼容解码。 |
288
- | `pdf` | 配置 PDF.js Worker、导航栏、目录、缩略图、旋转、流式读取、Range chunk 和凭据。 |
289
- | `docx` / `spreadsheet` | DOCX 由 @file-viewer/renderer-word 承接并使用自研 @file-viewer/docx,默认自动选择 Worker 或主线程解析,连续流式阅读和异步分批渲染,可按需显式开启视觉分页;表格由 @file-viewer/renderer-spreadsheet 承接,默认保真解析,大文件自动启用 Worker,表头拖拽调列宽可按需显式开启。 |
290
- | `iwork` | 显式安装 iWork capability 后,配置 Pages / Numbers / Keynote 的模块 Worker、超时、ZIP/Snappy/IWA 安全上限与 Quick Look 降级策略;它不属于 standard/full 默认闭包。 |
291
- | `hangul` | 显式安装 Hangul capability 后,配置 HWP/HWPX 模块 Worker、超时、ZIP 解压/压缩率/条目数与 HWP 记录数安全上限;它不属于 standard/full 默认闭包。 |
292
- | `wordPerfect` | 显式安装 WordPerfect capability 后,配置 Worker、libwpd/librevenge WASM 地址与超时;它不属于 standard/full 默认闭包。 |
293
- | `presentation` | standard/full 默认只装配 PPTX/OpenXML 的 `@file-viewer/pptx` Worker,可通过 `workerUrl` / `workerType` 覆盖。PowerPoint 97–2003 `.ppt` 是独立重型 capability,需用 `file-viewer add ppt --write` 显式安装其 Worker/WASM 和资产。 |
294
- | `typst` / `data` / `cad` | 显式安装相应 capability 后,配置 Typst、SQLite、CAD/DWG/DXF/DWF 等 WASM、Worker、编码和渲染策略;这些能力不属于 standard/full 默认闭包。 |
295
- | `hooks` / `beforeOperation` | 统一生命周期 hooks 和操作前置校验,可用于审计、权限、埋点和安全控制。 |
296
-
297
- ## 样式隔离与主题定制
298
-
299
- 所有标准组件默认使用 Shadow DOM 强隔离。宿主页面里的 `*`、`button`、`table`、`img`、`svg`、`canvas` 等全局样式不会直接侵入预览器工具栏和正文;预览器也不会把局部 reset 粗暴写到业务页面。
300
-
301
- | 模式 | 说明 |
300
+ | `theme` | `light`, `dark`, or `system`. This takes precedence over browser `prefers-color-scheme`. |
301
+ | `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`. |
302
+ | `watermark` | Text or image watermark with opacity, rotation, gap, size, font, and color controls. |
303
+ | `toolbar` | Controls the theme toggle, download, print, HTML export, zoom, item order, toolbar position, and operation-level preflight checks. |
304
+ | `search` | Document search, highlight class names, case sensitivity, whole-word matching, max matches, and debounce. |
305
+ | `ai` | Text collection, chunk size, and max text length for provenance, location, vectorization, and external AI workflows. |
306
+ | `archive` | Archive Worker/WASM URLs, timeout, cache, archive limits, nested entry preview limits, and legacy GBK/GB18030 ZIP filename decoding. |
307
+ | `pdf` | PDF.js worker, navigation pane, outline, thumbnails, rotation, streaming, range chunk size, and credentials. |
308
+ | `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. |
309
+ | `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. |
310
+ | `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. |
311
+ | `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. |
312
+ | `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. |
313
+ | `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. |
314
+ | `hooks` / `beforeOperation` | Shared lifecycle hooks and operation preflight checks for audit, permission, telemetry, and safety controls. |
315
+
316
+ ## Style Isolation And Theme Customization
317
+
318
+ 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.
319
+
320
+ | Mode | Description |
302
321
  | --- | --- |
303
- | `auto` | 默认值。Web Component、IIFE、Vue、React、Svelte、jQuery 和 full 包均走 Shadow DOM,保护工具栏与 renderer 内容不受宿主全局 CSS 影响。 |
304
- | `shadow` | 显式创建 ShadowRoot 作为渲染面,适合宿主 CSS 不可控、微前端混挂、低代码平台和设计系统全局 reset 很强的页面。 |
305
- | `scoped` | 不创建 ShadowRoot,使用稳定根选择器和局部 reset 约束影响范围,适合需要被外层 CSS 轻度继承的场景。 |
306
- | `none` | 历史 light DOM 行为,保留给依赖深度 class 覆盖、旧主题 CSS 或自动化测试快照的项目。 |
322
+ | `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. |
323
+ | `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. |
324
+ | `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. |
325
+ | `none` | Historical light-DOM behavior for projects that depend on deep class overrides, old theme CSS, or snapshot tests. |
307
326
 
308
- `styleIsolation` 是挂载边界配置;运行时切换模式时请重新挂载组件。`scoped` 与 `none` 都属于 Light DOM,仍可能被宿主的高权重或 `!important` 全局规则覆盖。
327
+ `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
328
 
310
- 定制优先级建议是:先使用 `--file-viewer-*` CSS 变量覆盖颜色、字体、间距、圆角、工具栏和按钮;需要命中内部结构时再使用稳定 Shadow Parts。当前 Web shell 暴露 `host`、`shell`、`toolbar`、`toolbar-group`、`toolbar-status`、`button`、`input` 和 `content`,后续 renderer 扩展应继续使用 `state-panel`、`watermark` 这类稳定命名。不要依赖内部 class 名,它们只服务实现细节。
329
+ 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
330
 
312
- 下面的 `file-viewer-host` 是实际 Shadow host 的 class:Vue 3 通过 `class`,Vue 2 通过 `containerClass`,React / Svelte 通过 `className` 传入,jQuery 则直接加在初始化节点上。
331
+ 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
332
 
314
333
  ```css
315
334
  .file-viewer-host {
@@ -329,7 +348,7 @@ const options = {
329
348
  }
330
349
  ```
331
350
 
332
- 框架组件无需额外配置即可使用 Shadow DOM;也可以在 `options` 中显式声明以固定策略:
351
+ Framework packages use Shadow DOM without extra configuration; set it explicitly when you want to lock the policy:
333
352
 
334
353
  ```ts
335
354
  const options = {
@@ -339,89 +358,89 @@ const options = {
339
358
  }
340
359
  ```
341
360
 
342
- ## 工具栏定制
361
+ ## Toolbar Customization
343
362
 
344
- | 配置 | 说明 |
363
+ | Config | Description |
345
364
  | --- | --- |
346
- | `toolbar: false` | 隐藏内置工具栏,但不关闭下载、打印、导出、缩放等 controller API,适合完全自定义业务工具栏。 |
347
- | `toolbar: true` | 使用默认内置工具栏;主题切换默认显示,下载、打印、HTML 导出和缩放按钮按能力动态显隐。 |
348
- | `download` / `print` / `exportHtml` / `zoom` | 表达业务是否允许展示对应按钮;最终仍会结合文件类型、渲染完成状态、导出适配器和缩放 provider 计算真实可用性。 |
349
- | `theme` | 控制浅色/深色切换按钮,默认 `true`;切换后触发 `theme-change`,传 `false` 可隐藏。 |
350
- | `order` | 设置内置分组顺序,可使用 `search`、`zoom`、`download`、`print`、`exportHtml`、`theme`;遗漏项保持默认相对顺序。 |
351
- | `position` | `auto`、`top`、`top-center`、`bottom-right`。默认 `auto`,PDF 自动悬浮右下角,其他格式保持顶部靠右;需要顶部水平居中时传 `top-center`。 |
352
- | `beforeOperation` | 工具栏层统一前置校验,会在 `options.beforeOperation` 后执行。返回 `false` 或抛错都会取消本次操作。 |
353
- | `beforeDownload` / `beforePrint` / `beforeExportHtml` | 单按钮前置校验;适合下载权限、打印审计、导出水印确认等细粒度业务规则。 |
365
+ | `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. |
366
+ | `toolbar: true` | Uses the default built-in toolbar. The theme toggle is visible by default; download, print, HTML export, and zoom remain capability-aware. |
367
+ | `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. |
368
+ | `theme` | Controls the light/dark toggle and defaults to `true`. A change emits `theme-change`; set it to `false` to hide the button. |
369
+ | `order` | Orders built-in groups with `search`, `zoom`, `download`, `print`, `exportHtml`, and `theme`. Omitted items keep their default relative order. |
370
+ | `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. |
371
+ | `beforeOperation` | Toolbar-level preflight that runs after `options.beforeOperation`. Returning `false` or throwing cancels the operation. |
372
+ | `beforeDownload` / `beforePrint` / `beforeExportHtml` | Operation-specific preflight for download permission, print audit, export confirmation, and similar business rules. |
354
373
 
355
- 完全自定义工具栏时,推荐关闭内置工具栏并使用组件 ref / controller 暴露的标准 API。不要在预览器外层用 CSS `transform: scale()` 做缩放;PDF、Excel、CAD、canvas 和文本层格式都应通过内部缩放 provider 保持坐标正确。
374
+ 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
375
 
357
- 缩放状态由各格式 renderer 的内部 provider 上报。首屏自适应、容器尺寸变化或 PDF / Word / 图片等异步布局完成后,内置工具栏会显示真实缩放比例,而不是固定显示 `100%`;自定义工具栏也应监听 `zoom-change` / `operation-availability-change`,或读取 `getZoomState()` / `getOperationAvailability()`。
376
+ 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
377
 
359
- 视图状态同步用于投屏、双端协同和恢复阅读进度。所有标准 renderer loader 都会获得通用 view-state provider,至少记录 `renderer`、缩放和滚动位置;PDF、XMind、Geo、3D、CAD 等高交互路径会补充页码、导航、画布 pan、地图中心、相机视角或底层视图快照。初始化可传 `options.initialViewState`,运行中监听 `view-state-change`;Pure Web / Vue3 controller 还可直接调用 `getViewState()` 与 `applyViewState(state, { source: "api", action: "restore" })`。
378
+ 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
379
 
361
- | 生态 | 推荐方式 |
380
+ | Ecosystem | Recommended pattern |
362
381
  | --- | --- |
363
- | Vanilla JS / Pure Web | `<flyfish-file-viewer toolbar="false">` 或 `mountViewer(container, { options:{ toolbar:false }, onStateChange })`;外部 DOM 按钮可直接调用元素实例 / controller 的 `zoomIn()`、`printRenderedHtml()`、`searchDocument()` 等方法,复杂场景用 `viewer-state-change` 或 `controller.subscribe()` 同步状态。 |
364
- | Vue 3 | 传 `:options="{ toolbar: false }"` 隐藏内置工具栏,通过模板 `ref` 调用 `downloadOriginalFile()`、`printRenderedHtml()`、`exportRenderedHtml()`、`zoomIn()`、`zoomOut()`、`resetZoom()`;用 `@operation-availability-change` 和 `@zoom-change` 同步按钮显隐与比例。 |
365
- | Vue 2.7 / 2.6 | 同样设置 `toolbar:false`,通过 `$refs.viewer` 调用实例方法;监听 `@viewer-event`,在 `event.type === "operation-availability-change"` 或 `event.type === "zoom-change"` 时更新外部工具栏。 |
366
- | React / React Legacy | 推荐 `useFileViewer({ options:{ toolbar:false } })`,把 `viewer.props` 传给组件,把按钮绑定到 `viewer.handle`,并读取 `viewer.state.availability` / `viewer.state.zoom` 控制禁用状态。 |
367
- | jQuery | `$("#viewer").fileViewer({ options:{ toolbar:false } })`;按钮调用 `$("#viewer").fileViewer("zoomIn")` 或通过 `getFileViewerController($("#viewer")).subscribe()` 获取能力状态。 |
368
- | Svelte | `<FileViewer bind:this={viewer} options={{ toolbar:false }} />`;按钮直接调用 `viewer.zoomIn()`、`viewer.printRenderedHtml()`,并用 `on:viewerEvent` / `onStateChange` 同步状态。 |
382
+ | 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. |
383
+ | 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`. |
384
+ | 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`. |
385
+ | 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`. |
386
+ | jQuery | Use `$("#viewer").fileViewer({ options:{ toolbar:false } })`; buttons can call `$("#viewer").fileViewer("zoomIn")` or read capability state through `getFileViewerController($("#viewer")).subscribe()`. |
387
+ | Svelte | Use `<FileViewer bind:this={viewer} options={{ toolbar:false }} />`; buttons call `viewer.zoomIn()` / `viewer.printRenderedHtml()`, with `on:viewerEvent` or `onStateChange` for state sync. |
369
388
 
370
- ## 生命周期与操作事件
389
+ ## Lifecycle And Operation Events
371
390
 
372
- | 事件 / hook | 说明 |
391
+ | Event / hook | Description |
373
392
  | --- | --- |
374
- | `load-start` / `hooks.onLoadStart` | 开始解析或下载文档时触发,包含文件名、类型、来源、版本、URL、File 和 size。 |
375
- | `load-complete` / `hooks.onLoadComplete` | 当前文档完成渲染时触发,包含耗时、来源上下文和版本号。 |
376
- | `unload-start` / `hooks.onUnloadStart` | 替换、重置或组件卸载前触发,可用于保存状态或释放外部资源。 |
377
- | `unload-complete` / `hooks.onUnloadComplete` | 旧文档释放完成后触发,reason 会标识 `replace`、`reset` 或 `component-unmount`。 |
378
- | `operation-before` / `operation-cancel` | 下载、打印、HTML 导出和缩放前后触发;`beforeOperation` 返回 `false` 可取消操作。 |
379
- | `operation-availability-change` | 当前格式是否可下载、可打印、可导出 HTML、可缩放发生变化时触发。 |
380
- | `theme-change` | 用户通过内置按钮切换浅色或深色模式时触发,payload 为 `light` 或 `dark`。 |
381
- | `search-change` / `location-change` / `zoom-change` / `view-state-change` | 搜索命中、定位锚点、缩放状态和完整视图快照变化时触发,用于外层同步 UI、投屏或恢复阅读进度。 |
382
-
383
- ## 公共操作 API
384
-
385
- | API | 说明 |
393
+ | `load-start` / `hooks.onLoadStart` | Fires when parsing or downloading starts. Context includes filename, type, source, version, URL, File, and size. |
394
+ | `load-complete` / `hooks.onLoadComplete` | Fires when the current document has rendered. Context includes duration, source data, and version. |
395
+ | `unload-start` / `hooks.onUnloadStart` | Fires before replace, reset, or component unmount so external state or resources can be saved. |
396
+ | `unload-complete` / `hooks.onUnloadComplete` | Fires after the previous document is released. The reason is `replace`, `reset`, or `component-unmount`. |
397
+ | `operation-before` / `operation-cancel` | Fires around download, print, HTML export, and zoom actions. Returning `false` from `beforeOperation` cancels the action. |
398
+ | `operation-availability-change` | Fires when download, print, HTML export, or zoom support changes for the active format. |
399
+ | `theme-change` | Fires when the built-in control selects light or dark mode. The payload is `light` or `dark`. |
400
+ | `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. |
401
+
402
+ ## Public Operation API
403
+
404
+ | API | Description |
386
405
  | --- | --- |
387
- | `load` / `update` / `reload` / `destroy` | 命令式控制文档加载、参数更新、重新加载和销毁。 |
388
- | `downloadOriginalFile()` | 下载原始文件,遵循 toolbar 与 `beforeOperation` 权限校验。 |
389
- | `printRenderedHtml(options?)` | 打印当前完整渲染内容,优先使用各格式的高保真打印适配器;开启水印时会一并输出,也可传入 `mask` 遮盖区域。 |
390
- | `printWithMask(options?)` | 打开掩膜设计器拖拽黑色遮盖块,确认后打印;设计器由 core 异步加载,组件开箱即用。 |
391
- | `exportRenderedHtml()` | 导出当前渲染后的 HTML,用于归档、审计和离线查看。 |
392
- | `zoomIn()` / `zoomOut()` / `resetZoom()` | 调用当前格式自己的缩放 provider,避免外层 CSS 缩放导致坐标偏移。 |
393
- | `searchDocument()` / `nextSearchResult()` / `previousSearchResult()` | 打开文档级搜索并在命中之间导航,保持高亮状态。 |
394
- | `collectDocumentAnchors()` / `scrollToAnchor()` / `scrollToLine()` | 采集页面、目录、标题或代码行锚点,并执行定位跳转。 |
395
- | `getDocumentTextChunks()` | 获取结构化文本块,便于搜索、AI 溯源、向量化和外部索引。 |
396
- | `getOperationAvailability()` / `getZoomState()` / `getSearchState()` | 读取当前能力、缩放和搜索状态,便于自定义工具栏。 |
397
-
398
- ## Worker、WASM 与私有化部署
399
-
400
- | 资源 | 说明 |
406
+ | `load` / `update` / `reload` / `destroy` | Imperatively load, update, reload, and destroy the viewer. |
407
+ | `downloadOriginalFile()` | Downloads the original file while respecting toolbar and `beforeOperation` checks. |
408
+ | `printRenderedHtml(options?)` | Prints the complete rendered document using the best available per-format print adapter. Enabled watermarks are included; pass `mask` for cover regions. |
409
+ | `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. |
410
+ | `exportRenderedHtml()` | Exports rendered HTML for archiving, audit, or offline review. |
411
+ | `zoomIn()` / `zoomOut()` / `resetZoom()` | Uses the active renderer zoom provider instead of outer CSS transforms that can break coordinates. |
412
+ | `searchDocument()` / `nextSearchResult()` / `previousSearchResult()` | Runs document-level search and navigates highlighted matches. |
413
+ | `collectDocumentAnchors()` / `scrollToAnchor()` / `scrollToLine()` | Collects pages, outline items, headings, or code-line anchors and scrolls to them. |
414
+ | `getDocumentTextChunks()` | Returns structured text chunks for search, AI provenance, vectorization, and external indexes. |
415
+ | `getOperationAvailability()` / `getZoomState()` / `getSearchState()` | Reads current capability, zoom, and search state for custom toolbars. |
416
+
417
+ ## Workers, WASM, And Private Deployment
418
+
419
+ | Asset | Description |
401
420
  | --- | --- |
402
- | Standard 资产 | `@file-viewer/assets-standard` 只复制 PDF、DOCX、PPTX、Excel/OpenXML 与 Archive 等冻结 standard 所需 Worker、WASM、字体和 vendor 文件;事务收据记录包版本、profile hash、逐文件 SHA-256 和 owner。 |
403
- | 专用资产 owner | CAD、Typst、iWork、3D、Data、Drawing、Hangul、WordPerfect 和旧版 PPT 各自使用独立 `@file-viewer/assets-*` 包。`@file-viewer/cli add <format> --write` 只选择该能力及其资产,不下载旁系格式。 |
404
- | PDF / DOCX / Excel / PPTX | standard 支持自托管 PDF.js Worker/字体、DOCX Worker、Spreadsheet Worker 与 PPTX Worker。PPTX 图表和 PDF Identity-font repair 属于正确性能力,已明确纳入 standard;不会静默省略图表或字体修复。 |
405
- | Archive / Email / 原生媒体 | Archive 的 libarchive Worker/WASM 属于 standard 资产;Email、常见图片和浏览器原生音视频按需加载代码。HLS、MIDI、RTF、Mermaid、patch/git bundle 是显式 capability,不会因 npm peer 自动安装。 |
406
- | Draw.io | 安全自研 Drawing fallback 随 renderer 提供;diagrams.net official viewer 是独立 `drawio-official` 重型 capability,不进入新项目的 standard 默认闭包。历史 `*-full` 包的已发布能力边界保持兼容。 |
407
- | 离线部署 | 运行时不依赖公共 CDN。Vite `copyAssets:true` 按已安装 asset owner 发布;其它构建工具运行 `file-viewer install --yes` 或 `file-viewer assets --write`。所有 owner 事务性合并为稳定运行时 manifest,安装顺序不影响结果。 |
408
- | 部署原则 | 新格式默认 opt-in,不会自动扩张已发布的 `*-full` 包。只有命中特定格式时才加载对应 Worker、WASM 或解析库;新项目优先使用 standard 或按需 capability,历史 full 集成继续保留原能力矩阵。 |
421
+ | 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. |
422
+ | 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. |
423
+ | 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. |
424
+ | 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. |
425
+ | 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. |
426
+ | 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. |
427
+ | 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
428
 
410
429
 
411
- ## 质量门禁
430
+ ## Quality Gates
412
431
 
413
- - 组件包只依赖 `@file-viewer/core` 和自身生态依赖,不嵌套引用其他框架组件包。
414
- - 格式解析、搜索、缩放、打印、导出、水印、生命周期和 beforeOperation 语义全部来自同一个 core。
415
- - 发布前需通过类型检查、组件 API 校验、README 生成校验、格式矩阵校验、独立仓库导出和浏览器 smoke。
432
+ - Component packages only depend on `@file-viewer/core` and their own ecosystem dependencies. They do not nest through another framework component package.
433
+ - Format parsing, search, zoom, print, export, watermark, lifecycle, and beforeOperation semantics all come from the same core.
434
+ - Releases should pass type checks, component API verification, README generation checks, format-matrix verification, standalone repository export, and browser smoke tests.
416
435
 
417
- 完整参数、生命周期 hooks、beforeOperation、主题、水印、搜索、缩放、打印和导出说明见官方文档: https://doc.file-viewer.app/
436
+ See the official documentation for options, lifecycle hooks, beforeOperation, theme, watermark, search, zoom, print, and export APIs: https://doc.file-viewer.app/
418
437
 
419
- 在线 Demo: https://demo.file-viewer.app/ 。File Viewer 自身源码与本仓生成的组件包使用 Apache-2.0;发行物若包含 `@file-viewer/ppt` 运行时,该运行时保留其独立 LICENSE 与 NOTICE,不被 Apache-2.0 重新许可。二开或商用请保留 Flyfish Viewer 来源说明;如果修复了通用兼容问题,也欢迎贡献回对应组件仓库。
438
+ 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
439
  <!-- FILE_VIEWER_GENERATED:END -->
421
440
 
422
- ## 扩展原生工具栏
441
+ ## Extending the native toolbar
423
442
 
424
- Vue 3 组件提供 `toolbar-start` 与 `toolbar-end` 插槽。它们保留内置搜索、缩放、下载、打印和主题能力,同时允许业务侧加入返回、文件信息、全屏、审核等操作。插槽属性会随预览状态响应式更新:
443
+ 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
444
 
426
445
  ```vue
427
446
  <FileViewer
@@ -433,31 +452,31 @@ Vue 3 组件提供 `toolbar-start` 与 `toolbar-end` 插槽。它们保留内置
433
452
  }"
434
453
  >
435
454
  <template #toolbar-start="{ api, availability, zoomState, searchState }">
436
- <button type="button" @click="goBack">返回</button>
455
+ <button type="button" @click="goBack">Back</button>
437
456
  <span>{{ file.name }}</span>
438
457
  </template>
439
458
 
440
459
  <template #toolbar-end="{ api }">
441
- <button type="button" @click="toggleFullscreen">全屏</button>
460
+ <button type="button" @click="toggleFullscreen">Fullscreen</button>
442
461
  </template>
443
462
  </FileViewer>
444
463
  ```
445
464
 
446
- - `api`:完整的 `FileViewer` 实例 API。
447
- - `availability`:下载、打印、导出和缩放的当前可用性。
448
- - `zoomState`:当前缩放比例及按钮状态。
449
- - `searchState`:查询、命中总数和当前命中位置。
465
+ - `api`: the complete `FileViewer` instance API.
466
+ - `availability`: current download, print, export, and zoom availability.
467
+ - `zoomState`: current scale and zoom button state.
468
+ - `searchState`: query, total matches, and current match position.
450
469
 
451
- 使用宿主页面 CSS 定制插槽内容时,建议设置 `styleIsolation: 'none'`;Shadow DOM 模式下可使用内联样式或 File Viewer CSS 变量。
470
+ 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
471
 
453
- ## 格式与相关包
472
+ ## Formats and related packages
454
473
 
455
- File Viewer 在浏览器内预览 275+ 种扩展名,覆盖 Office、PDF/OFD、CAD、3D、压缩包、邮件、图片、音视频和代码,无需服务端转码;完整清单见 [格式矩阵](https://doc.file-viewer.app/guide/formats)。
474
+ 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
475
 
457
- - 组件:`@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`,以及对应的 `-full` 包
458
- - 能力组合:`@file-viewer/preset-lite`、`@file-viewer/preset-office`、`@file-viewer/preset-engineering`、`@file-viewer/preset-all`
459
- - 构建:`@file-viewer/vite-plugin`、`file-viewer-copy-assets`
476
+ - 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
477
+ - Presets: `@file-viewer/preset-lite`, `@file-viewer/preset-office`, `@file-viewer/preset-engineering`, `@file-viewer/preset-all`
478
+ - Build: `@file-viewer/vite-plugin`, `file-viewer-copy-assets`
460
479
 
461
- ## 许可证
480
+ ## License
462
481
 
463
- 本包采用 Apache-2.0。详见 [LICENSE](https://github.com/flyfish-dev/file-viewer/blob/main/LICENSE)。
482
+ This package is Apache-2.0. See [LICENSE](https://github.com/flyfish-dev/file-viewer/blob/main/LICENSE).