diff --git a/src/pages/Container/Test/edtior/index.js b/src/pages/Container/Test/edtior/index.js index 56dadaa..ca8bf7c 100644 --- a/src/pages/Container/Test/edtior/index.js +++ b/src/pages/Container/Test/edtior/index.js @@ -1,34 +1,39 @@ // App.tsx -import { useRef, useState } from 'react'; -import { DocxEditor } from '@eigenpal/docx-editor-react'; -import '@eigenpal/docx-editor-react/styles.css'; +import { useRef, useState, useEffect } from "react"; +import { DocxEditor } from "@eigenpal/docx-editor-react"; +import { createEmptyDocument } from "@eigenpal/docx-editor-core"; +import "@eigenpal/docx-editor-react/styles.css"; +import "./index.less"; + export default function App() { const editorRef = useRef(null); - const [file, setFile] = useState(null); - async function download() { - const buffer = await editorRef.current?.save(); - if (!buffer) return; - const blob = new Blob([buffer], { - type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = file?.name ?? 'document.docx'; - a.click(); - URL.revokeObjectURL(url); - } + const [currentDocument, setCurrentDocument] = useState(createEmptyDocument()); + const [documentBuffer, setDocumentBuffer] = useState(); + + const chooseWord = () => { + fetch( + `https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a589a40e4b0f40a8d939aa1.docx`, + ) + .then((res) => res.arrayBuffer()) + .then((buffer) => { + setDocumentBuffer(buffer); + }); + }; + return ( -
-
- setFile(e.target.files?.[0] ?? null)} - /> - +
+ { + console.log('save'); + }} + /> +
+
文档
- {file && }
); -} \ No newline at end of file +} diff --git a/src/pages/Container/Test/edtior/index.less b/src/pages/Container/Test/edtior/index.less new file mode 100644 index 0000000..9c6eda3 --- /dev/null +++ b/src/pages/Container/Test/edtior/index.less @@ -0,0 +1,4 @@ +.pick-word-container{ + height: 100%; + width: 200px; +} \ No newline at end of file