@flyfish-group/file-viewer3 1.0.22 → 1.0.23

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.
Files changed (279) hide show
  1. package/README.en.md +10 -11
  2. package/README.md +20 -21
  3. package/dist/components/3MFLoader.js +1 -1
  4. package/dist/components/AMFLoader.js +1 -1
  5. package/dist/components/AudioViewer.js +1 -1
  6. package/dist/components/CadViewer.js +1 -1
  7. package/dist/components/CodeViewer.js +1 -1
  8. package/dist/components/ColladaLoader.js +1 -1
  9. package/dist/components/DrawingViewer.js +1 -1
  10. package/dist/components/EdaViewer.js +1 -1
  11. package/dist/components/EmailViewer.js +1 -1
  12. package/dist/components/EpubViewer.js +1 -1
  13. package/dist/components/FBXLoader.js +1 -1
  14. package/dist/components/GLTFLoader.js +1 -1
  15. package/dist/components/ImageViewer.js +1 -1
  16. package/dist/components/KMZLoader.js +1 -1
  17. package/dist/components/MarkdownViewer.js +1 -1
  18. package/dist/components/ModelViewer.js +1 -1
  19. package/dist/components/OBJLoader.js +1 -1
  20. package/dist/components/OfdViewer.js +1 -1
  21. package/dist/components/PCDLoader.js +1 -1
  22. package/dist/components/PLYLoader.js +1 -1
  23. package/dist/components/PdfView.js +5234 -5080
  24. package/dist/components/PptxRender.js +1 -1
  25. package/dist/components/STLLoader.js +1 -1
  26. package/dist/components/TDSLoader.js +1 -1
  27. package/dist/components/USDLoader.js +1 -1
  28. package/dist/components/UmdViewer.js +1 -1
  29. package/dist/components/VRMLLoader.js +1 -1
  30. package/dist/components/VTKLoader.js +1 -1
  31. package/dist/components/XYZLoader.js +1 -1
  32. package/dist/components/XlsxTable.js +1 -1
  33. package/dist/components/__vite-browser-external.js +1 -1
  34. package/dist/components/_plugin-vue_export-helper.js +1 -1
  35. package/dist/components/ar-SA-G6X2FPQ2.js +1 -1
  36. package/dist/components/arc.js +1 -1
  37. package/dist/components/architecture-7EHR7CIX.js +1 -1
  38. package/dist/components/architectureDiagram-3BPJPVTR.js +1 -1
  39. package/dist/components/archive.js +1 -1
  40. package/dist/components/asyncToGenerator.js +1 -1
  41. package/dist/components/audio.js +1 -1
  42. package/dist/components/az-AZ-76LH7QW2.js +1 -1
  43. package/dist/components/bash.js +1 -1
  44. package/dist/components/bg-BG-XCXSNQG7.js +1 -1
  45. package/dist/components/blockDiagram-GPEHLZMM.js +1 -1
  46. package/dist/components/bn-BD-2XOGV67Q.js +1 -1
  47. package/dist/components/c4Diagram-AAUBKEIU.js +1 -1
  48. package/dist/components/ca-ES-6MX7JW3Y.js +1 -1
  49. package/dist/components/cad.js +1 -1
  50. package/dist/components/cfb.js +1 -1
  51. package/dist/components/channel.js +1 -1
  52. package/dist/components/chunk-2J33WTMH.js +1 -1
  53. package/dist/components/chunk-3OPIFGDE.js +1 -1
  54. package/dist/components/chunk-4BX2VUAB.js +1 -1
  55. package/dist/components/chunk-55IACEB6.js +1 -1
  56. package/dist/components/chunk-5ZQYHXKU.js +1 -1
  57. package/dist/components/chunk-6U3AYISY.js +1 -1
  58. package/dist/components/chunk-727SXJPM.js +1 -1
  59. package/dist/components/chunk-AGHRB4JF.js +1 -1
  60. package/dist/components/chunk-AQP2D5EJ.js +1 -1
  61. package/dist/components/chunk-BSJP7CBP.js +1 -1
  62. package/dist/components/chunk-CSCIHK7Q.js +1 -1
  63. package/dist/components/chunk-FMBD7UC4.js +1 -1
  64. package/dist/components/chunk-K2UTITRG.js +1 -1
  65. package/dist/components/chunk-KSCS5N6A.js +1 -1
  66. package/dist/components/chunk-L5ZTLDWV.js +1 -1
  67. package/dist/components/chunk-LZXEDZCA.js +1 -1
  68. package/dist/components/chunk-ND2GUHAM.js +1 -1
  69. package/dist/components/chunk-NNHCCRGN.js +1 -1
  70. package/dist/components/chunk-NZK2D7GU.js +1 -1
  71. package/dist/components/chunk-O5CBEL6O.js +1 -1
  72. package/dist/components/chunk-QZHKN3VN.js +1 -1
  73. package/dist/components/chunk-SRAX5OIU.js +1 -1
  74. package/dist/components/chunk-WU5MYG2G.js +1 -1
  75. package/dist/components/chunk-XPW4576I.js +1 -1
  76. package/dist/components/chunk-Z3N5DIM6.js +1 -1
  77. package/dist/components/chunk-ZUYEQ4TG.js +1 -1
  78. package/dist/components/chunk.js +1 -1
  79. package/dist/components/classDiagram-4FO5ZUOK.js +1 -1
  80. package/dist/components/classDiagram-v2-Q7XG4LA2.js +1 -1
  81. package/dist/components/compiler.js +1 -1
  82. package/dist/components/core.js +1 -1
  83. package/dist/components/cose-bilkent-S5V4N54A.js +1 -1
  84. package/dist/components/cpp.js +1 -1
  85. package/dist/components/cs-CZ-2BRQDIVT.js +1 -1
  86. package/dist/components/csharp.js +1 -1
  87. package/dist/components/css.js +1 -1
  88. package/dist/components/cytoscape.esm.js +1 -1
  89. package/dist/components/da-DK-5WZEPLOC.js +1 -1
  90. package/dist/components/dagre-BM42HDAG.js +1 -1
  91. package/dist/components/dagre.js +1 -1
  92. package/dist/components/de-DE-XR44H4JA.js +1 -1
  93. package/dist/components/defaultLocale.js +1 -1
  94. package/dist/components/defineProperty.js +1 -1
  95. package/dist/components/diagram-2AECGRRQ.js +1 -1
  96. package/dist/components/diagram-5GNKFQAL.js +1 -1
  97. package/dist/components/diagram-KO2AKTUF.js +1 -1
  98. package/dist/components/diagram-LMA3HP47.js +1 -1
  99. package/dist/components/diagram-OG6HWLK6.js +1 -1
  100. package/dist/components/diff.js +1 -1
  101. package/dist/components/directory-open-01563666.js +1 -1
  102. package/dist/components/directory-open-4ed118d0.js +1 -1
  103. package/dist/components/dist.js +1 -1
  104. package/dist/components/dist2.js +1 -1
  105. package/dist/components/dist3.js +1 -1
  106. package/dist/components/documentSearch.js +1 -0
  107. package/dist/components/docx-preview.js +1 -1
  108. package/dist/components/drawing.js +1 -1
  109. package/dist/components/ebook.js +1 -1
  110. package/dist/components/eda.js +1 -1
  111. package/dist/components/el-GR-BZB4AONW.js +1 -1
  112. package/dist/components/email.js +1 -1
  113. package/dist/components/en-B4ZKOASM.js +1 -1
  114. package/dist/components/erDiagram-TEJ5UH35.js +1 -1
  115. package/dist/components/es-ES-U4NZUMDT.js +1 -1
  116. package/dist/components/eu-ES-A7QVB2H4.js +1 -1
  117. package/dist/components/eventmodeling-FCH6USID.js +1 -1
  118. package/dist/components/fa-IR-HGAKTJCU.js +1 -1
  119. package/dist/components/fflate.module.js +1 -1
  120. package/dist/components/fi-FI-Z5N7JZ37.js +1 -1
  121. package/dist/components/file-open-002ab408.js +1 -1
  122. package/dist/components/file-open-7c801643.js +1 -1
  123. package/dist/components/file-save-3189631c.js +1 -1
  124. package/dist/components/file-save-745eba88.js +1 -1
  125. package/dist/components/flowDiagram-I6XJVG4X.js +1 -1
  126. package/dist/components/fr-FR-RHASNOE6.js +1 -1
  127. package/dist/components/ganttDiagram-6RSMTGT7.js +1 -1
  128. package/dist/components/gitGraph-WXDBUCRP.js +1 -1
  129. package/dist/components/gitGraphDiagram-PVQCEYII.js +1 -1
  130. package/dist/components/gl-ES-HMX3MZ6V.js +1 -1
  131. package/dist/components/global-compiler.js +1 -1
  132. package/dist/components/global-renderer.js +1 -1
  133. package/dist/components/go.js +1 -1
  134. package/dist/components/graphlib.js +1 -1
  135. package/dist/components/he-IL-6SHJWFNN.js +1 -1
  136. package/dist/components/hi-IN-IWLTKZ5I.js +1 -1
  137. package/dist/components/hu-HU-A5ZG7DT2.js +1 -1
  138. package/dist/components/id-ID-SAP4L64H.js +1 -1
  139. package/dist/components/image-GAAHSSAO.js +1 -1
  140. package/dist/components/image-blob-reduce.esm.js +1 -1
  141. package/dist/components/image.js +1 -1
  142. package/dist/components/info-J43DQDTF.js +1 -1
  143. package/dist/components/infoDiagram-5YYISTIA.js +1 -1
  144. package/dist/components/ini.js +1 -1
  145. package/dist/components/init.js +1 -1
  146. package/dist/components/ishikawaDiagram-YF4QCWOH.js +1 -1
  147. package/dist/components/it-IT-JPQ66NNP.js +1 -1
  148. package/dist/components/ja-JP-DBVTYXUO.js +1 -1
  149. package/dist/components/java.js +1 -1
  150. package/dist/components/javascript.js +1 -1
  151. package/dist/components/journeyDiagram-JHISSGLW.js +1 -1
  152. package/dist/components/json.js +1 -1
  153. package/dist/components/jszip.min.js +1 -1
  154. package/dist/components/kaa-6HZHGXH3.js +1 -1
  155. package/dist/components/kab-KAB-ZGHBKWFO.js +1 -1
  156. package/dist/components/kanban-definition-UN3LZRKU.js +1 -1
  157. package/dist/components/katex.js +1 -1
  158. package/dist/components/kk-KZ-P5N5QNE5.js +1 -1
  159. package/dist/components/km-KH-HSX4SM5Z.js +1 -1
  160. package/dist/components/ko-KR-MTYHY66A.js +1 -1
  161. package/dist/components/ku-TR-6OUDTVRD.js +1 -1
  162. package/dist/components/lib.js +1 -1
  163. package/dist/components/libarchive.js +1 -1
  164. package/dist/components/linear.js +1 -1
  165. package/dist/components/lt-LT-XHIRWOB4.js +1 -1
  166. package/dist/components/lv-LV-5QDEKY6T.js +1 -1
  167. package/dist/components/markdown.js +1 -1
  168. package/dist/components/md.js +1 -1
  169. package/dist/components/mermaid-parser.core.js +1 -1
  170. package/dist/components/mindmap-definition-RKZ34NQL.js +1 -1
  171. package/dist/components/model.js +1 -1
  172. package/dist/components/mp4.js +1 -1
  173. package/dist/components/mr-IN-CRQNXWMA.js +1 -1
  174. package/dist/components/my-MM-5M5IBNSE.js +1 -1
  175. package/dist/components/nb-NO-T6EIAALU.js +1 -1
  176. package/dist/components/nestedRender.js +1 -1
  177. package/dist/components/nl-NL-IS3SIHDZ.js +1 -1
  178. package/dist/components/nn-NO-6E72VCQL.js +1 -1
  179. package/dist/components/objectSpread2.js +1 -1
  180. package/dist/components/objectWithoutProperties.js +1 -1
  181. package/dist/components/oc-FR-POXYY2M6.js +1 -1
  182. package/dist/components/ofd.js +1 -1
  183. package/dist/components/ofd2.js +1 -1
  184. package/dist/components/ordinal.js +1 -1
  185. package/dist/components/pa-IN-N4M65BXN.js +1 -1
  186. package/dist/components/packet-YPE3B663.js +1 -1
  187. package/dist/components/pdf.js +1 -1
  188. package/dist/components/percentages-BXMCSKIN.js +1 -1
  189. package/dist/components/php.js +1 -1
  190. package/dist/components/pica.js +1 -1
  191. package/dist/components/pie-LRSECV5Y.js +1 -1
  192. package/dist/components/pie.js +1 -1
  193. package/dist/components/pieDiagram-4H26LBE5.js +1 -1
  194. package/dist/components/pl-PL-T2D74RX3.js +1 -1
  195. package/dist/components/postal-mime.js +1 -1
  196. package/dist/components/pptx.js +1 -1
  197. package/dist/components/printLayout.js +1 -1
  198. package/dist/components/prod.js +1 -1
  199. package/dist/components/pt-BR-5N22H2LF.js +1 -1
  200. package/dist/components/pt-PT-UZXXM6DQ.js +1 -1
  201. package/dist/components/python.js +1 -1
  202. package/dist/components/quadrantDiagram-W4KKPZXB.js +1 -1
  203. package/dist/components/radar-GUYGQ44K.js +1 -1
  204. package/dist/components/renderer.js +1 -1
  205. package/dist/components/requirementDiagram-4Y6WPE33.js +1 -1
  206. package/dist/components/ro-RO-JPDTUUEW.js +1 -1
  207. package/dist/components/rough.esm.js +1 -1
  208. package/dist/components/roundRect.js +1 -1
  209. package/dist/components/ru-RU-B4JR7IUQ.js +1 -1
  210. package/dist/components/rust.js +1 -1
  211. package/dist/components/sankeyDiagram-5OEKKPKP.js +1 -1
  212. package/dist/components/sequenceDiagram-3UESZ5HK.js +1 -1
  213. package/dist/components/shared.js +1 -1
  214. package/dist/components/shared2.js +1 -1
  215. package/dist/components/si-LK-N5RQ5JYF.js +1 -1
  216. package/dist/components/sk-SK-C5VTKIMK.js +1 -1
  217. package/dist/components/sl-SI-NN7IZMDC.js +1 -1
  218. package/dist/components/sourceLoading.js +1 -1
  219. package/dist/components/sql.js +1 -1
  220. package/dist/components/src.js +1 -1
  221. package/dist/components/src2.js +1 -1
  222. package/dist/components/stateDiagram-AJRCARHV.js +1 -1
  223. package/dist/components/stateDiagram-v2-BHNVJYJU.js +1 -1
  224. package/dist/components/subset-shared.chunk.js +1 -1
  225. package/dist/components/subset-worker.chunk.js +1 -1
  226. package/dist/components/sv-SE-XGPEYMSR.js +1 -1
  227. package/dist/components/ta-IN-2NMHFXQM.js +1 -1
  228. package/dist/components/text.js +1 -1
  229. package/dist/components/th-TH-HPSO5L25.js +1 -1
  230. package/dist/components/three.module.js +1 -1
  231. package/dist/components/time.js +1 -1
  232. package/dist/components/timeline-definition-PNZ67QCA.js +1 -1
  233. package/dist/components/tr-TR-DEFEU3FU.js +1 -1
  234. package/dist/components/treeView-BLDUP644.js +1 -1
  235. package/dist/components/treemap-LRROVOQU.js +1 -1
  236. package/dist/components/typescript.js +1 -1
  237. package/dist/components/typst.js +1 -1
  238. package/dist/components/uk-UA-QMV73CPH.js +1 -1
  239. package/dist/components/umd.js +1 -1
  240. package/dist/components/use.js +1 -1
  241. package/dist/components/util.js +1 -1
  242. package/dist/components/vennDiagram-CIIHVFJN.js +1 -1
  243. package/dist/components/vi-VN-M7AON7JQ.js +1 -1
  244. package/dist/components/wardley-L42UT6IY.js +1 -1
  245. package/dist/components/wardleyDiagram-YWT4CUSO.js +1 -1
  246. package/dist/components/wasm-pack-shim.js +1 -1
  247. package/dist/components/wasm-pack-shim2.js +1 -1
  248. package/dist/components/wasm.js +1 -1
  249. package/dist/components/word.js +1 -1
  250. package/dist/components/worker-ref.js +1 -1
  251. package/dist/components/xlsx.js +1 -1
  252. package/dist/components/xml.js +1 -1
  253. package/dist/components/xychartDiagram-2RQKCTM6.js +1 -1
  254. package/dist/components/yaml.js +1 -1
  255. package/dist/components/zh-CN-LNUGB5OW.js +1 -1
  256. package/dist/components/zh-HK-E62DVLB3.js +1 -1
  257. package/dist/components/zh-TW-RAJ6MFWO.js +1 -1
  258. package/dist/file-viewer3.css +1 -1
  259. package/dist/index.mjs +1 -1
  260. package/dist/src/compare/useSynchronizedScroll.d.ts +7 -0
  261. package/dist/src/package/common/type.d.ts +199 -0
  262. package/dist/src/package/components/FileViewer/FileViewer.vue.d.ts +15 -1
  263. package/dist/src/package/components/FileViewer/hooks/useViewerDocumentFeatures.d.ts +29 -0
  264. package/dist/src/package/components/FileViewer/{useViewerExport.d.ts → hooks/useViewerExport.d.ts} +1 -1
  265. package/dist/src/package/components/FileViewer/hooks/useViewerWatermark.d.ts +8 -0
  266. package/dist/src/package/index.d.ts +1 -1
  267. package/dist/src/package/use/documentLocation.d.ts +15 -0
  268. package/dist/src/package/use/documentSearch.d.ts +234 -0
  269. package/dist/src/package/use/index.d.ts +2 -0
  270. package/dist/src/package/vendors/cad/CadViewer.vue.d.ts +2 -0
  271. package/dist/src/package/vendors/cad/index.d.ts +4 -3
  272. package/dist/src/package/vendors/word/docx.worker.d.ts +1 -0
  273. package/dist/wasm/cad/DwgWorker-CuZJ5EUe.js +349 -0
  274. package/dist/wasm/cad/dwfv-render.wasm +0 -0
  275. package/dist/wasm/cad/dwg-worker.js +349 -0
  276. package/dist/wasm/cad/index-C365l3i9.js +4161 -0
  277. package/dist/wasm/cad/libredwg-web.js +15 -0
  278. package/dist/wasm/cad/libredwg-web.wasm +0 -0
  279. package/package.json +12 -8
