Import QWord DOCX lists from numbering

This commit is contained in:
Курнат Андрей
2026-06-02 05:57:52 +03:00
parent 22d2903f10
commit 2f1c70852d
3 changed files with 189 additions and 36 deletions
+33
View File
@@ -225,6 +225,39 @@ describe("wordOffice DOCX import", () => {
]);
});
it("imports DOCX bullet and numbered lists from OOXML numbering", async () => {
const blob = await exportDocxBlob(
"Lists.docx",
'<ul><li>Bullet <strong>one</strong></li><li><span style="color: #0f5fae;">Bullet two</span></li></ul><ol><li>Step one</li><li>Step two</li></ol>'
);
const file = new File([blob], "Lists.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("<ul>");
expect(imported.html).toContain("<ol>");
expect(imported.html).toContain("color: #0F5FAE;");
expect(htmlToWordBlocks(imported.html)).toEqual([
{
type: "list",
ordered: false,
items: [
{ text: "Bullet one", runs: [{ text: "Bullet " }, { text: "one", bold: true }] },
{ text: "Bullet two", runs: [{ text: "Bullet two", color: "0F5FAE" }] }
]
},
{
type: "list",
ordered: true,
items: [
{ text: "Step one", runs: [{ text: "Step one" }] },
{ text: "Step two", runs: [{ text: "Step two" }] }
]
}
]);
});
it("imports styled DOCX content when the document also contains images", async () => {
const blob = await exportDocxBlob(
"Mixed.docx",