Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] 支持离线预览微软的各类文档 #4

Open
Okabe-Rintarou-0 opened this issue Mar 4, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@Okabe-Rintarou-0
Copy link
Owner

Okabe-Rintarou-0 commented Mar 4, 2024

目前预览文件用的是 react-doc-viewer,他是基于微软在线预览功能,只能预览公开的文档。但是在预览压缩包的情况下,就会失效。预览压缩包本质上是读取文件数据(但是不下载),然后展示。

可以参考 DocxRenderer 实现其他格式,诸如 pptx,xlsx 的替换:

export default function DocxRenderer({
mainState: { currentDocument },
}: DocRendererProps) {
if (!currentDocument) return null;
const containerRef = useRef<HTMLDivElement>(null);
const data = decodeBase64DataAsBinary(currentDocument.fileData as string);
useEffect(() => {
if (containerRef.current) {
renderAsync(data, containerRef.current);
}
}, [containerRef.current]);
return <div ref={containerRef} style={{ width: "100%" }} />
}
DocxRenderer.fileTypes = ["doc"];
DocxRenderer.weight = 1;

@Okabe-Rintarou-0 Okabe-Rintarou-0 added the enhancement New feature or request label Mar 4, 2024
@Okabe-Rintarou-0
Copy link
Owner Author

TODO-List:

  • xlsx
  • pptx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant