作者 | 日期 |
---|---|
雨中星辰 | 2018-12-20 |
參考圖和步驟說明了在ONLYOFFICE文檔服務(wù)器中共同編輯文檔的過程。
image.png
- 用戶1和用戶2在文檔編輯器中打開同一個文檔,即當打開文件時,使用了同一個document.key。
- 用戶1對打開的文檔進行更改。
- 該文檔編輯器發(fā)送由用戶1做出的更改文檔編輯服務(wù)。
- 該文檔編輯服務(wù)發(fā)送由用戶1做出了用戶2的變化的文檔編輯器。
- 現(xiàn)在,用戶2可以看到這些更改。
共同編輯
如何在實踐中做到這一點
- 創(chuàng)建一個空的html文件。
- 添加div元素,如下所示。
<div id="placeholder"></div>
- 使用將用于您網(wǎng)站的JavaScript API指定您的ONLYOFFICE文檔服務(wù)器鏈接。
<script type="text/javascript" src="https://documentserver/web-apps/apps/api/documents/api.js"></script>
documentserver是一臺安裝ONLYOFFICE文件服務(wù)器的服務(wù)器的名稱。
- 添加腳本初始化文件編輯器的DIV與您要打開的文檔的配置元素。
new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": "docx",
"key": "Khirz6zTPdfd7",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
},
"documentType": "text",
"editorConfig": {
"user": {
"id": "78e1e841",
"name": "John Smith"
}
}
});
其中**example.com**是安裝**文檔管理器**和**文檔存儲服務(wù)**的服務(wù)器的名稱。
- 在瀏覽器中打開您的html文件。
- 現(xiàn)在制作上面創(chuàng)建的html文件的副本。
- 更改在復(fù)制的html文件中初始化文檔編輯器的腳本。
new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": "docx",
"key": "Khirz6zTPdfd7",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
},
"documentType": "text",
"editorConfig": {
"user": {
"id": "F89d8069ba2b",
"name": "Kate Cage"
}
}
});
其中**example.com**是安裝**文檔管理器**和**文檔存儲服務(wù)**的服務(wù)器的名稱。
- 在瀏覽器中打開復(fù)制和編輯的html文件。
onlyoffice中文指南 目錄
【onlyoffice中文指南】0-基本概念
【onlyoffice中文指南】1-onlyoffice的工作原理
【onlyoffice中文指南】2-打開文件
【onlyoffice中文指南】3-保存文件
【onlyoffice中文指南】4-協(xié)同編輯
【onlyoffice中文指南】5-轉(zhuǎn)換和下載文件
【onlyoffice中文指南】6-文檔歷史
【onlyoffice中文指南】7-安全
【onlyoffice中文指南】8-高級參數(shù)
【onlyoffice中文指南】9-回調(diào)處理程序
【onlyoffice中文指南】10-Document配置
【onlyoffice中文指南】11-編輯器(Editor)參數(shù)配置
【onlyoffice中文指南】12-問題及排除
本文翻譯自官方文檔