@infinilabs/doc-detail 0.0.14 → 0.0.16
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/dist/doc-detail.cjs +95 -3065
- package/dist/doc-detail.js +76946 -235500
- package/package.json +4 -3
- package/src/components/DocDetail/components/Preview/components/Docx/index.tsx +4 -0
- package/src/components/DocDetail/components/Preview/components/Pptx/index.tsx +19 -5
- package/src/components/DocDetail/index.tsx +2 -1
- package/vite.config.ts +3 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinilabs/doc-detail",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/doc-detail.cjs",
|
|
7
7
|
"module": "dist/doc-detail.js",
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"preview": "vite preview"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ant-design/x": "^2.1.3",
|
|
26
|
-
"@ant-design/x-markdown": "^2.1.3",
|
|
27
25
|
"@infinilabs/markdown": "^0.0.4",
|
|
28
26
|
"ahooks": "^3.9.6",
|
|
29
27
|
"antd": "^6.0.0",
|
|
@@ -50,6 +48,9 @@
|
|
|
50
48
|
"vite-plugin-dts": "^4.5.4"
|
|
51
49
|
},
|
|
52
50
|
"peerDependencies": {
|
|
51
|
+
"@ant-design/cssinjs": ">=2",
|
|
52
|
+
"@ant-design/x": ">=2",
|
|
53
|
+
"@ant-design/x-markdown": ">=2",
|
|
53
54
|
"antd": ">=5",
|
|
54
55
|
"react": ">=17",
|
|
55
56
|
"react-dom": ">=17"
|
|
@@ -18,8 +18,12 @@ const Docx: FC<DocxProps> = (props) => {
|
|
|
18
18
|
headers: requestHeaders,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
if (!response.ok) return;
|
|
22
|
+
|
|
21
23
|
const arrayBuffer = await response.arrayBuffer();
|
|
22
24
|
|
|
25
|
+
if (arrayBuffer.byteLength === 0) return;
|
|
26
|
+
|
|
23
27
|
containerRef.current.innerHTML = "";
|
|
24
28
|
|
|
25
29
|
renderAsync(arrayBuffer, containerRef.current!, void 0, {
|
|
@@ -12,28 +12,42 @@ const Pptx: FC<PptxProps> = (props) => {
|
|
|
12
12
|
|
|
13
13
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const renderPptx = async () => {
|
|
16
16
|
if (!containerRef.current) return;
|
|
17
17
|
|
|
18
|
+
containerRef.current.innerHTML = "";
|
|
19
|
+
|
|
20
|
+
const width = containerRef.current.clientWidth;
|
|
21
|
+
const height = Math.round(width * (9 / 16));
|
|
22
|
+
|
|
18
23
|
const pptx = init(containerRef.current, {
|
|
19
|
-
width
|
|
20
|
-
height
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
21
26
|
});
|
|
22
27
|
|
|
23
28
|
const response = await fetch(url, {
|
|
24
29
|
headers: requestHeaders,
|
|
25
30
|
});
|
|
26
31
|
|
|
32
|
+
if (!response.ok) return;
|
|
33
|
+
|
|
27
34
|
const arrayBuffer = await response.arrayBuffer();
|
|
28
35
|
|
|
36
|
+
if (arrayBuffer.byteLength === 0) return;
|
|
37
|
+
|
|
29
38
|
pptx.preview(arrayBuffer);
|
|
30
39
|
};
|
|
31
40
|
|
|
32
41
|
useEffect(() => {
|
|
33
|
-
|
|
42
|
+
renderPptx();
|
|
34
43
|
}, [url]);
|
|
35
44
|
|
|
36
|
-
return
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
ref={containerRef}
|
|
48
|
+
className="w-full [&_.pptx-preview-wrapper]:(overflow-hidden)"
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
37
51
|
};
|
|
38
52
|
|
|
39
53
|
export default Pptx;
|
|
@@ -79,7 +79,8 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const DocDetail: FC<DocDetailProps> = (props) => {
|
|
82
|
-
const { data, i18n, actionButtons, className, ...rest } =
|
|
82
|
+
const { data, i18n, actionButtons, requestHeaders, className, ...rest } =
|
|
83
|
+
props;
|
|
83
84
|
|
|
84
85
|
const [expandMore, setExpandMore] = useState(false);
|
|
85
86
|
|