The Comments extension adds Word-style commenting with threads, replies, and resolution.
Usage
Configure comments through the modules option:
modules: {
comments: {
readOnly: false,
allowResolve: true
}
}
Commands
Add a comment to the current text selection. Requires text to be selected.
// Simple text comment
editor.commands.addComment('Please review this section')
// With options
editor.commands.addComment({
content: 'Please review',
author: 'Jane Smith',
authorEmail: 'jane@example.com',
isInternal: false
})
Parameters:
Comment text, or an options object with content, author, authorEmail, authorImage, and isInternal fields
Add a reply to an existing comment thread.
editor.commands.addCommentReply({
parentId: 'comment-123',
content: 'Done, updated the wording.'
})
Parameters:
Object with parentId (required), content, author, authorEmail, authorImage
Remove a comment and its highlight marks from the document.
editor.commands.removeComment({ commentId: 'abc-123' })
Parameters:
Object with commentId and/or importedId
Resolve a comment. Removes the highlight but preserves positional anchors for export.
editor.commands.resolveComment({ commentId: 'abc-123' })
Parameters:
Set the active/selected comment thread by ID.
editor.commands.setActiveComment({ commentId: 'abc-123' })
Toggle whether a comment is internal (private) or external.
editor.commands.setCommentInternal({
commentId: 'abc-123',
isInternal: true
})
setCursorById
Move the cursor to the start of a comment’s range. Also works for tracked change IDs.
editor.commands.setCursorById('abc-123')
Events
superdoc.on('commentsUpdate', ({ type, comment }) => {
// type: 'ADD' | 'deleted' | 'SELECTED'
});
Export behavior
Comments export to DOCX as native Word comments:
await superdoc.export({ commentsType: 'external' });
// Without comments
await superdoc.export({ commentsType: 'clean' });
Source code