Commenting

The Comment option allows you to leave comments on the specific words, phrases, sentences and other document parts, edit and remove these comments. All the comments will be saved and shown to other document users.

Commenting - 图1

Comment access rights

In order to enable the comment option, the comment parameter in the permissions section of the document initialization must be set to true. The document side bar will contain the Comment menu option.

In case the edit parameter is set to true and the comment parameter is also set to true, the user will be able to edit the document and comment.

Commenting

In case the edit parameter is set to false and the comment parameter is set to true, the document will be available for commenting only.

  1. var docEditor = new DocsAPI.DocEditor("placeholder", {
  2. "document": {
  3. "permissions": {
  4. "edit": false,
  5. "comment": true
  6. ...
  7. },
  8. ...
  9. },
  10. ...
  11. });

Please note that the document commenting will only be available for the document editor if the mode parameter is set to edit.

Differentiation of commenting rights by authors

  1. If you want to allow editing comments only by their authors, set the editCommentAuthorOnly parameter in the permissions section of the editor initialization to true.

    1. var docEditor = new DocsAPI.DocEditor("placeholder", {
    2. "document": {
    3. "permissions": {
    4. "editCommentAuthorOnly": true
    5. ...
    6. },
    7. ...
    8. },
    9. ...
    10. });
  2. If you want to allow deleting comments only by their authors, set the deleteCommentAuthorOnly parameter in the permissions section of the editor initialization to true.

    1. var docEditor = new DocsAPI.DocEditor("placeholder", {
    2. "document": {
    3. "permissions": {
    4. "deleteCommentAuthorOnly": true
    5. ...
    6. },
    7. ...
    8. },
    9. ...
    10. });

Differentiation of commenting rights by groups

  1. Specify the group (or several groups separated with commas) the user belongs to by adding the field group to the user parameter in the editorConfig section.

    1. var docEditor = new DocsAPI.DocEditor("placeholder", {
    2. "editorConfig": {
    3. "user": {
    4. "id": "78e1e841",
    5. "name": "John Smith",
    6. "group": "Group1"
    7. }
    8. },
    9. ...
    10. });
    11. var docEditor = new DocsAPI.DocEditor("placeholder", {
    12. "editorConfig": {
    13. "user": {
    14. "id": "F89d8069ba2b",
    15. "name": "Kate Cage",
    16. "group": "Group2"
    17. }
    18. },
    19. ...
    20. });
  2. Specify the access rights using the commentGroups parameter in the permissions section of the editor initialization.

    If the commentGroups parameter is specified in the editor config, the access rights to viewing, editing and/or removing all comments are disabled. Otherwise, if the current user does not belong to any of the groups, he or she can edit, remove and/or view comments of all groups.

    1. var docEditor = new DocsAPI.DocEditor("placeholder", {
    2. "document": {
    3. "permissions": {
    4. "commentGroups": {
    5. "edit": ["Group2", ""],
    6. "remove": [""],
    7. "view": ""
    8. },
    9. ...
    10. }
    11. ...
    12. },
    13. ...
    14. });
    • “edit”: [“Group2”, “”] means that the user can edit comments made by users from Group2 and users who do not belong to any of the groups (for example, the document that is commented in third-party editors).
    • “remove”: [“”] means that the user can remove comments made by someone who belongs to none of these groups (for example, the document that is commented in third-party editors).
    • “view”: “” means that the user can view comments made by any user.

Threaded comments in spreadsheets

To display ONLYOFFICE spreadsheet comments in other editors correctly, all the comments are saved in two formats - original and threaded:

  1. The original comment format looks as follows:

    1. ${author1}:
    2. comment
    3. ${author2}:
    4. reply1
    5. ${author2}:
    6. reply2

    Commenting - 图3

  2. To convert the original comments format into the threaded comments, the “${author}:\n” string is deleted if the comment starts with it.

The file in the editors opens as follows:

  • If there are threaded comments in the file, they are used when opening.
  • If there are comments in the original ONLYOFFICE format only, they are converted into threaded comments.