Import QWord DOCX paragraph alignment

This commit is contained in:
Курнат Андрей
2026-06-01 05:41:46 +03:00
parent 04811e6580
commit 08fe16bdf6
3 changed files with 30 additions and 5 deletions
+20
View File
@@ -20,4 +20,24 @@ describe("wordOffice DOCX import", () => {
}
]);
});
it("imports DOCX paragraph alignment from OOXML", async () => {
const blob = await exportDocxBlob(
"Alignment.docx",
'<p style="text-align: center;">Centered</p><p align="right">Right</p><p style="text-align: justify;">Justified</p>'
);
const file = new File([blob], "Alignment.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain('style="text-align: center;"');
expect(imported.html).toContain('style="text-align: right;"');
expect(imported.html).toContain('style="text-align: justify;"');
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "paragraph", text: "Centered", runs: [{ text: "Centered" }], alignment: "center" },
{ type: "paragraph", text: "Right", runs: [{ text: "Right" }], alignment: "right" },
{ type: "paragraph", text: "Justified", runs: [{ text: "Justified" }], alignment: "both" }
]);
});
});