Action link
The reference figure and the steps below explain the process of working with links in ONLYOFFICE Document Server.
- The user sends a request to get a link to the document which contains a bookmark in the document editor.
- The document editor sends the request to the document manager where the software integrators create the link.
- The document manager sends the link back to the document editor where the link is displayed.
How this can be done in practice
- Create an html file to Open the document.
Specify the event handler for the Get link button to be displayed in the bookmark editing menu in the configuration script for Document Editor initialization. When the onMakeActionLink event is called, the user request is sent to the software integrators which create the link in the document storage service.
var onMakeActionLink = function (event){
var ACTION_DATA = event.data;
...
var link = GENERATE_LINK(ACTION_DATA);
docEditor.setActionLink(link);
};
var docEditor = new DocsAPI.DocEditor("placeholder", {
"events": {
"onMakeActionLink": onMakeActionLink,
...
},
...
});
In order to give the user the link to the document which contains a bookmark, the software integrators send the link to the setActionLink method:
docEditor.setActionLink(link);
Opening the bookmark
- The user follows the link in the document manager.
- The document manager sends the initialization editorConfig to the document editor.
- The document editor scrolls the document to the bookmark.
When the user follows the link, the document editor sends the initialization editorConfig to the document editing service. The ACTION_DATA received from the onMakeActionLink event is specified in the data.actionLink parameter of the editorConfig:
var docEditor = new DocsAPI.DocEditor("placeholder", {
"editorConfig": {
"actionLink": ACTION_DATA,
...
},
...
});
The link is generated in the same way when mentioning users in the comments.