Skip to content
Merged
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
8 changes: 7 additions & 1 deletion packages/super-editor/src/core/super-converter/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,13 @@ function translateLineBreak(params) {
}

return {
name: 'w:br',
name: 'w:r',
elements: [
{
name: 'w:br',
attributes,
},
],
attributes,
Comment thread
harbournick marked this conversation as resolved.
};
}
Expand Down
Binary file not shown.
41 changes: 41 additions & 0 deletions packages/super-editor/src/tests/export/lineBreakExporter.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { getExportedResult } from './export-helpers/index';

describe('LineBreakExporter', () => {
let result;
let body;

beforeAll(async () => {
result = await getExportedResult('line-break.docx');
});

beforeEach(() => {
body = result.elements?.find((el) => el.name === 'w:body');
});

it('exports lineBreak nodes wrapped in w:r (run) elements', () => {
// Grab the first paragraph that contains line breaks
const paragraphWithLineBreaks = body.elements?.find(
(el) =>
el.name === 'w:p' &&
el.elements?.some((run) => run.name === 'w:r' && run.elements?.some((element) => element.name === 'w:br')),
);

expect(paragraphWithLineBreaks).toBeDefined();
expect(paragraphWithLineBreaks.name).toBe('w:p');

const runs = paragraphWithLineBreaks.elements?.filter((el) => el.name === 'w:r') || [];
expect(runs.length).toBeGreaterThan(0);

const runsWithLineBreaks = runs.filter((run) => run.elements?.some((element) => element.name === 'w:br'));

expect(runsWithLineBreaks.length).toBeGreaterThan(0);

// Verify the structure: w:r -> w:br
runsWithLineBreaks.forEach((run) => {
expect(run.name).toBe('w:r');
const lineBreak = run.elements?.find((element) => element.name === 'w:br');
expect(lineBreak).toBeDefined();
expect(lineBreak.name).toBe('w:br');
});
});
});
Loading