@json-to-office/shared-pptx 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-3TK45DVZ.js +68 -0
- package/dist/chunk-3TK45DVZ.js.map +1 -0
- package/dist/{chunk-7MPP5MFF.js → chunk-BIJP7NTG.js} +2 -2
- package/dist/{chunk-I3XL4HX7.js → chunk-G3FMM4FX.js} +207 -145
- package/dist/chunk-G3FMM4FX.js.map +1 -0
- package/dist/{chunk-5ER63EW5.js → chunk-HYJ6MU3F.js} +4 -13
- package/dist/chunk-HYJ6MU3F.js.map +1 -0
- package/dist/chunk-NCBBMAVS.js +64 -0
- package/dist/chunk-NCBBMAVS.js.map +1 -0
- package/dist/chunk-ZMZKHRBS.js +158 -0
- package/dist/chunk-ZMZKHRBS.js.map +1 -0
- package/dist/index.d.ts +6 -68
- package/dist/index.js +39 -22
- package/dist/index.js.map +1 -1
- package/dist/schemas/component-defaults.js +1 -1
- package/dist/schemas/component-registry.js +3 -2
- package/dist/schemas/component-union.d.ts +2 -11
- package/dist/schemas/component-union.js +4 -3
- package/dist/schemas/components.d.ts +3 -265
- package/dist/schemas/components.js +12 -11
- package/dist/schemas/document.js +5 -4
- package/dist/schemas/generator.js +4 -3
- package/dist/schemas/theme.d.ts +2 -8
- package/dist/schemas/theme.js +2 -1
- package/package.json +2 -2
- package/dist/chunk-5ER63EW5.js.map +0 -1
- package/dist/chunk-I3XL4HX7.js.map +0 -1
- package/dist/chunk-STLETJGO.js +0 -1102
- package/dist/chunk-STLETJGO.js.map +0 -1
- package/dist/chunk-YKBPU4GM.js +0 -42
- package/dist/chunk-YKBPU4GM.js.map +0 -1
- /package/dist/{chunk-7MPP5MFF.js.map → chunk-BIJP7NTG.js.map} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAllPptxComponentSchemasNarrowed
|
|
3
|
+
} from "./chunk-G3FMM4FX.js";
|
|
4
|
+
|
|
5
|
+
// src/schemas/generator.ts
|
|
6
|
+
import { Type } from "@sinclair/typebox";
|
|
7
|
+
import { latestVersion } from "@json-to-office/shared";
|
|
8
|
+
function createPluginVersionSchema(custom, entry, recursiveRef, isLatest) {
|
|
9
|
+
const fields = {
|
|
10
|
+
name: Type.Literal(custom.name),
|
|
11
|
+
id: Type.Optional(Type.String()),
|
|
12
|
+
enabled: Type.Optional(
|
|
13
|
+
Type.Boolean({
|
|
14
|
+
default: true,
|
|
15
|
+
description: "When false, this component is filtered out and not rendered. Defaults to true."
|
|
16
|
+
})
|
|
17
|
+
),
|
|
18
|
+
// Omitting version selects the latest release at runtime. Explicit older
|
|
19
|
+
// versions remain discriminated so their own props schema is enforced.
|
|
20
|
+
version: isLatest ? Type.Optional(Type.Literal(entry.version)) : Type.Literal(entry.version),
|
|
21
|
+
props: entry.propsSchema
|
|
22
|
+
};
|
|
23
|
+
if (entry.hasChildren) {
|
|
24
|
+
fields.children = Type.Optional(Type.Array(recursiveRef));
|
|
25
|
+
}
|
|
26
|
+
return Type.Object(fields, {
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
description: entry.description ?? custom.name
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function generateUnifiedDocumentSchema(options = {}) {
|
|
32
|
+
const { customComponents = [] } = options;
|
|
33
|
+
return Type.Recursive((Self) => {
|
|
34
|
+
const pluginSchemas = [];
|
|
35
|
+
for (const custom of customComponents) {
|
|
36
|
+
if (custom.versions.length > 0) {
|
|
37
|
+
const latest = latestVersion(
|
|
38
|
+
custom.versions.map((entry) => entry.version)
|
|
39
|
+
);
|
|
40
|
+
const versions = custom.versions.map(
|
|
41
|
+
(entry) => createPluginVersionSchema(
|
|
42
|
+
custom,
|
|
43
|
+
entry,
|
|
44
|
+
Self,
|
|
45
|
+
entry.version === latest
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
pluginSchemas.push(
|
|
49
|
+
versions.length === 1 ? versions[0] : Type.Union(versions)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const standardSchemas = createAllPptxComponentSchemasNarrowed(
|
|
54
|
+
Self,
|
|
55
|
+
pluginSchemas
|
|
56
|
+
);
|
|
57
|
+
const componentSchemas = [...standardSchemas, ...pluginSchemas];
|
|
58
|
+
if (componentSchemas.length === 0) {
|
|
59
|
+
return Type.Object({});
|
|
60
|
+
}
|
|
61
|
+
return Type.Union(componentSchemas);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
generateUnifiedDocumentSchema
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=chunk-3TK45DVZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/generator.ts"],"sourcesContent":["/**\n * Unified Presentation Schema Generator\n *\n * Generates JSON schemas that include both standard and custom plugin components.\n * Used at build-time for static schema files and at runtime for plugin-aware validation.\n */\nimport { Type, TSchema } from '@sinclair/typebox';\nimport { latestVersion } from '@json-to-office/shared';\nimport { createAllPptxComponentSchemasNarrowed } from './component-registry';\n\nexport interface VersionedPropsEntry {\n version: string;\n propsSchema: TSchema;\n hasChildren?: boolean;\n description?: string;\n}\n\nexport interface CustomComponentInfo {\n name: string;\n versions: VersionedPropsEntry[];\n}\n\nexport interface GenerateSchemaOptions {\n customComponents?: CustomComponentInfo[];\n includeMetadata?: boolean;\n}\n\nfunction createPluginVersionSchema(\n custom: CustomComponentInfo,\n entry: VersionedPropsEntry,\n recursiveRef: TSchema,\n isLatest: boolean\n): TSchema {\n const fields: Record<string, TSchema> = {\n name: Type.Literal(custom.name),\n id: Type.Optional(Type.String()),\n enabled: Type.Optional(\n Type.Boolean({\n default: true,\n description:\n 'When false, this component is filtered out and not rendered. Defaults to true.',\n })\n ),\n // Omitting version selects the latest release at runtime. Explicit older\n // versions remain discriminated so their own props schema is enforced.\n version: isLatest\n ? Type.Optional(Type.Literal(entry.version))\n : Type.Literal(entry.version),\n props: entry.propsSchema,\n };\n\n if (entry.hasChildren) {\n fields.children = Type.Optional(Type.Array(recursiveRef));\n }\n\n return Type.Object(fields, {\n additionalProperties: false,\n description: entry.description ?? custom.name,\n });\n}\n\n/**\n * Generate a unified presentation schema that includes standard + custom components.\n * Uses Type.Recursive so container components (presentation, slide) can have children.\n */\nexport function generateUnifiedDocumentSchema(\n options: GenerateSchemaOptions = {}\n): TSchema {\n const { customComponents = [] } = options;\n\n return Type.Recursive((Self) => {\n // ── Phase 1: Build plugin schemas (plugins get Self for arbitrary nesting) ──\n const pluginSchemas: TSchema[] = [];\n\n for (const custom of customComponents) {\n if (custom.versions.length > 0) {\n const latest = latestVersion(\n custom.versions.map((entry) => entry.version)\n );\n const versions = custom.versions.map((entry) =>\n createPluginVersionSchema(\n custom,\n entry,\n Self,\n entry.version === latest\n )\n );\n pluginSchemas.push(\n versions.length === 1 ? versions[0] : Type.Union(versions)\n );\n }\n }\n\n // ── Phase 2: Build standard components with narrowed children ──\n const standardSchemas = createAllPptxComponentSchemasNarrowed(\n Self,\n pluginSchemas\n );\n\n const componentSchemas = [...standardSchemas, ...pluginSchemas];\n\n if (componentSchemas.length === 0) {\n return Type.Object({});\n }\n\n return Type.Union(componentSchemas);\n });\n}\n"],"mappings":";;;;;AAMA,SAAS,YAAqB;AAC9B,SAAS,qBAAqB;AAoB9B,SAAS,0BACP,QACA,OACA,cACA,UACS;AACT,QAAM,SAAkC;AAAA,IACtC,MAAM,KAAK,QAAQ,OAAO,IAAI;AAAA,IAC9B,IAAI,KAAK,SAAS,KAAK,OAAO,CAAC;AAAA,IAC/B,SAAS,KAAK;AAAA,MACZ,KAAK,QAAQ;AAAA,QACX,SAAS;AAAA,QACT,aACE;AAAA,MACJ,CAAC;AAAA,IACH;AAAA;AAAA;AAAA,IAGA,SAAS,WACL,KAAK,SAAS,KAAK,QAAQ,MAAM,OAAO,CAAC,IACzC,KAAK,QAAQ,MAAM,OAAO;AAAA,IAC9B,OAAO,MAAM;AAAA,EACf;AAEA,MAAI,MAAM,aAAa;AACrB,WAAO,WAAW,KAAK,SAAS,KAAK,MAAM,YAAY,CAAC;AAAA,EAC1D;AAEA,SAAO,KAAK,OAAO,QAAQ;AAAA,IACzB,sBAAsB;AAAA,IACtB,aAAa,MAAM,eAAe,OAAO;AAAA,EAC3C,CAAC;AACH;AAMO,SAAS,8BACd,UAAiC,CAAC,GACzB;AACT,QAAM,EAAE,mBAAmB,CAAC,EAAE,IAAI;AAElC,SAAO,KAAK,UAAU,CAAC,SAAS;AAE9B,UAAM,gBAA2B,CAAC;AAElC,eAAW,UAAU,kBAAkB;AACrC,UAAI,OAAO,SAAS,SAAS,GAAG;AAC9B,cAAM,SAAS;AAAA,UACb,OAAO,SAAS,IAAI,CAAC,UAAU,MAAM,OAAO;AAAA,QAC9C;AACA,cAAM,WAAW,OAAO,SAAS;AAAA,UAAI,CAAC,UACpC;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAM,YAAY;AAAA,UACpB;AAAA,QACF;AACA,sBAAc;AAAA,UACZ,SAAS,WAAW,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,QAAQ;AAAA,QAC3D;AAAA,MACF;AAAA,IACF;AAGA,UAAM,kBAAkB;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AAEA,UAAM,mBAAmB,CAAC,GAAG,iBAAiB,GAAG,aAAa;AAE9D,QAAI,iBAAiB,WAAW,GAAG;AACjC,aAAO,KAAK,OAAO,CAAC,CAAC;AAAA,IACvB;AAEA,WAAO,KAAK,MAAM,gBAAgB;AAAA,EACpC,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PptxComponentDefinitionSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HYJ6MU3F.js";
|
|
4
4
|
|
|
5
5
|
// src/schemas/document.ts
|
|
6
6
|
var PptxJsonComponentDefinitionSchema = PptxComponentDefinitionSchema;
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
PptxJsonComponentDefinitionSchema,
|
|
19
19
|
PPTX_JSON_SCHEMA_URLS
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-BIJP7NTG.js.map
|
|
@@ -1,46 +1,150 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ColorValueSchema,
|
|
3
3
|
GridConfigSchema,
|
|
4
|
-
|
|
4
|
+
ThemeConfigSchema
|
|
5
|
+
} from "./chunk-ZMZKHRBS.js";
|
|
6
|
+
import {
|
|
5
7
|
PptxChartPropsSchema,
|
|
6
8
|
PptxComponentDefaultsSchema,
|
|
7
9
|
PptxHighchartsPropsSchema,
|
|
8
10
|
PptxImagePropsSchema,
|
|
9
11
|
PptxTablePropsSchema,
|
|
10
12
|
ShapePropsSchema,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ThemeConfigSchema,
|
|
14
|
-
TransitionSchema
|
|
15
|
-
} from "./chunk-STLETJGO.js";
|
|
13
|
+
TextPropsSchema
|
|
14
|
+
} from "./chunk-NCBBMAVS.js";
|
|
16
15
|
|
|
17
16
|
// src/schemas/component-registry.ts
|
|
18
|
-
import { Type as
|
|
17
|
+
import { Type as Type5 } from "@sinclair/typebox";
|
|
18
|
+
import { PPTX_SLIDE_CONTENT_COMPONENTS } from "@json-to-office/shared/schemas/slide-content";
|
|
19
19
|
|
|
20
20
|
// src/schemas/components/presentation.ts
|
|
21
|
-
import { Type as
|
|
21
|
+
import { Type as Type3 } from "@sinclair/typebox";
|
|
22
22
|
|
|
23
23
|
// src/schemas/components/template.ts
|
|
24
|
+
import { Type as Type2 } from "@sinclair/typebox";
|
|
25
|
+
|
|
26
|
+
// src/schemas/components/common.ts
|
|
24
27
|
import { Type } from "@sinclair/typebox";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
import { ColorValueSchema as ColorValueSchema2 } from "@json-to-office/shared/schemas/slide-content";
|
|
29
|
+
import {
|
|
30
|
+
PptxAlignmentSchema,
|
|
31
|
+
VerticalAlignmentSchema,
|
|
32
|
+
ShadowSchema,
|
|
33
|
+
GridPositionSchema
|
|
34
|
+
} from "@json-to-office/shared/schemas/slide-content";
|
|
35
|
+
var PositionSchema = Type.Object(
|
|
36
|
+
{
|
|
37
|
+
x: Type.Optional(
|
|
38
|
+
Type.Union([
|
|
39
|
+
Type.Number({ description: "X position in inches" }),
|
|
40
|
+
Type.String({
|
|
41
|
+
pattern: "^\\d+(\\.\\d+)?%$",
|
|
42
|
+
description: 'X position as percentage (e.g., "10%")'
|
|
43
|
+
})
|
|
44
|
+
])
|
|
45
|
+
),
|
|
46
|
+
y: Type.Optional(
|
|
47
|
+
Type.Union([
|
|
48
|
+
Type.Number({ description: "Y position in inches" }),
|
|
49
|
+
Type.String({
|
|
50
|
+
pattern: "^\\d+(\\.\\d+)?%$",
|
|
51
|
+
description: 'Y position as percentage (e.g., "10%")'
|
|
52
|
+
})
|
|
53
|
+
])
|
|
54
|
+
),
|
|
55
|
+
w: Type.Optional(
|
|
56
|
+
Type.Union([
|
|
57
|
+
Type.Number({ description: "Width in inches" }),
|
|
58
|
+
Type.String({
|
|
59
|
+
pattern: "^\\d+(\\.\\d+)?%$",
|
|
60
|
+
description: 'Width as percentage (e.g., "80%")'
|
|
61
|
+
})
|
|
62
|
+
])
|
|
63
|
+
),
|
|
64
|
+
h: Type.Optional(
|
|
65
|
+
Type.Union([
|
|
66
|
+
Type.Number({ description: "Height in inches" }),
|
|
67
|
+
Type.String({
|
|
68
|
+
pattern: "^\\d+(\\.\\d+)?%$",
|
|
69
|
+
description: 'Height as percentage (e.g., "20%")'
|
|
70
|
+
})
|
|
71
|
+
])
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
description: "Position and size in inches or percentages",
|
|
76
|
+
additionalProperties: false
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
var SlideBackgroundSchema = Type.Object(
|
|
80
|
+
{
|
|
81
|
+
color: Type.Optional(ColorValueSchema2),
|
|
82
|
+
image: Type.Optional(
|
|
83
|
+
Type.Object(
|
|
84
|
+
{
|
|
85
|
+
path: Type.Optional(
|
|
86
|
+
Type.String({ description: "Image file path or URL" })
|
|
87
|
+
),
|
|
88
|
+
base64: Type.Optional(
|
|
89
|
+
Type.String({ description: "Base64-encoded image data" })
|
|
90
|
+
)
|
|
91
|
+
},
|
|
92
|
+
{ description: "Background image", additionalProperties: false }
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
description: "Slide background configuration",
|
|
98
|
+
additionalProperties: false
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
var TransitionSchema = Type.Object(
|
|
102
|
+
{
|
|
103
|
+
type: Type.Optional(
|
|
104
|
+
Type.Union(
|
|
105
|
+
[
|
|
106
|
+
Type.Literal("fade"),
|
|
107
|
+
Type.Literal("push"),
|
|
108
|
+
Type.Literal("wipe"),
|
|
109
|
+
Type.Literal("zoom"),
|
|
110
|
+
Type.Literal("none")
|
|
111
|
+
],
|
|
112
|
+
{ description: "Transition effect type" }
|
|
113
|
+
)
|
|
114
|
+
),
|
|
115
|
+
speed: Type.Optional(
|
|
116
|
+
Type.Union(
|
|
117
|
+
[Type.Literal("slow"), Type.Literal("medium"), Type.Literal("fast")],
|
|
118
|
+
{ description: "Transition speed" }
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
description: "Slide transition configuration",
|
|
124
|
+
additionalProperties: false
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// src/schemas/components/template.ts
|
|
129
|
+
var Coord = Type2.Union([
|
|
130
|
+
Type2.Number({ description: "Position/size in inches" }),
|
|
131
|
+
Type2.String({
|
|
28
132
|
pattern: "^\\d+(\\.\\d+)?%$",
|
|
29
133
|
description: 'Position/size as percentage of slide dimension (e.g., "50%")'
|
|
30
134
|
})
|
|
31
135
|
]);
|
|
32
136
|
function contentComponent(name, propsSchema) {
|
|
33
|
-
return
|
|
34
|
-
name:
|
|
35
|
-
id:
|
|
36
|
-
enabled:
|
|
137
|
+
return Type2.Object({
|
|
138
|
+
name: Type2.Literal(name),
|
|
139
|
+
id: Type2.Optional(Type2.String()),
|
|
140
|
+
enabled: Type2.Optional(Type2.Boolean({
|
|
37
141
|
default: true,
|
|
38
142
|
description: "When false, this component is filtered out and not rendered. Defaults to true."
|
|
39
143
|
})),
|
|
40
144
|
props: propsSchema
|
|
41
145
|
}, { additionalProperties: false });
|
|
42
146
|
}
|
|
43
|
-
var TemplateObjectComponentSchema =
|
|
147
|
+
var TemplateObjectComponentSchema = Type2.Union([
|
|
44
148
|
contentComponent("text", TextPropsSchema),
|
|
45
149
|
contentComponent("image", PptxImagePropsSchema),
|
|
46
150
|
contentComponent("shape", ShapePropsSchema),
|
|
@@ -52,12 +156,12 @@ var TemplateObjectComponentSchema = Type.Union([
|
|
|
52
156
|
description: "Fixed component on a template slide (same format as slide children)"
|
|
53
157
|
});
|
|
54
158
|
function defaultsComponent(name, propsSchema) {
|
|
55
|
-
return
|
|
56
|
-
name:
|
|
57
|
-
props:
|
|
159
|
+
return Type2.Object({
|
|
160
|
+
name: Type2.Literal(name),
|
|
161
|
+
props: Type2.Partial(propsSchema, { description: "Default props inherited by the component placed in this placeholder" })
|
|
58
162
|
}, { additionalProperties: false });
|
|
59
163
|
}
|
|
60
|
-
var PlaceholderDefaultsSchema =
|
|
164
|
+
var PlaceholderDefaultsSchema = Type2.Union([
|
|
61
165
|
defaultsComponent("text", TextPropsSchema),
|
|
62
166
|
defaultsComponent("image", PptxImagePropsSchema),
|
|
63
167
|
defaultsComponent("shape", ShapePropsSchema),
|
|
@@ -68,54 +172,54 @@ var PlaceholderDefaultsSchema = Type.Union([
|
|
|
68
172
|
discriminator: { propertyName: "name" },
|
|
69
173
|
description: "Partial component stub \u2014 styling defaults only"
|
|
70
174
|
});
|
|
71
|
-
var PlaceholderDefinitionSchema =
|
|
72
|
-
name:
|
|
73
|
-
x:
|
|
74
|
-
y:
|
|
75
|
-
w:
|
|
76
|
-
h:
|
|
77
|
-
grid:
|
|
78
|
-
defaults:
|
|
175
|
+
var PlaceholderDefinitionSchema = Type2.Object({
|
|
176
|
+
name: Type2.String({ description: "Unique placeholder name" }),
|
|
177
|
+
x: Type2.Optional(Coord),
|
|
178
|
+
y: Type2.Optional(Coord),
|
|
179
|
+
w: Type2.Optional(Coord),
|
|
180
|
+
h: Type2.Optional(Coord),
|
|
181
|
+
grid: Type2.Optional(GridPositionSchema),
|
|
182
|
+
defaults: Type2.Optional(PlaceholderDefaultsSchema)
|
|
79
183
|
}, { additionalProperties: false, description: "Placeholder on a template slide \u2014 defaults is a component stub whose props are inherited by the actual component" });
|
|
80
|
-
var TemplateSlideDefinitionSchema =
|
|
81
|
-
name:
|
|
82
|
-
background:
|
|
83
|
-
margin:
|
|
84
|
-
|
|
85
|
-
|
|
184
|
+
var TemplateSlideDefinitionSchema = Type2.Object({
|
|
185
|
+
name: Type2.String({ description: "Unique template slide name" }),
|
|
186
|
+
background: Type2.Optional(SlideBackgroundSchema),
|
|
187
|
+
margin: Type2.Optional(Type2.Union([
|
|
188
|
+
Type2.Number({ description: "Margin in inches (all sides)" }),
|
|
189
|
+
Type2.Array(Type2.Number(), { minItems: 4, maxItems: 4, description: "Margin [top, right, bottom, left] in inches" })
|
|
86
190
|
])),
|
|
87
|
-
slideNumber:
|
|
191
|
+
slideNumber: Type2.Optional(Type2.Object({
|
|
88
192
|
x: Coord,
|
|
89
193
|
y: Coord,
|
|
90
|
-
w:
|
|
91
|
-
h:
|
|
92
|
-
color:
|
|
93
|
-
fontSize:
|
|
194
|
+
w: Type2.Optional(Coord),
|
|
195
|
+
h: Type2.Optional(Coord),
|
|
196
|
+
color: Type2.Optional(ColorValueSchema),
|
|
197
|
+
fontSize: Type2.Optional(Type2.Number({ description: "Slide number font size in points" }))
|
|
94
198
|
}, { additionalProperties: false, description: "Slide number position and styling" })),
|
|
95
|
-
objects:
|
|
96
|
-
placeholders:
|
|
97
|
-
grid:
|
|
199
|
+
objects: Type2.Optional(Type2.Array(TemplateObjectComponentSchema, { description: "Fixed components (logos, footers, decorations) \u2014 same { name, props } format as slide children" })),
|
|
200
|
+
placeholders: Type2.Optional(Type2.Array(PlaceholderDefinitionSchema, { description: "Placeholder regions for slide content" })),
|
|
201
|
+
grid: Type2.Optional(GridConfigSchema)
|
|
98
202
|
}, { additionalProperties: false, description: "Template slide definition (reusable slide template)" });
|
|
99
203
|
|
|
100
204
|
// src/schemas/components/presentation.ts
|
|
101
|
-
var PresentationPropsSchema =
|
|
205
|
+
var PresentationPropsSchema = Type3.Object(
|
|
102
206
|
{
|
|
103
|
-
title:
|
|
104
|
-
|
|
207
|
+
title: Type3.Optional(
|
|
208
|
+
Type3.String({ description: "Presentation title metadata" })
|
|
105
209
|
),
|
|
106
|
-
author:
|
|
107
|
-
|
|
210
|
+
author: Type3.Optional(
|
|
211
|
+
Type3.String({ description: "Presentation author metadata" })
|
|
108
212
|
),
|
|
109
|
-
subject:
|
|
110
|
-
|
|
213
|
+
subject: Type3.Optional(
|
|
214
|
+
Type3.String({ description: "Presentation subject metadata" })
|
|
111
215
|
),
|
|
112
|
-
company:
|
|
113
|
-
|
|
216
|
+
company: Type3.Optional(
|
|
217
|
+
Type3.String({ description: "Company name metadata" })
|
|
114
218
|
),
|
|
115
|
-
theme:
|
|
116
|
-
|
|
219
|
+
theme: Type3.Optional(
|
|
220
|
+
Type3.Union(
|
|
117
221
|
[
|
|
118
|
-
|
|
222
|
+
Type3.String({
|
|
119
223
|
description: 'Theme name to apply (default: "default")',
|
|
120
224
|
default: "default"
|
|
121
225
|
}),
|
|
@@ -126,38 +230,38 @@ var PresentationPropsSchema = Type2.Object(
|
|
|
126
230
|
}
|
|
127
231
|
)
|
|
128
232
|
),
|
|
129
|
-
slideWidth:
|
|
130
|
-
|
|
233
|
+
slideWidth: Type3.Optional(
|
|
234
|
+
Type3.Number({
|
|
131
235
|
description: "Slide width in inches (default: 10)",
|
|
132
236
|
default: 10
|
|
133
237
|
})
|
|
134
238
|
),
|
|
135
|
-
slideHeight:
|
|
136
|
-
|
|
239
|
+
slideHeight: Type3.Optional(
|
|
240
|
+
Type3.Number({
|
|
137
241
|
description: "Slide height in inches (default: 7.5)",
|
|
138
242
|
default: 7.5
|
|
139
243
|
})
|
|
140
244
|
),
|
|
141
|
-
rtlMode:
|
|
142
|
-
|
|
245
|
+
rtlMode: Type3.Optional(
|
|
246
|
+
Type3.Boolean({ description: "Right-to-left text direction" })
|
|
143
247
|
),
|
|
144
|
-
language:
|
|
145
|
-
|
|
248
|
+
language: Type3.Optional(
|
|
249
|
+
Type3.String({
|
|
146
250
|
pattern: "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
|
|
147
251
|
description: 'Default presentation language (BCP-47 tag, e.g. "en-US"). Sets the spell-check language for all text; individual text components can override it.',
|
|
148
252
|
examples: ["en-US", "fr-FR", "de-DE", "it-IT", "es-ES"]
|
|
149
253
|
})
|
|
150
254
|
),
|
|
151
|
-
pageNumberFormat:
|
|
152
|
-
|
|
255
|
+
pageNumberFormat: Type3.Optional(
|
|
256
|
+
Type3.Union([Type3.Literal("9"), Type3.Literal("09")], {
|
|
153
257
|
description: 'Format for {PAGE_NUMBER} placeholders: "9" = bare number (default), "09" = zero-padded',
|
|
154
258
|
default: "9"
|
|
155
259
|
})
|
|
156
260
|
),
|
|
157
|
-
componentDefaults:
|
|
158
|
-
grid:
|
|
159
|
-
templates:
|
|
160
|
-
|
|
261
|
+
componentDefaults: Type3.Optional(PptxComponentDefaultsSchema),
|
|
262
|
+
grid: Type3.Optional(GridConfigSchema),
|
|
263
|
+
templates: Type3.Optional(
|
|
264
|
+
Type3.Array(TemplateSlideDefinitionSchema, {
|
|
161
265
|
description: "Template slide definitions (reusable slide templates)"
|
|
162
266
|
})
|
|
163
267
|
)
|
|
@@ -169,24 +273,24 @@ var PresentationPropsSchema = Type2.Object(
|
|
|
169
273
|
);
|
|
170
274
|
|
|
171
275
|
// src/schemas/components/slide.ts
|
|
172
|
-
import { Type as
|
|
173
|
-
var SlidePropsSchema =
|
|
276
|
+
import { Type as Type4 } from "@sinclair/typebox";
|
|
277
|
+
var SlidePropsSchema = Type4.Object(
|
|
174
278
|
{
|
|
175
|
-
background:
|
|
176
|
-
transition:
|
|
177
|
-
notes:
|
|
178
|
-
|
|
279
|
+
background: Type4.Optional(SlideBackgroundSchema),
|
|
280
|
+
transition: Type4.Optional(TransitionSchema),
|
|
281
|
+
notes: Type4.Optional(
|
|
282
|
+
Type4.String({ description: "Speaker notes for this slide" })
|
|
179
283
|
),
|
|
180
|
-
layout:
|
|
181
|
-
|
|
284
|
+
layout: Type4.Optional(
|
|
285
|
+
Type4.String({
|
|
182
286
|
description: 'Slide layout name (e.g., "Title Slide", "Blank")'
|
|
183
287
|
})
|
|
184
288
|
),
|
|
185
|
-
hidden:
|
|
186
|
-
|
|
289
|
+
hidden: Type4.Optional(
|
|
290
|
+
Type4.Boolean({ description: "Hide this slide from presentation" })
|
|
187
291
|
),
|
|
188
|
-
template:
|
|
189
|
-
|
|
292
|
+
template: Type4.Optional(
|
|
293
|
+
Type4.String({ description: "Template slide name to apply" })
|
|
190
294
|
)
|
|
191
295
|
// Note: `placeholders` is added dynamically by the component registry
|
|
192
296
|
// with the recursive component ref, to avoid circular imports.
|
|
@@ -217,63 +321,14 @@ var PPTX_STANDARD_COMPONENTS_REGISTRY = [
|
|
|
217
321
|
name: "slide",
|
|
218
322
|
propsSchema: SlidePropsSchema,
|
|
219
323
|
hasChildren: true,
|
|
220
|
-
allowedChildren:
|
|
221
|
-
"text",
|
|
222
|
-
"image",
|
|
223
|
-
"shape",
|
|
224
|
-
"table",
|
|
225
|
-
"highcharts",
|
|
226
|
-
"chart"
|
|
227
|
-
],
|
|
324
|
+
allowedChildren: PPTX_SLIDE_CONTENT_COMPONENTS.map(({ name }) => name),
|
|
228
325
|
hasPlaceholders: true,
|
|
229
326
|
category: "container",
|
|
230
327
|
description: "Slide container - groups content elements on a single slide."
|
|
231
328
|
},
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
name: "text",
|
|
237
|
-
propsSchema: TextPropsSchema,
|
|
238
|
-
hasChildren: false,
|
|
239
|
-
category: "content",
|
|
240
|
-
description: "Text element - displays text with formatting, positioning and styling options."
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
name: "image",
|
|
244
|
-
propsSchema: PptxImagePropsSchema,
|
|
245
|
-
hasChildren: false,
|
|
246
|
-
category: "content",
|
|
247
|
-
description: "Image element - displays images from file path, URL, or base64 data."
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
name: "shape",
|
|
251
|
-
propsSchema: ShapePropsSchema,
|
|
252
|
-
hasChildren: false,
|
|
253
|
-
category: "content",
|
|
254
|
-
description: "Shape element - draws geometric shapes with optional text, fill, and line styling."
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "table",
|
|
258
|
-
propsSchema: PptxTablePropsSchema,
|
|
259
|
-
hasChildren: false,
|
|
260
|
-
category: "content",
|
|
261
|
-
description: "Table element - displays tabular data with rows and columns."
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
name: "highcharts",
|
|
265
|
-
propsSchema: PptxHighchartsPropsSchema,
|
|
266
|
-
hasChildren: false,
|
|
267
|
-
category: "content",
|
|
268
|
-
description: "Highcharts element - renders charts via Highcharts Export Server."
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
name: "chart",
|
|
272
|
-
propsSchema: PptxChartPropsSchema,
|
|
273
|
-
hasChildren: false,
|
|
274
|
-
category: "content",
|
|
275
|
-
description: "Native PowerPoint chart - editable, scalable, no external server needed."
|
|
276
|
-
}
|
|
329
|
+
// Content components are canonical in @json-to-office/shared so DOCX
|
|
330
|
+
// visuals can reuse the exact schemas without depending on shared-pptx.
|
|
331
|
+
...PPTX_SLIDE_CONTENT_COMPONENTS
|
|
277
332
|
];
|
|
278
333
|
function getPptxStandardComponent(name) {
|
|
279
334
|
return PPTX_STANDARD_COMPONENTS_REGISTRY.find((c) => c.name === name);
|
|
@@ -297,30 +352,30 @@ function isPptxStandardComponent(name) {
|
|
|
297
352
|
}
|
|
298
353
|
function createPptxComponentSchemaObject(component, recursiveRef, placeholderRef) {
|
|
299
354
|
const schema = {
|
|
300
|
-
name:
|
|
301
|
-
id:
|
|
302
|
-
enabled:
|
|
303
|
-
|
|
355
|
+
name: Type5.Literal(component.name),
|
|
356
|
+
id: Type5.Optional(Type5.String()),
|
|
357
|
+
enabled: Type5.Optional(
|
|
358
|
+
Type5.Boolean({
|
|
304
359
|
default: true,
|
|
305
360
|
description: "When false, this component is filtered out and not rendered. Defaults to true."
|
|
306
361
|
})
|
|
307
362
|
)
|
|
308
363
|
};
|
|
309
364
|
if (component.special?.hasSchemaField) {
|
|
310
|
-
schema.$schema =
|
|
365
|
+
schema.$schema = Type5.Optional(Type5.String({ format: "uri" }));
|
|
311
366
|
}
|
|
312
367
|
schema.props = component.propsSchema;
|
|
313
368
|
if (component.hasChildren && recursiveRef) {
|
|
314
|
-
schema.children =
|
|
369
|
+
schema.children = Type5.Optional(Type5.Array(recursiveRef));
|
|
315
370
|
}
|
|
316
371
|
if (component.hasPlaceholders && (placeholderRef ?? recursiveRef)) {
|
|
317
372
|
const baseProperties = component.propsSchema.properties ?? {};
|
|
318
373
|
const phRef = placeholderRef ?? recursiveRef;
|
|
319
|
-
schema.props =
|
|
374
|
+
schema.props = Type5.Object(
|
|
320
375
|
{
|
|
321
376
|
...baseProperties,
|
|
322
|
-
placeholders:
|
|
323
|
-
|
|
377
|
+
placeholders: Type5.Optional(
|
|
378
|
+
Type5.Record(Type5.String(), phRef, {
|
|
324
379
|
description: 'Content for named placeholders: { "title": { "name": "text", ... } }'
|
|
325
380
|
})
|
|
326
381
|
)
|
|
@@ -331,7 +386,7 @@ function createPptxComponentSchemaObject(component, recursiveRef, placeholderRef
|
|
|
331
386
|
}
|
|
332
387
|
);
|
|
333
388
|
}
|
|
334
|
-
return
|
|
389
|
+
return Type5.Object(schema, { additionalProperties: false });
|
|
335
390
|
}
|
|
336
391
|
function createAllPptxComponentSchemas(recursiveRef) {
|
|
337
392
|
return PPTX_STANDARD_COMPONENTS_REGISTRY.map(
|
|
@@ -371,7 +426,7 @@ function createAllPptxComponentSchemasNarrowed(selfRef, pluginSchemas = []) {
|
|
|
371
426
|
if (!containerDeps.every((d) => resolved.has(d))) continue;
|
|
372
427
|
const childSchemas = comp.allowedChildren.map((name) => resolved.get(name) ?? leafSchemas.get(name)).filter((s) => s !== void 0);
|
|
373
428
|
const allChildSchemas = [...childSchemas, ...pluginSchemas];
|
|
374
|
-
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] :
|
|
429
|
+
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] : Type5.Union(allChildSchemas);
|
|
375
430
|
resolved.set(
|
|
376
431
|
comp.name,
|
|
377
432
|
createPptxComponentSchemaObject(comp, childrenType, selfRef)
|
|
@@ -388,6 +443,13 @@ function createAllPptxComponentSchemasNarrowed(selfRef, pluginSchemas = []) {
|
|
|
388
443
|
}
|
|
389
444
|
|
|
390
445
|
export {
|
|
446
|
+
PositionSchema,
|
|
447
|
+
SlideBackgroundSchema,
|
|
448
|
+
TransitionSchema,
|
|
449
|
+
PptxAlignmentSchema,
|
|
450
|
+
VerticalAlignmentSchema,
|
|
451
|
+
ShadowSchema,
|
|
452
|
+
GridPositionSchema,
|
|
391
453
|
PresentationPropsSchema,
|
|
392
454
|
SlidePropsSchema,
|
|
393
455
|
PPTX_STANDARD_COMPONENTS_REGISTRY,
|
|
@@ -401,4 +463,4 @@ export {
|
|
|
401
463
|
createAllPptxComponentSchemas,
|
|
402
464
|
createAllPptxComponentSchemasNarrowed
|
|
403
465
|
};
|
|
404
|
-
//# sourceMappingURL=chunk-
|
|
466
|
+
//# sourceMappingURL=chunk-G3FMM4FX.js.map
|