fix: 修复DOCX独立封面视觉门禁
统一 Chromium 与 DOCX 的受限高度封面布局,补齐可编辑边框、装饰边和 Office 页面舍入适配。 按四套独立封面主题、纵横方向及五组页边距执行 40 个 Word/WPS 真实视觉场景,严格失败为 0,并保留正文诊断供 D4 修复。
This commit is contained in:
@@ -366,11 +366,12 @@ function normalizeComputedSlot(
|
||||
message: "CSS outline 已近似为 Word 四边边框"
|
||||
});
|
||||
} else {
|
||||
style.outline = outline;
|
||||
diagnostic(context, {
|
||||
severity: "warning",
|
||||
code: "css-property-unsupported",
|
||||
severity: "info",
|
||||
code: "layout-approximated",
|
||||
property: "outline",
|
||||
message: "CSS border 与 outline 并存,Word 单层边框仅保留 border,结构层需生成双层边框"
|
||||
message: "CSS border 与 outline 并存,DOCX 容器将生成双层边框"
|
||||
});
|
||||
}
|
||||
context.approximate = true;
|
||||
@@ -380,11 +381,18 @@ function normalizeComputedSlot(
|
||||
computed.outlineOffset
|
||||
);
|
||||
if (outlineOffsetPt !== undefined && outlineOffsetPt !== 0) {
|
||||
if (style.outline) {
|
||||
style.outlineOffsetPt = outlineOffsetPt;
|
||||
}
|
||||
diagnostic(context, {
|
||||
severity: "warning",
|
||||
code: "css-property-unsupported",
|
||||
severity: style.outline ? "info" : "warning",
|
||||
code: style.outline
|
||||
? "layout-approximated"
|
||||
: "css-property-unsupported",
|
||||
property: "outline-offset",
|
||||
message: `Word 边框不支持 CSS outline-offset ${outlineOffsetPt}pt,结构层需近似处理`
|
||||
message: style.outline
|
||||
? `DOCX 容器将以单元格间距近似 CSS outline-offset ${outlineOffsetPt}pt`
|
||||
: `Word 边框不支持 CSS outline-offset ${outlineOffsetPt}pt,结构层需近似处理`
|
||||
});
|
||||
context.approximate = true;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ export const docxSlotStyleTokenSchema = z.object({
|
||||
left: docxBorderTokenSchema.optional()
|
||||
})
|
||||
.optional(),
|
||||
outline: docxBorderTokenSchema.optional(),
|
||||
outlineOffsetPt: z.number().min(-1000).max(1000).optional(),
|
||||
widthPercent: z.number().min(0).max(100).optional(),
|
||||
minimumWidthPercent: z.number().min(0).max(100).optional(),
|
||||
minimumHeightPt: z.number().min(0).max(10000).optional(),
|
||||
|
||||
@@ -330,6 +330,14 @@ describe("DOCX 主题令牌归一化", () => {
|
||||
expect(
|
||||
findSlot(tokens, "tender-cover").style.borders?.top?.widthPt
|
||||
).toBe(20);
|
||||
expect(findSlot(tokens, "tender-cover").style).toMatchObject({
|
||||
outline: {
|
||||
widthPt: 0.75,
|
||||
color: "#777777",
|
||||
style: "single"
|
||||
},
|
||||
outlineOffsetPt: -12
|
||||
});
|
||||
expect(
|
||||
tokens.diagnostics.some(
|
||||
(entry) =>
|
||||
@@ -343,7 +351,7 @@ describe("DOCX 主题令牌归一化", () => {
|
||||
(entry) =>
|
||||
entry.slot === "tender-cover" &&
|
||||
entry.property === "outline" &&
|
||||
entry.code === "css-property-unsupported"
|
||||
entry.code === "layout-approximated"
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user