Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ const decode = (params) => {
let commentSchema = getCommentSchema(type, commentIndex);

if (type === 'commentRangeEnd') {
// SD-2910: Word marks comment-anchor runs with w:rStyle="CommentReference" so the
// marker renders with the expected appearance. The importer drops the source w:rPr
// (commentReference is consumed by the comments-list import), so we synthesize the
// canonical rStyle here on every round-trip.
const commentReference = {
name: 'w:r',
elements: [{ name: 'w:commentReference', attributes: { 'w:id': String(commentIndex) } }],
elements: [
{ name: 'w:rPr', elements: [{ name: 'w:rStyle', attributes: { 'w:val': 'CommentReference' } }] },
{ name: 'w:commentReference', attributes: { 'w:id': String(commentIndex) } },
],
};
commentSchema = [commentSchema, commentReference];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('w:commentRangeStart and w:commentRangeEnd', () => {
});

describe('decode:commentRangeEndTranslator', () => {
test('returns comment schema', () => {
test('returns comment schema with CommentReference rStyle on the synthesized anchor run (SD-2910)', () => {
expect(
commentRangeEndTranslator.decode({
node: { type: 'commentRangeEnd', attrs: { 'w:id': 'id1' } },
Expand All @@ -111,15 +111,14 @@ describe('w:commentRangeStart and w:commentRangeEnd', () => {
).toStrictEqual([
{ attributes: { 'w:id': '0' }, name: 'w:commentRangeEnd' },
{
name: 'w:r',
elements: [
{
attributes: {
'w:id': '0',
},
name: 'w:commentReference',
name: 'w:rPr',
elements: [{ name: 'w:rStyle', attributes: { 'w:val': 'CommentReference' } }],
},
{ name: 'w:commentReference', attributes: { 'w:id': '0' } },
],
name: 'w:r',
},
]);
});
Expand Down Expand Up @@ -180,12 +179,19 @@ describe('w:commentRangeStart and w:commentRangeEnd', () => {
commentsExportType: 'external',
});

// Should return bare comment markers, not wrapped in w:del
// Should return bare comment markers, not wrapped in w:del.
// The synthesized anchor run must carry the CommentReference rStyle (SD-2910).
expect(result).toStrictEqual([
{ name: 'w:commentRangeEnd', attributes: { 'w:id': '0' } },
{
name: 'w:r',
elements: [{ name: 'w:commentReference', attributes: { 'w:id': '0' } }],
elements: [
{
name: 'w:rPr',
elements: [{ name: 'w:rStyle', attributes: { 'w:val': 'CommentReference' } }],
},
{ name: 'w:commentReference', attributes: { 'w:id': '0' } },
],
},
]);
});
Expand Down
Loading