Preserve QWord paragraph spacing in DOCX

This commit is contained in:
Курнат Андрей
2026-06-02 08:03:03 +03:00
parent f5ab0448c7
commit f15467b8a1
4 changed files with 118 additions and 8 deletions
+18
View File
@@ -363,4 +363,22 @@ describe("wordOffice DOCX import", () => {
{ type: "paragraph", text: "Hanging", runs: [{ text: "Hanging" }], indent: { left: 720, hanging: 240 } }
]);
});
it("imports DOCX paragraph spacing from OOXML", async () => {
const blob = await exportDocxBlob(
"Spacing.docx",
'<h2 style="margin-top: 6pt; margin-bottom: 10pt;">Title spacing</h2><p style="margin-top: 12pt; margin-bottom: 18pt;">Paragraph spacing</p>'
);
const file = new File([blob], "Spacing.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("margin-top: 6pt; margin-bottom: 10pt;");
expect(imported.html).toContain("margin-top: 12pt; margin-bottom: 18pt;");
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "heading", level: 2, text: "Title spacing", runs: [{ text: "Title spacing" }], spacing: { before: 120, after: 200 } },
{ type: "paragraph", text: "Paragraph spacing", runs: [{ text: "Paragraph spacing" }], spacing: { before: 240, after: 360 } }
]);
});
});