feat: 建立 DOCX 主题映射引擎
This commit is contained in:
@@ -27,6 +27,16 @@ export type DocxStylePreset = z.infer<
|
||||
typeof docxStylePresetSchema
|
||||
>;
|
||||
|
||||
export const docxThemeStyleModeSchema = z.enum([
|
||||
"auto",
|
||||
"auto-with-overrides",
|
||||
"explicit"
|
||||
]);
|
||||
|
||||
export type DocxThemeStyleMode = z.infer<
|
||||
typeof docxThemeStyleModeSchema
|
||||
>;
|
||||
|
||||
export const docxFontFamilySchema = z.object({
|
||||
latin: fontNameSchema,
|
||||
eastAsia: fontNameSchema,
|
||||
@@ -37,7 +47,7 @@ export type DocxFontFamily = z.infer<
|
||||
typeof docxFontFamilySchema
|
||||
>;
|
||||
|
||||
const docxBodyStyleSchema = z.object({
|
||||
export const docxBodyStyleSchema = z.object({
|
||||
fonts: docxFontFamilySchema.optional(),
|
||||
sizePt: pointSizeSchema.optional(),
|
||||
color: colorSchema.optional(),
|
||||
@@ -47,7 +57,7 @@ const docxBodyStyleSchema = z.object({
|
||||
spacingAfterPt: spacingSchema.optional()
|
||||
});
|
||||
|
||||
const docxHeadingStyleSchema = z.object({
|
||||
export const docxHeadingStyleSchema = z.object({
|
||||
fonts: docxFontFamilySchema.optional(),
|
||||
sizesPt: z
|
||||
.tuple([
|
||||
@@ -65,7 +75,7 @@ const docxHeadingStyleSchema = z.object({
|
||||
spacingAfterPt: spacingSchema.optional()
|
||||
});
|
||||
|
||||
const docxCodeStyleSchema = z.object({
|
||||
export const docxCodeStyleSchema = z.object({
|
||||
fonts: docxFontFamilySchema.optional(),
|
||||
sizePt: pointSizeSchema.optional(),
|
||||
color: colorSchema.optional(),
|
||||
@@ -74,7 +84,7 @@ const docxCodeStyleSchema = z.object({
|
||||
lineSpacing: z.number().min(1).max(3).optional()
|
||||
});
|
||||
|
||||
const docxBlockStyleSchema = z.object({
|
||||
export const docxBlockStyleSchema = z.object({
|
||||
color: colorSchema.optional(),
|
||||
backgroundColor: colorSchema.optional(),
|
||||
borderColor: colorSchema.optional(),
|
||||
@@ -82,7 +92,7 @@ const docxBlockStyleSchema = z.object({
|
||||
italic: z.boolean().optional()
|
||||
});
|
||||
|
||||
const docxTableStyleSchema = z.object({
|
||||
export const docxTableStyleSchema = z.object({
|
||||
fonts: docxFontFamilySchema.optional(),
|
||||
sizePt: pointSizeSchema.optional(),
|
||||
color: colorSchema.optional(),
|
||||
@@ -92,7 +102,7 @@ const docxTableStyleSchema = z.object({
|
||||
cellMarginMm: z.number().min(0).max(20).optional()
|
||||
});
|
||||
|
||||
const docxCaptionStyleSchema = z.object({
|
||||
export const docxCaptionStyleSchema = z.object({
|
||||
fonts: docxFontFamilySchema.optional(),
|
||||
sizePt: pointSizeSchema.optional(),
|
||||
color: colorSchema.optional(),
|
||||
@@ -100,8 +110,7 @@ const docxCaptionStyleSchema = z.object({
|
||||
alignment: z.enum(["left", "center", "right"]).optional()
|
||||
});
|
||||
|
||||
export const docxThemeStyleSchema = z.object({
|
||||
preset: docxStylePresetSchema,
|
||||
export const docxThemeStyleOverridesSchema = z.object({
|
||||
body: docxBodyStyleSchema.optional(),
|
||||
headings: docxHeadingStyleSchema.optional(),
|
||||
code: docxCodeStyleSchema.optional(),
|
||||
@@ -116,6 +125,18 @@ export const docxThemeStyleSchema = z.object({
|
||||
.optional()
|
||||
});
|
||||
|
||||
export type DocxThemeStyleOverrides = z.infer<
|
||||
typeof docxThemeStyleOverridesSchema
|
||||
>;
|
||||
|
||||
export const docxThemeStyleSchema =
|
||||
docxThemeStyleOverridesSchema.extend({
|
||||
mode: docxThemeStyleModeSchema.optional(),
|
||||
preset: docxStylePresetSchema.optional(),
|
||||
basePreset: docxStylePresetSchema.optional(),
|
||||
overrides: docxThemeStyleOverridesSchema.optional()
|
||||
});
|
||||
|
||||
export type DocxThemeStyle = z.infer<
|
||||
typeof docxThemeStyleSchema
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user