@@ -0,0 +1,7 @@
1
+ import { Ref } from 'vue';
2
+ type ScrollerGetter = () => HTMLElement | null;
3
+ export declare const useSynchronizedScroll: (enabled: Ref<boolean>, getLeftScroller: ScrollerGetter, getRightScroller: ScrollerGetter) => {
4
+ bind: () => Promise<void>;
5
+ destroy: () => void;
6
+ };
7
+ export {};
@@ -94,6 +94,13 @@ export interface FileViewerArchiveOptions {
94
94
  * PDF 预览配置。
95
95
  */
96
96
  export interface FileViewerPdfOptions {
97
+ /**
98
+ * 是否显示 PDF 渲染器自己的阅读工具栏。
99
+ *
100
+ * 独立预览建议保持默认显示;在文档比对这类左右排版场景中可以设为
101
+ * `false`,让 PDF 与 Word / Markdown 等格式从同一内容起点对齐。
102
+ */
103
+ toolbar?: boolean;
97
104
  /**
98
105
  * 是否启用左侧页面/目录导航窗格。设为 `false` 时会同时隐藏侧栏和切换按钮。
99
106
  */
@@ -133,6 +140,154 @@ export interface FileViewerTypstOptions {
133
140
  */
134
141
  compilerWasmUrl?: string;
135
142
  }
143
+ export type FileViewerCadRenderer = 'auto' | 'webgl' | 'canvas2d';
144
+ export type FileViewerCadDwfLineWeightMode = 'adaptive' | 'physical' | 'hairline';
145
+ /**
146
+ * CAD 预览配置。
147
+ *
148
+ * 默认使用 @flyfish-dev/cad-viewer,并从 viewer 静态目录下的
149
+ * `wasm/cad/` 按需加载 LibreDWG WASM、DWF raster WASM 与 DWG Worker。
150
+ * 私有化部署或 CDN 路径不同的场景,可以显式覆盖对应 URL。
151
+ */
152
+ export interface FileViewerCadOptions {
153
+ wasmPath?: string;
154
+ workerUrl?: string | URL;
155
+ dwfWasmUrl?: string;
156
+ useWorker?: boolean;
157
+ workerTimeoutMs?: number;
158
+ renderer?: FileViewerCadRenderer;
159
+ preferDwgWasm?: boolean;
160
+ includePaperSpace?: boolean;
161
+ maxInsertDepth?: number;
162
+ keepRaw?: boolean;
163
+ preloadDwg?: boolean;
164
+ dwfPreferWebgl?: boolean;
165
+ dwfPreferWasm?: boolean;
166
+ dwfBackground?: string;
167
+ dwfMaxDevicePixelRatio?: number;
168
+ dwfMaxCanvasPixels?: number;
169
+ dwfMaxGpuCacheBytes?: number;
170
+ dwfMaxCachedScenes?: number;
171
+ dwfLineWeightMode?: FileViewerCadDwfLineWeightMode;
172
+ dwfMinStrokeCssPx?: number;
173
+ dwfMaxOverviewStrokeCssPx?: number;
174
+ dwfMinTextCssPx?: number;
175
+ dwfMinFilledAreaCssPx?: number;
176
+ canvasOptions?: Record<string, unknown>;
177
+ }
178
+ /**
179
+ * 文档定位锚点。
180
+ *
181
+ * 预览器会尽量把当前渲染结果中的页面、段落、表格行、代码块等内容
182
+ * 抽象成稳定锚点。不同格式的“行”粒度不完全相同:文本类文档通常可到
183
+ * 段落/行块,PDF 这类画布型文档会优先回退到页与可用文本层。
184
+ */
185
+ export interface FileViewerDocumentAnchor {
186
+ id: string;
187
+ index: number;
188
+ line: number;
189
+ type: 'page' | 'line' | 'block';
190
+ label: string;
191
+ text: string;
192
+ page?: number;
193
+ top: number;
194
+ left: number;
195
+ width: number;
196
+ height: number;
197
+ }
198
+ /**
199
+ * AI / 搜索可复用的文档文本切片。
200
+ *
201
+ * 这里不直接绑定任何云端能力,只提供溯源、向量化和高亮所需的稳定结构。
202
+ */
203
+ export interface FileViewerDocumentChunk {
204
+ id: string;
205
+ text: string;
206
+ anchor: FileViewerDocumentAnchor;
207
+ startLine: number;
208
+ endLine: number;
209
+ }
210
+ /**
211
+ * 文档搜索配置。
212
+ */
213
+ export interface FileViewerSearchOptions {
214
+ /**
215
+ * 是否启用搜索能力。设为 `false` 时公开方法仍存在,但不会执行高亮。
216
+ */
217
+ enabled?: boolean;
218
+ /**
219
+ * 是否区分大小写。
220
+ */
221
+ caseSensitive?: boolean;
222
+ /**
223
+ * 是否整词匹配。
224
+ */
225
+ wholeWord?: boolean;
226
+ /**
227
+ * 单次搜索最多保留的命中数量,避免极端大文档一次性插入过多高亮节点。
228
+ */
229
+ maxMatches?: number;
230
+ /**
231
+ * 搜索 MutationObserver 重新扫描的防抖时间。
232
+ */
233
+ debounce?: number;
234
+ /**
235
+ * 自定义高亮类名。
236
+ */
237
+ className?: string;
238
+ /**
239
+ * 当前命中高亮类名。
240
+ */
241
+ activeClassName?: string;
242
+ }
243
+ /**
244
+ * 单条搜索命中。
245
+ */
246
+ export interface FileViewerSearchMatch {
247
+ id: string;
248
+ index: number;
249
+ text: string;
250
+ anchor: FileViewerDocumentAnchor | null;
251
+ line?: number;
252
+ page?: number;
253
+ }
254
+ /**
255
+ * 当前搜索状态。
256
+ */
257
+ export interface FileViewerSearchState {
258
+ query: string;
259
+ total: number;
260
+ currentIndex: number;
261
+ current: FileViewerSearchMatch | null;
262
+ matches: FileViewerSearchMatch[];
263
+ }
264
+ /**
265
+ * 渲染器自定义搜索提供器。
266
+ *
267
+ * PDF.js、EPUB iframe、虚拟表格等格式拥有自己的文本层或虚拟滚动结构,
268
+ * 不能总是由通用 DOM 高亮直接改写内部节点。渲染器可以在根节点上注册
269
+ * 该提供器,让 FileViewer 的搜索 API 继续保持统一入口。
270
+ */
271
+ export interface FileViewerSearchProvider {
272
+ search: (query: string, options?: FileViewerSearchOptions) => FileViewerSearchState | Promise<FileViewerSearchState>;
273
+ next?: () => FileViewerSearchState | Promise<FileViewerSearchState>;
274
+ previous?: () => FileViewerSearchState | Promise<FileViewerSearchState>;
275
+ clear?: () => FileViewerSearchState | Promise<FileViewerSearchState>;
276
+ getState?: () => FileViewerSearchState;
277
+ }
278
+ /**
279
+ * AI 友好能力配置。
280
+ *
281
+ * 预览器本身不内置云端模型调用;这里提供可选文本切片结构,业务侧可以
282
+ * 基于 `getDocumentTextChunks()` 做向量化、溯源、AI 摘要和命中高亮。
283
+ */
284
+ export interface FileViewerAiOptions {
285
+ enabled?: boolean;
286
+ collectText?: boolean;
287
+ maxTextLength?: number;
288
+ chunkSize?: number;
289
+ chunkOverlap?: number;
290
+ }
136
291
  /**
137
292
  * 预览器主题模式。
138
293
  *
@@ -192,9 +347,20 @@ export interface FileViewerOptions {
192
347
  theme?: FileViewerThemeMode;
193
348
  watermark?: boolean | FileViewerWatermarkOptions;
194
349
  toolbar?: boolean | FileViewerToolbarOptions;
350
+ /**
351
+ * 文档搜索能力配置。设为 `false` 可关闭内置搜索/高亮扫描;
352
+ * 默认启用公开 API,业务 UI 可通过组件 ref 调用 `searchDocument()`。
353
+ */
354
+ search?: boolean | FileViewerSearchOptions;
355
+ /**
356
+ * AI 友好能力配置。预览器只提供文本切片、锚点和溯源上下文,不绑定模型服务。
357
+ */
358
+ ai?: boolean | FileViewerAiOptions;
195
359
  archive?: FileViewerArchiveOptions;
196
360
  pdf?: FileViewerPdfOptions;
361
+ docx?: FileViewerDocxOptions;
197
362
  typst?: FileViewerTypstOptions;
363
+ cad?: FileViewerCadOptions;
198
364
  /**
199
365
  * 文档加载/卸载生命周期钩子。直接使用 Vue 组件时可以传函数;
200
366
  * iframe 集成时同名事件会通过 `postMessage` 向宿主发送。
@@ -205,6 +371,34 @@ export interface FileViewerOptions {
205
371
  */
206
372
  beforeOperation?: FileViewerBeforeOperation;
207
373
  }
374
+ /**
375
+ * DOCX 渲染配置。
376
+ *
377
+ * 默认使用 Web Worker 承载 `docx-preview` 的 ZIP/XML 解析和 HTML 构建,
378
+ * 主线程只负责把最终 HTML 挂载到预览区并执行缩放、打印等交互适配。
379
+ * 这样可以保持 docxjs 的真实渲染结果,同时减少复杂 DOCX 首屏卡顿。
380
+ */
381
+ export interface FileViewerDocxOptions {
382
+ /**
383
+ * 是否启用 DOCX Worker 渲染链路。默认开启。
384
+ * 极少数 CSP 或低版本浏览器不允许内联 Worker 时,可设为 `false`
385
+ * 回退到 docx-preview 原生主线程渲染。
386
+ */
387
+ worker?: boolean;
388
+ /**
389
+ * 是否把 Worker 返回的 docx-preview HTML 按页面分批挂载。默认开启。
390
+ * 它不改变渲染器,只是避免一次性插入长文档 DOM 时阻塞首屏。
391
+ */
392
+ progressive?: boolean;
393
+ /**
394
+ * DOCX Worker 最大等待时间,单位毫秒,默认 15000。
395
+ *
396
+ * 少量复杂 Word 文件会触发浏览器 Worker DOM 兼容边界,设置超时可以避免
397
+ * 永久停留在 loading;超时后仍会回到 docx-preview 原生主线程渲染。
398
+ * 传入 0 或负数可关闭超时保护。
399
+ */
400
+ workerTimeout?: number;
401
+ }
208
402
  /**
209
403
  * 导出/打印模式。
210
404
  */
@@ -263,6 +457,11 @@ export interface FileRenderContext {
263
457
  streamUrl?: string;
264
458
  options?: FileViewerOptions;
265
459
  registerExportAdapter?: (adapter: FileRenderExportAdapter | null) => void;
460
+ /**
461
+ * 渲染器已经写入可读的渐进式内容,但完整高保真渲染仍在继续。
462
+ * 主入口收到后可以先露出内容,避免用户长时间只看到 Loading。
463
+ */
464
+ onProgressiveRender?: () => void;
266
465
  }
267
466
  /**
268
467
  * 文件处理逻辑,用于声明具体格式的异步渲染器。
@@ -1,4 +1,4 @@
1
- import { FileRef, FileViewerLifecycleContext, FileViewerOperationAvailability, FileViewerOptions, FileViewerOperationContext } from '../../../../package/common/type';
1
+ import { FileRef, FileViewerDocumentAnchor, FileViewerLifecycleContext, FileViewerOperationAvailability, FileViewerOptions, FileViewerOperationContext, FileViewerSearchState } from '../../../../package/common/type';
2
2
  type __VLS_Props = {
3
3
  /**
4
4
  * 本地二进制输入。优先级高于 `url`。
@@ -30,11 +30,23 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
30
30
  print: boolean;
31
31
  exportHtml: boolean;
32
32
  };
33
+ getScrollContainer: () => HTMLElement | null;
34
+ searchDocument: (query: string) => Promise<FileViewerSearchState>;
35
+ clearDocumentSearch: () => Promise<FileViewerSearchState>;
36
+ nextSearchResult: () => Promise<FileViewerSearchState>;
37
+ previousSearchResult: () => Promise<FileViewerSearchState>;
38
+ getSearchState: () => FileViewerSearchState;
39
+ collectDocumentAnchors: () => Promise<FileViewerDocumentAnchor[]>;
40
+ scrollToAnchor: (anchor: FileViewerDocumentAnchor | string) => Promise<boolean>;
41
+ scrollToLine: (line: number) => Promise<boolean>;
42
+ getDocumentTextChunks: () => import('../../../../package/common/type').FileViewerDocumentChunk[];
33
43
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
34
44
  "load-start": (context: FileViewerLifecycleContext) => any;
35
45
  "load-complete": (context: FileViewerLifecycleContext) => any;
36
46
  "unload-start": (context: FileViewerLifecycleContext) => any;
37
47
  "unload-complete": (context: FileViewerLifecycleContext) => any;
48
+ "search-change": (state: FileViewerSearchState) => any;
49
+ "location-change": (anchor: FileViewerDocumentAnchor | null) => any;
38
50
  "operation-before": (context: FileViewerOperationContext) => any;
39
51
  "operation-cancel": (context: FileViewerOperationContext) => any;
40
52
  "operation-availability-change": (availability: FileViewerOperationAvailability) => any;
@@ -43,6 +55,8 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
43
55
  "onLoad-complete"?: ((context: FileViewerLifecycleContext) => any) | undefined;
44
56
  "onUnload-start"?: ((context: FileViewerLifecycleContext) => any) | undefined;
45
57
  "onUnload-complete"?: ((context: FileViewerLifecycleContext) => any) | undefined;
58
+ "onSearch-change"?: ((state: FileViewerSearchState) => any) | undefined;
59
+ "onLocation-change"?: ((anchor: FileViewerDocumentAnchor | null) => any) | undefined;
46
60
  "onOperation-before"?: ((context: FileViewerOperationContext) => any) | undefined;
47
61
  "onOperation-cancel"?: ((context: FileViewerOperationContext) => any) | undefined;
48
62
  "onOperation-availability-change"?: ((availability: FileViewerOperationAvailability) => any) | undefined;
@@ -0,0 +1,29 @@
1
+ import { Ref } from 'vue';
2
+ import { FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerOptions, FileViewerSearchState } from '../../../../../package/common/type';
3
+ interface UseViewerDocumentFeaturesOptions {
4
+ output: Ref<HTMLDivElement | null>;
5
+ getOptions: () => FileViewerOptions | undefined;
6
+ emitSearchChange: (state: FileViewerSearchState) => void;
7
+ emitLocationChange: (anchor: FileViewerDocumentAnchor | null) => void;
8
+ }
9
+ /**
10
+ * FileViewer 的文档交互门面。
11
+ *
12
+ * 底层搜索、高亮、锚点收集继续放在 `src/package/use` 的通用 hooks 中;
13
+ * 这里只负责把这些能力组合成组件对外暴露的 API,并处理 iframe 事件桥接。
14
+ */
15
+ export declare const useViewerDocumentFeatures: ({ output, getOptions, emitSearchChange, emitLocationChange }: UseViewerDocumentFeaturesOptions) => {
16
+ refreshDocumentIndex: () => Promise<FileViewerDocumentAnchor[]>;
17
+ clearDocumentState: () => void;
18
+ getScrollContainer: () => HTMLElement | null;
19
+ searchDocument: (query: string) => Promise<FileViewerSearchState>;
20
+ clearDocumentSearch: () => Promise<FileViewerSearchState>;
21
+ nextSearchResult: () => Promise<FileViewerSearchState>;
22
+ previousSearchResult: () => Promise<FileViewerSearchState>;
23
+ getSearchState: () => FileViewerSearchState;
24
+ collectDocumentAnchors: () => Promise<FileViewerDocumentAnchor[]>;
25
+ scrollToAnchor: (anchor: FileViewerDocumentAnchor | string) => Promise<boolean>;
26
+ scrollToLine: (line: number) => Promise<boolean>;
27
+ getDocumentTextChunks: () => FileViewerDocumentChunk[];
28
+ };
29
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ComputedRef, Ref, ShallowRef } from 'vue';
2
- import { FileRenderExportAdapter, FileViewerOperationAvailability, FileViewerOperationType } from '../../../../package/common/type';
2
+ import { FileRenderExportAdapter, FileViewerOperationAvailability, FileViewerOperationType } from '../../../../../package/common/type';
3
3
  interface UseViewerExportOptions {
4
4
  activeExportAdapter: ShallowRef<FileRenderExportAdapter | null>;
5
5
  currentBuffer: Ref<ArrayBuffer | null>;
@@ -0,0 +1,8 @@
1
+ import { FileViewerWatermarkOptions } from '../../../../../package/common/type';
2
+ export declare const useViewerWatermark: (getWatermark: () => boolean | FileViewerWatermarkOptions | undefined) => {
3
+ normalizedWatermark: import('vue').ComputedRef<FileViewerWatermarkOptions | null>;
4
+ watermarkStyle: import('vue').ComputedRef<{
5
+ backgroundImage: string;
6
+ } | undefined>;
7
+ watermarkInlineStyle: import('vue').ComputedRef<string>;
8
+ };
@@ -19,4 +19,4 @@ declare class Installer implements FileViewerInstaller {
19
19
  declare const _default: Installer;
20
20
  export default _default;
21
21
  export { FileViewer };
22
- export type { FileRef, FileRenderExportAdapter, FileRenderExportMode, FileRenderExportOptions, FileViewerArchiveOptions, FileViewerBeforeOperation, FileViewerLifecycleContext, FileViewerLifecycleHooks, FileViewerLifecyclePhase, FileViewerOperationAvailability, FileViewerOperationContext, FileViewerOperationType, FileViewerOptions, FileViewerSourceType, FileViewerToolbarOptions, FileViewerWatermarkOptions } from './common/type';
22
+ export type { FileRef, FileRenderExportAdapter, FileRenderExportMode, FileRenderExportOptions, FileViewerAiOptions, FileViewerArchiveOptions, FileViewerBeforeOperation, FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerLifecycleContext, FileViewerLifecycleHooks, FileViewerLifecyclePhase, FileViewerOperationAvailability, FileViewerOperationContext, FileViewerOperationType, FileViewerOptions, FileViewerPdfOptions, FileViewerSearchMatch, FileViewerSearchOptions, FileViewerSearchState, FileViewerSourceType, FileViewerToolbarOptions, FileViewerToolbarPosition, FileViewerThemeMode, FileViewerTypstOptions, FileViewerWatermarkOptions } from './common/type';
@@ -0,0 +1,15 @@
1
+ import { Ref } from 'vue';
2
+ import { FileViewerAiOptions, FileViewerDocumentAnchor, FileViewerDocumentChunk } from '../../../package/common/type';
3
+ export declare const collectDocumentAnchors: (root: HTMLElement | null) => FileViewerDocumentAnchor[];
4
+ export declare const findAnchorForElement: (element: Element | null, anchors: FileViewerDocumentAnchor[], root?: HTMLElement | null) => FileViewerDocumentAnchor | null;
5
+ export declare const getCurrentDocumentAnchor: (root: HTMLElement | null, anchors: FileViewerDocumentAnchor[]) => FileViewerDocumentAnchor | null;
6
+ export declare const scrollToDocumentAnchor: (root: HTMLElement | null, anchor: FileViewerDocumentAnchor | string | number | null | undefined) => boolean;
7
+ export declare const buildDocumentTextChunks: (anchors: FileViewerDocumentAnchor[], options?: boolean | FileViewerAiOptions) => FileViewerDocumentChunk[];
8
+ export declare const useDocumentLocation: (root: Ref<HTMLElement | null>) => {
9
+ anchors: import('vue').ShallowRef<FileViewerDocumentAnchor[], FileViewerDocumentAnchor[]>;
10
+ refreshAnchors: () => Promise<FileViewerDocumentAnchor[]>;
11
+ getCurrentAnchor: () => FileViewerDocumentAnchor | null;
12
+ scrollToAnchor: (anchor: FileViewerDocumentAnchor | string) => boolean;
13
+ scrollToLine: (line: number) => Promise<boolean>;
14
+ getTextChunks: (options?: boolean | FileViewerAiOptions) => FileViewerDocumentChunk[];
15
+ };
@@ -0,0 +1,234 @@
1
+ import { Ref } from 'vue';
2
+ import { FileViewerDocumentAnchor, FileViewerSearchOptions, FileViewerSearchProvider } from '../../../package/common/type';
3
+ export declare const registerFileViewerSearchProvider: (host: HTMLElement, provider: FileViewerSearchProvider) => void;
4
+ export declare const unregisterFileViewerSearchProvider: (host: HTMLElement | null | undefined) => void;
5
+ export declare const useDocumentSearch: (root: Ref<HTMLElement | null>, optionsSource?: () => boolean | FileViewerSearchOptions | undefined, scrollContainerSource?: () => HTMLElement | null | undefined) => {
6
+ anchors: import('vue').ShallowRef<FileViewerDocumentAnchor[], FileViewerDocumentAnchor[]>;
7
+ state: {
8
+ query: string;
9
+ total: number;
10
+ currentIndex: number;
11
+ current: {
12
+ id: string;
13
+ index: number;
14
+ text: string;
15
+ anchor: {
16
+ id: string;
17
+ index: number;
18
+ line: number;
19
+ type: "page" | "line" | "block";
20
+ label: string;
21
+ text: string;
22
+ page?: number | undefined;
23
+ top: number;
24
+ left: number;
25
+ width: number;
26
+ height: number;
27
+ } | null;
28
+ line?: number | undefined;
29
+ page?: number | undefined;
30
+ } | null;
31
+ matches: {
32
+ id: string;
33
+ index: number;
34
+ text: string;
35
+ anchor: {
36
+ id: string;
37
+ index: number;
38
+ line: number;
39
+ type: "page" | "line" | "block";
40
+ label: string;
41
+ text: string;
42
+ page?: number | undefined;
43
+ top: number;
44
+ left: number;
45
+ width: number;
46
+ height: number;
47
+ } | null;
48
+ line?: number | undefined;
49
+ page?: number | undefined;
50
+ }[];
51
+ };
52
+ observe: () => void;
53
+ refreshAnchors: () => Promise<FileViewerDocumentAnchor[]>;
54
+ search: (query: string) => Promise<{
55
+ query: string;
56
+ total: number;
57
+ currentIndex: number;
58
+ current: {
59
+ id: string;
60
+ index: number;
61
+ text: string;
62
+ anchor: {
63
+ id: string;
64
+ index: number;
65
+ line: number;
66
+ type: "page" | "line" | "block";
67
+ label: string;
68
+ text: string;
69
+ page?: number | undefined;
70
+ top: number;
71
+ left: number;
72
+ width: number;
73
+ height: number;
74
+ } | null;
75
+ line?: number | undefined;
76
+ page?: number | undefined;
77
+ } | null;
78
+ matches: {
79
+ id: string;
80
+ index: number;
81
+ text: string;
82
+ anchor: {
83
+ id: string;
84
+ index: number;
85
+ line: number;
86
+ type: "page" | "line" | "block";
87
+ label: string;
88
+ text: string;
89
+ page?: number | undefined;
90
+ top: number;
91
+ left: number;
92
+ width: number;
93
+ height: number;
94
+ } | null;
95
+ line?: number | undefined;
96
+ page?: number | undefined;
97
+ }[];
98
+ }>;
99
+ next: () => Promise<{
100
+ query: string;
101
+ total: number;
102
+ currentIndex: number;
103
+ current: {
104
+ id: string;
105
+ index: number;
106
+ text: string;
107
+ anchor: {
108
+ id: string;
109
+ index: number;
110
+ line: number;
111
+ type: "page" | "line" | "block";
112
+ label: string;
113
+ text: string;
114
+ page?: number | undefined;
115
+ top: number;
116
+ left: number;
117
+ width: number;
118
+ height: number;
119
+ } | null;
120
+ line?: number | undefined;
121
+ page?: number | undefined;
122
+ } | null;
123
+ matches: {
124
+ id: string;
125
+ index: number;
126
+ text: string;
127
+ anchor: {
128
+ id: string;
129
+ index: number;
130
+ line: number;
131
+ type: "page" | "line" | "block";
132
+ label: string;
133
+ text: string;
134
+ page?: number | undefined;
135
+ top: number;
136
+ left: number;
137
+ width: number;
138
+ height: number;
139
+ } | null;
140
+ line?: number | undefined;
141
+ page?: number | undefined;
142
+ }[];
143
+ }>;
144
+ previous: () => Promise<{
145
+ query: string;
146
+ total: number;
147
+ currentIndex: number;
148
+ current: {
149
+ id: string;
150
+ index: number;
151
+ text: string;
152
+ anchor: {
153
+ id: string;
154
+ index: number;
155
+ line: number;
156
+ type: "page" | "line" | "block";
157
+ label: string;
158
+ text: string;
159
+ page?: number | undefined;
160
+ top: number;
161
+ left: number;
162
+ width: number;
163
+ height: number;
164
+ } | null;
165
+ line?: number | undefined;
166
+ page?: number | undefined;
167
+ } | null;
168
+ matches: {
169
+ id: string;
170
+ index: number;
171
+ text: string;
172
+ anchor: {
173
+ id: string;
174
+ index: number;
175
+ line: number;
176
+ type: "page" | "line" | "block";
177
+ label: string;
178
+ text: string;
179
+ page?: number | undefined;
180
+ top: number;
181
+ left: number;
182
+ width: number;
183
+ height: number;
184
+ } | null;
185
+ line?: number | undefined;
186
+ page?: number | undefined;
187
+ }[];
188
+ }>;
189
+ clear: () => Promise<{
190
+ query: string;
191
+ total: number;
192
+ currentIndex: number;
193
+ current: {
194
+ id: string;
195
+ index: number;
196
+ text: string;
197
+ anchor: {
198
+ id: string;
199
+ index: number;
200
+ line: number;
201
+ type: "page" | "line" | "block";
202
+ label: string;
203
+ text: string;
204
+ page?: number | undefined;
205
+ top: number;
206
+ left: number;
207
+ width: number;
208
+ height: number;
209
+ } | null;
210
+ line?: number | undefined;
211
+ page?: number | undefined;
212
+ } | null;
213
+ matches: {
214
+ id: string;
215
+ index: number;
216
+ text: string;
217
+ anchor: {
218
+ id: string;
219
+ index: number;
220
+ line: number;
221
+ type: "page" | "line" | "block";
222
+ label: string;
223
+ text: string;
224
+ page?: number | undefined;
225
+ top: number;
226
+ left: number;
227
+ width: number;
228
+ height: number;
229
+ } | null;
230
+ line?: number | undefined;
231
+ page?: number | undefined;
232
+ }[];
233
+ }>;
234
+ };
@@ -1,2 +1,4 @@
1
1
  export * from './loading';
2
2
  export * from './worker';
3
+ export * from './documentLocation';
4
+ export * from './documentSearch';
@@ -1,6 +1,8 @@
1
+ import { FileViewerCadOptions } from '../../../../package/common/type';
1
2
  type __VLS_Props = {
2
3
  data: ArrayBuffer;
3
4
  type: string;
5
+ options?: FileViewerCadOptions;
4
6
  };
5
7
  declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
6
8
  declare const _default: typeof __VLS_export;
@@ -1,7 +1,8 @@
1
+ import { FileRenderContext } from '../../../../package/common/type';
1
2
  /**
2
3
  * 渲染 CAD 图纸。
3
4
  *
4
- * 当前内置 MIT 协议的 @cadview/core,提供 DXF 解析、Canvas 渲染、平移缩放和测量能力。
5
- * DWG 属于专有格式,开源纯前端转换器通常带 GPL 约束,因此这里不默认打进组件库。
5
+ * @flyfish-dev/cad-viewer 提供 DWG / DXF / DWF / DWFx / XPS 纯前端预览。
6
+ * DWG 解析依赖按需加载的 LibreDWG WASM 与独立 Worker,DWF 系列走 native renderer。
6
7
  */
7
- export default function renderCad(buffer: ArrayBuffer, target: HTMLDivElement, type?: string): Promise<import('vue').App<Element>>;
8
+ export default function renderCad(buffer: ArrayBuffer, target: HTMLDivElement, type?: string, context?: FileRenderContext): Promise<import('vue').App<Element>>;
@@ -0,0 +1 @@
1
+ export {};