feat: 实现动态 DOCX 模板与样式映射
This commit is contained in:
@@ -10,7 +10,8 @@ import {
|
||||
docxCapabilitySchema,
|
||||
docxMediaCapturePlanSchema,
|
||||
docxExportErrorResponseSchema,
|
||||
docxExportRequestSchema
|
||||
docxExportRequestSchema,
|
||||
docxThemeStyleSchema
|
||||
} from "../src/index.js";
|
||||
|
||||
describe("DOCX 共享协议", () => {
|
||||
@@ -165,3 +166,47 @@ describe("DOCX 共享协议", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("DOCX 主题样式协议", () => {
|
||||
it("接受预设和受限样式覆盖", () => {
|
||||
expect(
|
||||
docxThemeStyleSchema.parse({
|
||||
preset: "formal",
|
||||
body: {
|
||||
fonts: {
|
||||
latin: "Times New Roman",
|
||||
eastAsia: "SimSun"
|
||||
},
|
||||
sizePt: 12,
|
||||
lineSpacing: 1.5
|
||||
},
|
||||
headings: {
|
||||
sizesPt: [22, 18, 16, 14, 12, 10.5],
|
||||
color: "#1f2937"
|
||||
},
|
||||
table: {
|
||||
borderColor: "#d1d5db",
|
||||
cellMarginMm: 1.5
|
||||
}
|
||||
})
|
||||
).toMatchObject({
|
||||
preset: "formal",
|
||||
body: { sizePt: 12, lineSpacing: 1.5 }
|
||||
});
|
||||
});
|
||||
|
||||
it("拒绝危险字体名称和越界样式值", () => {
|
||||
expect(() =>
|
||||
docxThemeStyleSchema.parse({
|
||||
preset: "general",
|
||||
body: {
|
||||
fonts: {
|
||||
latin: "Arial; DROP",
|
||||
eastAsia: "宋体"
|
||||
},
|
||||
sizePt: 200
|
||||
}
|
||||
})
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user