Developer Edition ONLYOFFICE Documentation 7.5: API and Documentation Generator Updates

With the release of new features in version 7.5  , ONLYOFFICE has updated the APIs for editors, document generators, plug-ins and desktop applications. Read this article to see all the details.

ONLYOFFICE Docs 7.5 for developers: API and Doc Builder updates

API for handling forms

Hide/show submit form button : Using the editorConfig.customization.submitForm parameter, you can define whether to show or hide the "Submit" button on the top toolbar of the OFORM file.  

var docEditor = new DocsAPI.DocEditor("placeholder", {     
"editorConfig": {         
"customization": {
...
"submitForm": true,

More parameters for force save : In version 7.5, ONLYOFFICE added 3 types for the forcesavetype parameter of the callback handler. If applied, a force save request will be performed every time the form is submitted (for example, when the Submit button is clicked).

{    
 "changesurl": "https://documentserver/url-to-changes.zip",     
"forcesavetype": 3,
....

API for working with documents

Changing external data source : The newly added events.onRequestReferenceSource event will be called when the user attempts to change the external data source by clicking the "Change Source" button in the editor. An object with unique file data and file path or name is sent in the data parameter.  

When the button is clicked, the setReferenceSource method must be called to change the source of the external data. When calling this method, a token must be added to verify the parameters. If the event is not declared, the "Change Source" button will not be displayed. 

var onRequestReferenceSource = function () 
{     var referenceData =  event.data.referenceData;     
var path = event.data.path; 
...
    docEditor.setReferenceSource({        
"fileType": "xlsx",         
"path": "sample.xlsx",         
"referenceData": {             
"fileKey": "BCFA2CED",             
"instanceId": "https://example.com",             
"key": "Khirz6zTPdfd7"        
},

Key field : The key field added to the document.referenceData parameter defines the unique document identifier used by the service to obtain data from the co-editing session.  

If sending a known key, the document will be fetched from cache. The key must be regenerated each time the document is edited and saved.

You can use a document URL as a key, but it cannot contain special characters and is limited to 128 symbols in length.

var docEditor = new DocsAPI.DocEditor("placeholder", {     
"document": {         
"fileType": "docx",         
"key": "Khirz6zTPdfd7",         
"referenceData": {             
"fileKey": "BCFA2CED",             
"instanceId": "https://example.com",             
"key": "Khirz6zTPdfd7"        
},

Conversion API

The conversion API has been extended so that  a -9 error code appears when the converter cannot automatically determine the output file format. 

This error means that the client must explicitly specify which format the file should be converted to – a text document or a spreadsheet. It is used to convert XML to OOXML when the XML type is unknown.

{     
"error": -9 
}

Other updates

Additionally, in the desktop application API , ONLYOFFICE added the uiTheme parameter in the portal:login command, which defines the editor theme settings when connecting the desktop editor to the cloud.

Plug-in API  optimization

The newly added align parameter of the ShowButton method indicates whether the button is displayed on the right or left side of the window. The default value is "left".

window.Asc.plugin.executeMethod ("ShowButton", ["back", false, "right"]);

Document generator API updates

In the document builder API  , ONLYOFFICE adds multiple new watermark and combo box and drop-down list content control methods, multiple global and slideshow methods, including the following methods:

See the full list of new methods .

Please note: Documentation Builder v7.5 will be available for download at a later date.

Guess you like

Origin www.oschina.net/news/263257