The reference figure and the steps below explain the process of mentioning users in comments in ONLYOFFICE Docs.
In the configuration script for Document Editor initialization, specify the event handler for the hint about mentioning users in the comments to be displayed. When the user types the + sign, the onRequestUsers event is called and the commenter can select other users for mentioning in the comments. The data.c parameter with the mention operation type is passed in this event.
var onRequestUsers = function(event) { docEditor.setUsers({ "c": event.data.c, "users": [ { "email": "john@example.com", "name": "John Smith" }, { "email": "kate@example.com", "name": "Kate Cage" }, ... ] }); }; var docEditor = new DocsAPI.DocEditor("placeholder", { "events": { "onRequestUsers": onRequestUsers, ... }, ... });
In order to set the users list under the comment field, the setUsers method must be called:
docEditor.setUsers({ "c": "mention", "users": [ { "email": "john@example.com", "name": "John Smith" }, { "email": "kate@example.com", "name": "Kate Cage" }, ... ] });
Where the example.com is the name of the server where document manager and document storage service are installed. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.
Specify the event handler for the comment message and the list of emails to be sent in the configuration script for Document Editor initialization. When the user adds the comment, the onRequestSendNotify event is called. The message and the list of emails are sent in the data parameter. The comment data is received in the data.actionLink parameter. As in the case of adding an action link to a bookmark, an actionLink object must be used in the configuration as the value for the editorConfig.actionLink parameter.
var onRequestSendNotify = function(event) { var ACTION_DATA = event.data.actionLink; var comment = event.data.message; var emails = event.data.emails; ... }; var docEditor = new DocsAPI.DocEditor("placeholder", { "events": { "onRequestSendNotify": onRequestSendNotify, ... }, ... });
When the onRequestSendNotify event is called, the software integrators provide access to the file, send notifications to the mentioned users with the action link which allows scrolling to the comment position in the document.
In the case when the document.info.sharingSettings field is used in the document initialization but the list of the users from the onRequestSendNotify event is different, the setSharingSettings method must be called.
docEditor.setSharingSettings({ "sharingSettings": [ { "permissions": "Full Access", "user": "John Smith" }, { "isLink": true, "permissions": "Read Only", "user": "External link" } ] });
In the case when the onRequestSendNotify event does not provide access to the file, the mentionShare parameter in the customization section of the editor configuration must be set to false.