Preserve QWord paragraph indentation in DOCX

This commit is contained in:
Курнат Андрей
2026-06-01 20:05:48 +03:00
parent 15ea571395
commit d403ea7f10
4 changed files with 157 additions and 5 deletions
+18
View File
@@ -256,4 +256,22 @@ describe("wordOffice DOCX import", () => {
rows: [["Stage", "Done"]]
});
});
it("imports DOCX paragraph indentation from OOXML", async () => {
const blob = await exportDocxBlob(
"Indent.docx",
'<p style="margin-left: 36pt; text-indent: 18pt;">Indented</p><p style="margin-left: 48px; text-indent: -12pt;">Hanging</p>'
);
const file = new File([blob], "Indent.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("margin-left: 36pt; text-indent: 18pt;");
expect(imported.html).toContain("margin-left: 36pt; text-indent: -12pt;");
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "paragraph", text: "Indented", runs: [{ text: "Indented" }], indent: { left: 720, firstLine: 360 } },
{ type: "paragraph", text: "Hanging", runs: [{ text: "Hanging" }], indent: { left: 720, hanging: 240 } }
]);
});
});