Inline editors
The steps below explain the process of connecting several editors to the same html page in ONLYOFFICE Document Server.
Simultaneous work with several editors is available starting from version 5.5.
- Create an empty html file.
Specify your ONLYOFFICE Document Server link with the JavaScript API that will be used for your website:
<script type="text/javascript" src="https://documentserver/web-apps/apps/api/documents/api.js"></script>
Where the documentserver is the name of the server with the ONLYOFFICE Document Server installed.
Add the div element as shown below. In order to connect several editors to the same html page, each of them can be initialized separately:
<div id="placeholder1"></div>
<div id="placeholder2"></div>
<div id="placeholder3"></div>
...
Add the script initializing the Document Editor for the div element with the configuration for the document you want to open. Each editor has its own initialization script:
var documentEditor = new DocsAPI.DocEditor("placeholder1", {
"document": {
"fileType": "docx",
"key": "Khirz6zTPdfd7",
"title": "Example Document Title.docx",
"url": "https://example.com/url-to-example-document.docx"
},
"documentType": "word"
});
var spreadsheetEditor = new DocsAPI.DocEditor("placeholder2", {
"document": {
"fileType": "xlsx",
"key": "af86C7e71Ca8",
"title": "Example Spreadsheet Title.xlsx",
"url": "https://example.com/url-to-example-spreadsheet.xlsx"
},
"documentType": "cell"
});
var presentationEditor = new DocsAPI.DocEditor("placeholder3", {
"document": {
"fileType": "pptx",
"key": "bv48M5r64Sf9",
"title": "Example Presentation Title.pptx",
"url": "https://example.com/url-to-example-presentation.pptx"
},
"documentType": "slide"
});
...
Where the example.com is the name of the server where document manager and document storage service are installed.
In order to finish editing, the destroyEditor method must be called to close the required editor:
documentEditor.destroyEditor();
spreadsheetEditor.destroyEditor();
presentationEditor.destroyEditor();
...
Open your html file in the browser.