Preserve QWord DOCX text colors on import
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportDocxBlob, htmlToWordBlocks, importDocxFile } from "./wordOffice";
|
||||
|
||||
describe("wordOffice DOCX import", () => {
|
||||
it("imports DOCX text color and highlight from OOXML", async () => {
|
||||
const blob = await exportDocxBlob(
|
||||
"Color.docx",
|
||||
'<p><span style="color: #0f5fae; background-color: #fff2cc;">Color fragment</span></p>'
|
||||
);
|
||||
const file = new File([blob], "Color.docx", { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
||||
const imported = await importDocxFile(file);
|
||||
|
||||
expect(imported.html).toContain("color: #0F5FAE;");
|
||||
expect(imported.html).toContain("background-color: #FFF2CC;");
|
||||
expect(htmlToWordBlocks(imported.html)).toEqual([
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "Color fragment",
|
||||
runs: [{ text: "Color fragment", color: "0F5FAE", highlightColor: "FFF2CC" }]
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user