Preserve QWord line spacing in DOCX

This commit is contained in:
Курнат Андрей
2026-06-02 08:11:00 +03:00
parent f15467b8a1
commit c9b09565b3
4 changed files with 105 additions and 6 deletions
+18
View File
@@ -381,4 +381,22 @@ describe("wordOffice DOCX import", () => {
{ type: "paragraph", text: "Paragraph spacing", runs: [{ text: "Paragraph spacing" }], spacing: { before: 240, after: 360 } }
]);
});
it("imports DOCX paragraph line spacing from OOXML", async () => {
const blob = await exportDocxBlob(
"LineSpacing.docx",
'<p style="line-height: 1.5;">Auto line height</p><p style="line-height: 24pt;">Exact line height</p>'
);
const file = new File([blob], "LineSpacing.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("line-height: 1.5;");
expect(imported.html).toContain("line-height: 24pt;");
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "paragraph", text: "Auto line height", runs: [{ text: "Auto line height" }], spacing: { line: 360, lineRule: "auto" } },
{ type: "paragraph", text: "Exact line height", runs: [{ text: "Exact line height" }], spacing: { line: 480, lineRule: "exact" } }
]);
});
});