Summary
DOCX comments containing w:bookmarkStart / w:bookmarkEnd nodes fail during comment HTML conversion with:
RangeError: Unknown node type: bookmarkStart
Failed to convert comment
The affected comment is then omitted from the loaded comments list.
Minimal shape
A comment containing an invisible bookmark pair around visible mention text is sufficient:
<w:comment w:id="1">
<w:p>
<w:r><w:t>Before mention </w:t></w:r>
<w:bookmarkStart w:id="42" w:name="_mention"/>
<w:r><w:t>@Person</w:t></w:r>
<w:bookmarkEnd w:id="42"/>
</w:p>
</w:comment>
Root cause
The full DOCX editor schema includes bookmarkStart and bookmarkEnd, so the comment XML is converted to valid DOCX-schema JSON.
During processLoadedDocxComments, getHtmlFromComment normalizes that JSON and creates a headless text editor using getRichTextExtensions(). That smaller schema does not include bookmark nodes, but normalizeCommentForEditor currently passes them through. schema.nodeFromJSON throws, the catch returns no HTML, and this guard skips the non-tracked comment:
if (!htmlContent && !comment.trackedChange) {
return;
}
Expected behavior
Invisible bookmark boundary nodes should not prevent the visible comment content from importing.
Suggested narrow fix
Ignore only bookmark boundary nodes while producing the comment's display HTML:
if (node.type === 'bookmarkStart' || node.type === 'bookmarkEnd') {
return null;
}
This leaves the original docxCommentJSON unchanged, so the imported DOCX representation still retains the bookmark metadata. In a local reproduction with two affected comments, both comments imported successfully, visible text and mentions remained intact, the original bookmark JSON was preserved, and the console errors disappeared.
Versions checked
@harbour-enterprises/superdoc@1.44.1
@harbour-enterprises/superdoc@1.45.0
- Current
main implementation of packages/superdoc/src/stores/comments-store.js
Summary
DOCX comments containing
w:bookmarkStart/w:bookmarkEndnodes fail during comment HTML conversion with:The affected comment is then omitted from the loaded comments list.
Minimal shape
A comment containing an invisible bookmark pair around visible mention text is sufficient:
Root cause
The full DOCX editor schema includes
bookmarkStartandbookmarkEnd, so the comment XML is converted to valid DOCX-schema JSON.During
processLoadedDocxComments,getHtmlFromCommentnormalizes that JSON and creates a headless text editor usinggetRichTextExtensions(). That smaller schema does not include bookmark nodes, butnormalizeCommentForEditorcurrently passes them through.schema.nodeFromJSONthrows, the catch returns no HTML, and this guard skips the non-tracked comment:Expected behavior
Invisible bookmark boundary nodes should not prevent the visible comment content from importing.
Suggested narrow fix
Ignore only bookmark boundary nodes while producing the comment's display HTML:
This leaves the original
docxCommentJSONunchanged, so the imported DOCX representation still retains the bookmark metadata. In a local reproduction with two affected comments, both comments imported successfully, visible text and mentions remained intact, the original bookmark JSON was preserved, and the console errors disappeared.Versions checked
@harbour-enterprises/superdoc@1.44.1@harbour-enterprises/superdoc@1.45.0mainimplementation ofpackages/superdoc/src/stores/comments-store.js