feat: 完善 Mermaid 配置与预览缩放

This commit is contained in:
SkyJourney
2026-07-26 23:10:22 +08:00
parent 15dd2acfc0
commit d93728bb8b
25 changed files with 870 additions and 56 deletions
+40
View File
@@ -7,6 +7,9 @@ import {
millimetersToCssPixels,
millimetersToPdfPoints,
paperDimensionsMm,
supportedMermaidLayouts,
supportedMermaidLooks,
supportedMermaidThemes,
supportedPaperFormats
} from "../src/export-config.js";
@@ -42,6 +45,43 @@ describe("导出配置", () => {
expect(exportConfigSchema.safeParse(defaultExportConfig).success).toBe(true);
});
it("提供 Mermaid 官方布局、主题、外观和字体默认值", () => {
expect(supportedMermaidLayouts).toEqual(["dagre", "elk"]);
expect(supportedMermaidLooks).toEqual([
"classic",
"handDrawn",
"neo"
]);
expect(supportedMermaidThemes).toContain("redux-dark-color");
expect(defaultExportConfig.mermaid).toEqual({
layout: "dagre",
theme: "default",
look: "classic",
fontFamily: "Segoe UI, Microsoft YaHei, sans-serif"
});
});
it("拒绝 Mermaid 未支持的导出配置", () => {
expect(
exportConfigSchema.safeParse({
...defaultExportConfig,
mermaid: {
...defaultExportConfig.mermaid,
layout: "unknown"
}
}).success
).toBe(false);
expect(
exportConfigSchema.safeParse({
...defaultExportConfig,
mermaid: {
...defaultExportConfig.mermaid,
fontFamily: ""
}
}).success
).toBe(false);
});
it("使用统一的 96 CSS px/in 和 72 PDF pt/in 换算物理尺寸", () => {
expect(millimetersToCssPixels(25.4)).toBeCloseTo(96);
expect(cssPixelsToMillimeters(96)).toBeCloseTo(25.4);