CommentCollection class
CommentCollection class
Provides typed access to a collection of Comment nodes. To learn more, visit the Working with Comments documentation article.
Inheritance: CommentCollection → NodeCollection
Properties
Name | Description |
---|---|
count | Gets the number of nodes in the collection. (Inherited from NodeCollection) |
this[] | (Inherited from NodeCollection) |
Methods
Name | Description |
---|---|
add(node) | Adds a node to the end of the collection. (Inherited from NodeCollection) |
clear() | Removes all nodes from this collection and from the document. (Inherited from NodeCollection) |
contains(node) | Determines whether a node is in the collection. (Inherited from NodeCollection) |
indexOf(node) | Returns the zero-based index of the specified node. (Inherited from NodeCollection) |
insert(index, node) | Inserts a node into the collection at the specified index. (Inherited from NodeCollection) |
remove(node) | Removes the node from the collection and from the document. (Inherited from NodeCollection) |
removeAt(index) | Removes the node at the specified index from the collection and from the document. (Inherited from NodeCollection) |
toArray() | Copies all nodes from the collection to a new array of nodes. (Inherited from NodeCollection) |
Examples
Shows how to mark a comment as “done”.
let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);
builder.writeln("Helo world!");
// Insert a comment to point out an error.
let comment = new aw.Comment(doc, "John Doe", "J.D.", Date.now());
comment.setText("Fix the spelling error!");
doc.firstSection.body.firstParagraph.appendChild(comment);
// Comments have a "Done" flag, which is set to "false" by default.
// If a comment suggests that we make a change within the document,
// we can apply the change, and then also set the "Done" flag afterwards to indicate the correction.
expect(comment.done).toEqual(false);
doc.firstSection.body.firstParagraph.runs.at(0).text = "Hello world!";
comment.done = true;
// Comments that are "done" will differentiate themselves
// from ones that are not "done" with a faded text color.
comment = new aw.Comment(doc, "John Doe", "J.D.", Date.now());
comment.setText("Add text to this paragraph.");
builder.currentParagraph.appendChild(comment);
doc.save(base.artifactsDir + "Comment.done.docx");
See Also
- module Aspose.Words
- class NodeCollection