测试wps 的sdk
parent
99381e8ed5
commit
cd25fa5e9a
|
|
@ -21,7 +21,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^5.0.0",
|
"@ant-design/icons": "^5.0.0",
|
||||||
|
|
||||||
"@cqsjjb/jjb-common-decorator": "latest",
|
"@cqsjjb/jjb-common-decorator": "latest",
|
||||||
"@cqsjjb/jjb-common-lib": "latest",
|
"@cqsjjb/jjb-common-lib": "latest",
|
||||||
"@cqsjjb/jjb-dva-runtime": "latest",
|
"@cqsjjb/jjb-dva-runtime": "latest",
|
||||||
|
|
@ -29,12 +28,11 @@
|
||||||
"@eigenpal/docx-editor-react": "^1.9.0",
|
"@eigenpal/docx-editor-react": "^1.9.0",
|
||||||
"@rc-component/motion": "^1.0.0",
|
"@rc-component/motion": "^1.0.0",
|
||||||
"@rc-component/util": "^1.11.1",
|
"@rc-component/util": "^1.11.1",
|
||||||
|
|
||||||
"antd": "^5.29.2",
|
"antd": "^5.29.2",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"echarts": "^6.1.0",
|
"echarts": "^6.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"zy-react-library": "^1.2.3"
|
"zy-react-library": "^1.2.3"
|
||||||
|
|
@ -46,7 +44,6 @@
|
||||||
"@babel/preset-react": "^7.29.7",
|
"@babel/preset-react": "^7.29.7",
|
||||||
"@cqsjjb/scripts": "latest",
|
"@cqsjjb/scripts": "latest",
|
||||||
"@eslint-react/eslint-plugin": "^2.2.2",
|
"@eslint-react/eslint-plugin": "^2.2.2",
|
||||||
|
|
||||||
"babel-loader": "^9.1.3",
|
"babel-loader": "^9.1.3",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"css-loader": "^6.8.1",
|
"css-loader": "^6.8.1",
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,21 @@
|
||||||
// App.tsx
|
// App.tsx
|
||||||
import { useRef, useState, useEffect } from "react";
|
import { useRef, useState, useEffect } from "react";
|
||||||
import { DocxEditor } from "@eigenpal/docx-editor-react";
|
import WebOfficeSDK from "web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js";
|
||||||
import { createEmptyDocument } from "@eigenpal/docx-editor-core";
|
|
||||||
import "@eigenpal/docx-editor-react/styles.css";
|
|
||||||
import "./index.less";
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const editorRef = useRef(null);
|
useEffect(() => {
|
||||||
const [currentDocument, setCurrentDocument] = useState(createEmptyDocument());
|
window.onload = async function () {
|
||||||
const [documentBuffer, setDocumentBuffer] = useState();
|
const instance = WebOfficeSDK.init({
|
||||||
|
// 必填项
|
||||||
const chooseWord = () => {
|
officeType: WebOfficeSDK.OfficeType.Writer,
|
||||||
fetch(
|
appId: "SX20260717TSGKEA",
|
||||||
`https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a589a40e4b0f40a8d939aa1.docx`,
|
fileId: "EOCVQPCDCCE4ZJ2X6MTF",
|
||||||
)
|
|
||||||
.then((res) => res.arrayBuffer())
|
|
||||||
.then((buffer) => {
|
|
||||||
setDocumentBuffer(buffer);
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
// 需要等待实例 ready 之后再调用 API
|
||||||
<div style={{ height: "100vh", display: "flex" }}>
|
await instance.ready();
|
||||||
<DocxEditor
|
};
|
||||||
ref={editorRef}
|
}, []);
|
||||||
document={documentBuffer ? undefined : currentDocument}
|
|
||||||
documentBuffer={documentBuffer}
|
return <div style={{ height: "100vh", display: "flex" }}></div>;
|
||||||
mode="editing"
|
|
||||||
onSave={()=>{
|
|
||||||
console.log('save');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="pick-word-container">
|
|
||||||
<div onClick={chooseWord}>文档</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue