跳到主要内容

ShowComment

通过 ID 显示批注。

语法

expression.ShowComment(commentId);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
commentId必需string | Array.string批注 ID。

返回值

boolean

示例

通过 ID 使文档中的特定批注可见。

// How do I display a comment attached to a text range in a document?

// Reveal a reviewer's comment programmatically so it appears in the comment panel without manual interaction.

const doc = Api.GetDocument();
const paragraph = doc.GetElement(0);
paragraph.AddText('This text has a comment attached to it.');

const range = paragraph.GetRange();
const comment = range.AddComment('Please review this section.', 'John');

if (comment) {
doc.ShowComment(comment.GetId());
const resultParagraph = Api.CreateParagraph();
const author = comment.GetAuthorName();
resultParagraph.AddText('Comment by ' + author + ' is now displayed.');
doc.Push(resultParagraph);
}