Preserve QWord bookmarks in DOCX

This commit is contained in:
Курнат Андрей
2026-06-01 19:43:35 +03:00
parent fd2e03a44c
commit f22c7af88b
4 changed files with 86 additions and 10 deletions
+15
View File
@@ -184,6 +184,21 @@ describe("wordOffice DOCX import", () => {
]);
});
it("imports DOCX bookmarks as HTML ids", async () => {
const blob = await exportDocxBlob("Bookmark.docx", '<h1 id="Section1">Section</h1><p><a href="#Section1">Open section</a></p>');
const file = new File([blob], "Bookmark.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain('<h1 id="Section1">Section</h1>');
expect(imported.html).toContain('<a href="#Section1">Open section</a>');
expect(htmlToWordBlocks(imported.html)).toEqual([
{ type: "heading", level: 1, text: "Section", runs: [{ text: "Section" }], bookmark: "Section1" },
{ type: "paragraph", text: "Open section", runs: [{ text: "Open section", href: "#Section1" }] }
]);
});
it("imports simple DOCX tables from OOXML", async () => {
const blob = await exportDocxBlob(
"Table.docx",