feat: 将主题令牌接入 DOCX 动态模板
This commit is contained in:
@@ -10,6 +10,7 @@ import type {
|
||||
PandocDocxConversionResult,
|
||||
PandocRuntimeResolution
|
||||
} from "@md-to-pdf/docx-engine";
|
||||
import type { DocxThemeTokenSet } from "@md-to-pdf/docx-theme-engine";
|
||||
import {
|
||||
DocxExportService,
|
||||
readDocxExportRuntimeLimits,
|
||||
@@ -84,6 +85,16 @@ const availableCapability: DocxCapability = {
|
||||
detectedVersion: "3.9.0.2"
|
||||
};
|
||||
|
||||
const themeTokens: DocxThemeTokenSet = {
|
||||
schemaVersion: 1,
|
||||
themeId: "test-theme",
|
||||
themeFingerprint: "c".repeat(64),
|
||||
mode: "auto-with-overrides",
|
||||
basePreset: "technical",
|
||||
slots: [],
|
||||
diagnostics: []
|
||||
};
|
||||
|
||||
function resolution(
|
||||
capability: DocxCapability = availableCapability
|
||||
): PandocRuntimeResolution {
|
||||
@@ -151,13 +162,22 @@ function createService(options: {
|
||||
options.convert ??
|
||||
vi.fn().mockResolvedValue(conversionResult())
|
||||
},
|
||||
themeTokens: {
|
||||
prepare: vi.fn().mockResolvedValue({
|
||||
tokens: themeTokens,
|
||||
warnings: []
|
||||
})
|
||||
},
|
||||
limits: options.limits
|
||||
});
|
||||
}
|
||||
|
||||
describe("DOCX 共享导出服务", () => {
|
||||
it("串联准备、媒体和转换并返回完整耗时", async () => {
|
||||
const service = createService({});
|
||||
const convert = vi
|
||||
.fn()
|
||||
.mockResolvedValue(conversionResult());
|
||||
const service = createService({ convert });
|
||||
const result = await service.generate(
|
||||
{ markdown: "# 测试" },
|
||||
{ mediaAdapter: emptyAdapter }
|
||||
@@ -170,7 +190,14 @@ describe("DOCX 共享导出服务", () => {
|
||||
echartsErrors: [],
|
||||
mermaidErrors: []
|
||||
});
|
||||
expect(convert).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
themeTokens
|
||||
}),
|
||||
expect.any(AbortSignal)
|
||||
);
|
||||
expect(result.timings).toMatchObject({
|
||||
themeStyleMs: expect.any(Number),
|
||||
referenceMs: 3,
|
||||
pandocMs: 4,
|
||||
validationMs: 5
|
||||
|
||||
Reference in New Issue
Block a user