diff --git a/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.js b/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.js index 60ead7a371..f4648ec937 100644 --- a/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.js +++ b/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.js @@ -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]; } diff --git a/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.test.js b/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.test.js index 7255c56240..47a5d65c7c 100644 --- a/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.test.js +++ b/packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/commentRange/comment-range-translator.test.js @@ -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' } }, @@ -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', }, ]); }); @@ -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' } }, + ], }, ]); });