Preserve QWord DOCX tables on import

This commit is contained in:
Курнат Андрей
2026-06-01 08:05:14 +03:00
parent 95be5e3a8a
commit 9ad29a184b
3 changed files with 78 additions and 13 deletions
+26
View File
@@ -112,4 +112,30 @@ describe("wordOffice DOCX import", () => {
}
]);
});
it("imports simple DOCX tables from OOXML", async () => {
const blob = await exportDocxBlob(
"Table.docx",
"<p>Before table</p><table><tr><th>Stage</th><th>Owner</th></tr><tr><td>Plan</td><td>Anna</td></tr></table><p>After table</p>"
);
const file = new File([blob], "Table.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("<table>");
expect(imported.html).toContain("<td><p>Stage</p></td>");
expect(imported.html).toContain("<td><p>Anna</p></td>");
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "paragraph", text: "Before table", runs: [{ text: "Before table" }] },
{
type: "table",
rows: [
["Stage", "Owner"],
["Plan", "Anna"]
]
},
{ type: "paragraph", text: "After table", runs: [{ text: "After table" }] }
]);
});
});