跳到主要内容

AddComment

向指定的文档元素或 Runs 数组添加批注。

语法

expression.AddComment(element, text, author, userId);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
element必需ApiRun[] | DocumentElement将添加批注的元素。可以应用于任何具有 AddComment 方法的元素。
text必需string批注文本。
author可选string作者姓名。
userId可选string批注作者的用户 ID。

返回值

ApiComment

示例

此示例向第一个段落添加文本和批注。

// How to add a comment to the ApiParagraph class.

// How to comment on text.

// Adds a paragraph to the document and comments on it.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
Api.AddComment(paragraph, "ONLYOFFICE for developers", "Jane");