Comments

更新时间:
复制 MD 格式

This topic describes how to check whether a document has comments, obtain comments, show or hide comments, and delete all comments when you use a text document.

Check whether a document has comments

Check whether a document has comments.

  • Syntax

    Expression.ActiveDocument.HasComments()

    Expression: the document type application object.

  • Return value

    Returns a value of the boolean type. true indicates that the document has comments. false indicates that the document has no comments.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Check whether the document has comments.
      const hasComments = await app.ActiveDocument.HasComments();
      console.log(hasComments); // The return value is true or false. 
    }

Obtain comments

Obtain the comments of a document.

  • Syntax

    Expression.ActiveDocument.GetComments({ Offset, Limit })

    Expression: the document type application object.

  • Parameters

    Important

    Because text documents use liquid layout, it takes a long time to obtain the comments of a large document when you specify a large value for Limit or Offset, or both. In this case, we recommend that you add a loading transition effect.

    Parameter

    Type

    Required

    Description

    Offset

    Number

    Yes

    The starting position.

    Limit

    Number

    Yes

    The maximum number of comments that can be returned.

  • Return value

    Array.<Object>

    The following table describes the parameters in the return value.

    Parameter

    Type

    Description

    auth

    String

    The user who added the comment.

    content

    String

    The comment content.

    date

    Date

    The time when the comment was added.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain comments.
      const operatorsInfo = await app.ActiveDocument.GetComments({ Offset: 0, Limit: 20 });
      console.log(operatorsInfo);
    }

Show or hide the comments

Show or hide the comments of a document.

  • Syntax

    Expression.ActiveDocument.ActiveWindow.View.ShowComments = Boolean

    Expression: the document type application object.

    If you set Boolean to true, the comments are displayed. If you set Boolean to false, the comments are hidden.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Hide the document comments.
      app.ActiveDocument.ActiveWindow.View.ShowComments = false;
    }

Delete all comments

Delete all comments in a document.

  • Syntax

    Expression.ActiveDocument.DeleteAllComments()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Delete all comments in the document.
      await app.ActiveDocument.DeleteAllComments();
    }