SOURCE

console 命令行工具 X clear

                    
>
console
let docEditor = null;

// Word 文档配置
const documentConfig = {
    documentType: 'word',
    document: {
        fileType: 'docx',
        key: 'example_' + Date.now(), 
        title: '文档服务中国版',
        url: 'https://moqisoft.github.io/assets/example.docx' // 需要替换为实际文档URL,且容器内可正常下载
    },
    editorConfig: {
        lang: 'zh-CN',
        mode: 'edit',
        callbackUrl: undefined,  // 需要替换为实际回调URL
        user: {
            id: 'user_1',
            name: '用户1'
        },
        customization: {
            autosave: true,
            forcesave: true,
            comments: true,
            chat: true,
            compactToolbar: false,
            feedback: true,
        }
    },
    height: '100%',
    width: '100%'
};

// 页面加载完成后,打开 Word 文档
window.addEventListener('load', function () {
    console.log('OnlyOffice API 加载完成');
    // 延迟一点时间确保 API 完全加载
    setTimeout(() => {
        try {
            docEditor = new DocsAPI.DocEditor('editor', documentConfig);
            console.log('已加载文档: example.docx');
        } catch (error) {
            console.error('加载编辑器失败:', error);
            alert('加载编辑器失败,请检查 OnlyOffice API 是否正确加载。');
        }
    }, 500);
});
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=, initial-scale=">
	<meta http-equiv="X-UA-Compatible" content="">
    <script src="https://ds-demo.moqisoft.com/web-apps/apps/api/documents/api.js"></script>
	<title>documentserver 标准集成示例</title>
</head>

<body>
	 <div class="outer" id="editor">
         loading...
     </div>
</body>

</html>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  font-size: 14px;
}

.outer {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
}