Simulators
Comments
A comment is a note anchored on a range of the document, with a thread of replies under it. The default scenario holds Alice’s open comment on Beta LLC with Bob’s reply, and Bob’s resolved comment on Confidential Information:
curl -s "$RYSTIC_URL/_rystic/inspect?view=document" | jq -c '.comments[] | {author, resolved, text}'
# -> {"author":"Alice","resolved":false,"text":"Is Beta LLC the right legal entity?"}
# -> {"author":"Bob","resolved":true,"text":"Defined in section 1."}
From a test, these members work with comments:
| Member | What it does |
|---|---|
insertComment on a range | anchors a comment |
getComments on the body, a paragraph or a range | lists comments, with content, authorName, authorEmail, creationDate, id and resolved |
reply | adds a reply |
setting resolved | resolves the thread |
delete | removes the comment |
A reply has its own content, authorName, id and delete:
await Word.run(async context => {
const hit = context.document.body.search('Acme Corp').getFirst();
const comment = hit.insertComment('Check the party name.');
comment.load('authorName,authorEmail,content,resolved');
await context.sync();
comment.reply('Confirmed.');
comment.resolved = true;
comment.replies.load('items/content');
await context.sync();
// comment.authorName -> "Test User", comment.authorEmail -> "user@example.com"
// comment.replies.items.map(r => r.content) -> ["Check the party name.", "Confirmed."]
});
Threads
Threads behave as in Word for the web on a Microsoft 365 work account. A thread’s replies list its first comment as item 0, then each reply. So the reply you just made is the last item, and deleting item 0 deletes the whole thread. A resolved thread takes no reply: reply throws NotAllowed. A comment the simulator writes has authorEmail user@example.com, its signed-in user’s.
Ids and dates
A comment’s or reply’s id is a number the simulator keeps from run to run. Compare comments by content, not id.
Differs from Word for the web: Word mints a random id each run.
A new comment’s creationDate is the simulator’s clock.
Deleted comments
A comment or reply deleted since a collection loaded stays listed in it with its id, author, date and resolved state. Reading its content there throws GeneralException. The deleted comment itself, or the collection’s getFirst that returns it, throws ItemNotFound (Ranges and collections).