Preserve QWord strikethrough formatting

This commit is contained in:
Курнат Андрей
2026-06-01 07:14:24 +03:00
parent 5a968dea72
commit ea26f5c55d
5 changed files with 63 additions and 3 deletions
+28
View File
@@ -248,6 +248,34 @@ describe("wordOffice helpers", () => {
expect(documentXml).toContain('w:ascii="Arial"');
});
it("сохраняет зачеркнутый текст из HTML для DOCX", () => {
const blocks = htmlToWordBlocks('<p><s>Deleted</s> <span style="text-decoration-line: line-through;">Styled</span></p>');
expect(blocks).toEqual([
{
type: "paragraph",
text: "Deleted Styled",
runs: [
{ text: "Deleted", strike: true },
{ text: " " },
{ text: "Styled", strike: true }
]
}
]);
});
it("преобразует зачеркнутый inline run в параметр docx strike", () => {
expect(wordInlineRunsToTextRunOptions([{ text: "Deleted", strike: true }])).toEqual([{ text: "Deleted", strike: true }]);
});
it("записывает зачеркнутый текст в XML экспортированного DOCX", async () => {
const blob = await exportDocxBlob("Зачеркнутый.docx", "<p><s>Удаленный текст</s></p>");
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
const documentXml = await zip.file("word/document.xml")?.async("string");
expect(documentXml).toContain("<w:strike/>");
});
it("нормализует HTML после импорта DOCX", () => {
expect(normalizeImportedDocxHtml(" <p>Готово</p>\n")).toBe("<p>Готово</p>");
});