@flyfish-group/file-viewer-react 1.0.10 → 1.0.12

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
@@ -3,7 +3,7 @@
3
3
  React 文件预览组件。只提供私有化部署路线: 依赖的 `@flyfish-group/file-viewer-web` 会随包携带 Vue 基线 viewer 产物;使用 `npm install` 或已允许 pnpm 安装脚本后,会复制到宿主项目 `public/file-viewer`。React 组件默认加载 `/file-viewer/index.html`,不依赖任何外部服务。
4
4
 
5
5
  ```bash
6
- npm install @flyfish-group/file-viewer-react@1.0.10
6
+ npm install @flyfish-group/file-viewer-react@1.0.12
7
7
  ```
8
8
 
9
9
  pnpm 10 默认会拦截依赖包的 `postinstall`。如果安装后提示 `Ignored build scripts: @flyfish-group/file-viewer-web`,请执行 `pnpm approve-builds` 允许该包,或运行 `pnpm exec file-viewer-copy-assets ./public/file-viewer`。
@@ -16,6 +16,14 @@ export function Preview() {
16
16
  <div style={{ height: '100vh' }}>
17
17
  <FileViewer
18
18
  url="https://example.com/demo.docx"
19
+ options={{
20
+ toolbar: true,
21
+ watermark: { text: '内部预览', opacity: 0.14 },
22
+ archive: {
23
+ workerUrl: '/file-viewer/vendor/libarchive/worker-bundle.js',
24
+ cache: true
25
+ }
26
+ }}
19
27
  />
20
28
  </div>
21
29
  )
@@ -33,3 +41,5 @@ export function Preview() {
33
41
  ```tsx
34
42
  <FileViewer viewerUrl="/vendor/file-viewer/index.html" url={url} />
35
43
  ```
44
+
45
+ `options` 会透传给 Vue 基线预览器,可配置下载/打印/导出 HTML 操作栏、文字或图片水印,以及压缩包预览的 `libarchive.js` Worker、IndexedDB 缓存和体积上限。
package/dist/index.d.ts CHANGED
@@ -37,6 +37,10 @@ export interface FileViewerProps extends Omit<IframeHTMLAttributes<HTMLIFrameEle
37
37
  * 预留给 Vue 基线页面的查询参数。
38
38
  */
39
39
  params?: ViewerFrameOptions['params'];
40
+ /**
41
+ * 透传给 Vue 基线预览器的运行时选项,例如水印、工具栏和压缩包缓存限制。
42
+ */
43
+ options?: ViewerFrameOptions['options'];
40
44
  }
41
45
  export declare const FileViewer: import("react").ForwardRefExoticComponent<FileViewerProps & import("react").RefAttributes<FileViewerHandle>>;
42
46
  export default FileViewer;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ const defaultStyle = {
8
8
  display: 'block'
9
9
  };
10
10
  export const FileViewer = forwardRef((props, forwardedRef) => {
11
- const { viewerUrl, url, file, name, from, targetOrigin, params, onLoad, style, title = 'Flyfish Viewer 文件预览', ...iframeProps } = props;
11
+ const { viewerUrl, url, file, name, from, targetOrigin, params, options, onLoad, style, title = 'Flyfish Viewer 文件预览', ...iframeProps } = props;
12
12
  const iframeRef = useRef(null);
13
13
  const [frameReady, setFrameReady] = useState(false);
14
14
  const frameOptions = useMemo(() => ({
@@ -18,8 +18,9 @@ export const FileViewer = forwardRef((props, forwardedRef) => {
18
18
  name,
19
19
  from,
20
20
  targetOrigin,
21
- params
22
- }), [viewerUrl, url, file, name, from, targetOrigin, params]);
21
+ params,
22
+ options
23
+ }), [viewerUrl, url, file, name, from, targetOrigin, params, options]);
23
24
  const src = useMemo(() => buildViewerSrc(frameOptions), [frameOptions]);
24
25
  const postFile = useCallback(() => {
25
26
  return postFileToViewer(iframeRef.current, frameOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flyfish-group/file-viewer-react",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Private-deploy React component for Flyfish Viewer",
@@ -47,7 +47,7 @@
47
47
  "react": ">=17 <20"
48
48
  },
49
49
  "dependencies": {
50
- "@flyfish-group/file-viewer-web": "^1.0.10"
50
+ "@flyfish-group/file-viewer-web": "^1.0.12"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",