Preserve QWord paragraph spacing in DOCX
This commit is contained in:
@@ -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 } }
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user