Preserve QWord internal hyperlinks in DOCX

This commit is contained in:
Курнат Андрей
2026-06-01 19:38:43 +03:00
parent 6204d59418
commit fd2e03a44c
4 changed files with 75 additions and 8 deletions
+17
View File
@@ -167,6 +167,23 @@ describe("wordOffice DOCX import", () => {
]);
});
it("imports DOCX internal hyperlink anchors from OOXML", async () => {
const blob = await exportDocxBlob("InternalHyperlink.docx", '<p>Open <a href="#Section1"><strong>section</strong></a>.</p>');
const file = new File([blob], "InternalHyperlink.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain('<a href="#Section1">');
expect(htmlToWordBlocks(imported.html)).toEqual([
{
type: "paragraph",
text: "Open section.",
runs: [{ text: "Open " }, { text: "section", bold: true, href: "#Section1" }, { text: "." }]
}
]);
});
it("imports simple DOCX tables from OOXML", async () => {
const blob = await exportDocxBlob(
"Table.docx",