@json-to-office/shared-pptx 0.19.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-2R6VYDG2.js → chunk-BIJP7NTG.js} +2 -2
- package/dist/{chunk-UVET7RT3.js → chunk-G3FMM4FX.js} +217 -146
- package/dist/chunk-G3FMM4FX.js.map +1 -0
- package/dist/{chunk-BJP72XV3.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 +108 -68
- package/dist/index.js +327 -21
- 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 +319 -266
- 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-BJP72XV3.js.map +0 -1
- package/dist/chunk-GUSMSJT6.js +0 -42
- package/dist/chunk-GUSMSJT6.js.map +0 -1
- package/dist/chunk-STLETJGO.js +0 -1102
- package/dist/chunk-STLETJGO.js.map +0 -1
- package/dist/chunk-UVET7RT3.js.map +0 -1
- /package/dist/{chunk-2R6VYDG2.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,45 +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
|
-
TransitionSchema
|
|
14
|
-
} from "./chunk-STLETJGO.js";
|
|
13
|
+
TextPropsSchema
|
|
14
|
+
} from "./chunk-NCBBMAVS.js";
|
|
15
15
|
|
|
16
16
|
// src/schemas/component-registry.ts
|
|
17
|
-
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";
|
|
18
19
|
|
|
19
20
|
// src/schemas/components/presentation.ts
|
|
20
|
-
import { Type as
|
|
21
|
+
import { Type as Type3 } from "@sinclair/typebox";
|
|
21
22
|
|
|
22
23
|
// src/schemas/components/template.ts
|
|
24
|
+
import { Type as Type2 } from "@sinclair/typebox";
|
|
25
|
+
|
|
26
|
+
// src/schemas/components/common.ts
|
|
23
27
|
import { Type } from "@sinclair/typebox";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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({
|
|
27
132
|
pattern: "^\\d+(\\.\\d+)?%$",
|
|
28
133
|
description: 'Position/size as percentage of slide dimension (e.g., "50%")'
|
|
29
134
|
})
|
|
30
135
|
]);
|
|
31
136
|
function contentComponent(name, propsSchema) {
|
|
32
|
-
return
|
|
33
|
-
name:
|
|
34
|
-
id:
|
|
35
|
-
enabled:
|
|
137
|
+
return Type2.Object({
|
|
138
|
+
name: Type2.Literal(name),
|
|
139
|
+
id: Type2.Optional(Type2.String()),
|
|
140
|
+
enabled: Type2.Optional(Type2.Boolean({
|
|
36
141
|
default: true,
|
|
37
142
|
description: "When false, this component is filtered out and not rendered. Defaults to true."
|
|
38
143
|
})),
|
|
39
144
|
props: propsSchema
|
|
40
145
|
}, { additionalProperties: false });
|
|
41
146
|
}
|
|
42
|
-
var TemplateObjectComponentSchema =
|
|
147
|
+
var TemplateObjectComponentSchema = Type2.Union([
|
|
43
148
|
contentComponent("text", TextPropsSchema),
|
|
44
149
|
contentComponent("image", PptxImagePropsSchema),
|
|
45
150
|
contentComponent("shape", ShapePropsSchema),
|
|
@@ -51,12 +156,12 @@ var TemplateObjectComponentSchema = Type.Union([
|
|
|
51
156
|
description: "Fixed component on a template slide (same format as slide children)"
|
|
52
157
|
});
|
|
53
158
|
function defaultsComponent(name, propsSchema) {
|
|
54
|
-
return
|
|
55
|
-
name:
|
|
56
|
-
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" })
|
|
57
162
|
}, { additionalProperties: false });
|
|
58
163
|
}
|
|
59
|
-
var PlaceholderDefaultsSchema =
|
|
164
|
+
var PlaceholderDefaultsSchema = Type2.Union([
|
|
60
165
|
defaultsComponent("text", TextPropsSchema),
|
|
61
166
|
defaultsComponent("image", PptxImagePropsSchema),
|
|
62
167
|
defaultsComponent("shape", ShapePropsSchema),
|
|
@@ -67,88 +172,96 @@ var PlaceholderDefaultsSchema = Type.Union([
|
|
|
67
172
|
discriminator: { propertyName: "name" },
|
|
68
173
|
description: "Partial component stub \u2014 styling defaults only"
|
|
69
174
|
});
|
|
70
|
-
var PlaceholderDefinitionSchema =
|
|
71
|
-
name:
|
|
72
|
-
x:
|
|
73
|
-
y:
|
|
74
|
-
w:
|
|
75
|
-
h:
|
|
76
|
-
grid:
|
|
77
|
-
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)
|
|
78
183
|
}, { additionalProperties: false, description: "Placeholder on a template slide \u2014 defaults is a component stub whose props are inherited by the actual component" });
|
|
79
|
-
var TemplateSlideDefinitionSchema =
|
|
80
|
-
name:
|
|
81
|
-
background:
|
|
82
|
-
margin:
|
|
83
|
-
|
|
84
|
-
|
|
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" })
|
|
85
190
|
])),
|
|
86
|
-
slideNumber:
|
|
191
|
+
slideNumber: Type2.Optional(Type2.Object({
|
|
87
192
|
x: Coord,
|
|
88
193
|
y: Coord,
|
|
89
|
-
w:
|
|
90
|
-
h:
|
|
91
|
-
color:
|
|
92
|
-
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" }))
|
|
93
198
|
}, { additionalProperties: false, description: "Slide number position and styling" })),
|
|
94
|
-
objects:
|
|
95
|
-
placeholders:
|
|
96
|
-
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)
|
|
97
202
|
}, { additionalProperties: false, description: "Template slide definition (reusable slide template)" });
|
|
98
203
|
|
|
99
204
|
// src/schemas/components/presentation.ts
|
|
100
|
-
var PresentationPropsSchema =
|
|
205
|
+
var PresentationPropsSchema = Type3.Object(
|
|
101
206
|
{
|
|
102
|
-
title:
|
|
103
|
-
|
|
207
|
+
title: Type3.Optional(
|
|
208
|
+
Type3.String({ description: "Presentation title metadata" })
|
|
104
209
|
),
|
|
105
|
-
author:
|
|
106
|
-
|
|
210
|
+
author: Type3.Optional(
|
|
211
|
+
Type3.String({ description: "Presentation author metadata" })
|
|
107
212
|
),
|
|
108
|
-
subject:
|
|
109
|
-
|
|
213
|
+
subject: Type3.Optional(
|
|
214
|
+
Type3.String({ description: "Presentation subject metadata" })
|
|
110
215
|
),
|
|
111
|
-
company:
|
|
112
|
-
|
|
216
|
+
company: Type3.Optional(
|
|
217
|
+
Type3.String({ description: "Company name metadata" })
|
|
113
218
|
),
|
|
114
|
-
theme:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
219
|
+
theme: Type3.Optional(
|
|
220
|
+
Type3.Union(
|
|
221
|
+
[
|
|
222
|
+
Type3.String({
|
|
223
|
+
description: 'Theme name to apply (default: "default")',
|
|
224
|
+
default: "default"
|
|
225
|
+
}),
|
|
226
|
+
ThemeConfigSchema
|
|
227
|
+
],
|
|
228
|
+
{
|
|
229
|
+
description: 'Theme to apply: a built-in/custom theme name (default: "default"), or an inline theme config object so the document stays self-contained'
|
|
230
|
+
}
|
|
231
|
+
)
|
|
119
232
|
),
|
|
120
|
-
slideWidth:
|
|
121
|
-
|
|
233
|
+
slideWidth: Type3.Optional(
|
|
234
|
+
Type3.Number({
|
|
122
235
|
description: "Slide width in inches (default: 10)",
|
|
123
236
|
default: 10
|
|
124
237
|
})
|
|
125
238
|
),
|
|
126
|
-
slideHeight:
|
|
127
|
-
|
|
239
|
+
slideHeight: Type3.Optional(
|
|
240
|
+
Type3.Number({
|
|
128
241
|
description: "Slide height in inches (default: 7.5)",
|
|
129
242
|
default: 7.5
|
|
130
243
|
})
|
|
131
244
|
),
|
|
132
|
-
rtlMode:
|
|
133
|
-
|
|
245
|
+
rtlMode: Type3.Optional(
|
|
246
|
+
Type3.Boolean({ description: "Right-to-left text direction" })
|
|
134
247
|
),
|
|
135
|
-
language:
|
|
136
|
-
|
|
248
|
+
language: Type3.Optional(
|
|
249
|
+
Type3.String({
|
|
137
250
|
pattern: "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
|
|
138
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.',
|
|
139
252
|
examples: ["en-US", "fr-FR", "de-DE", "it-IT", "es-ES"]
|
|
140
253
|
})
|
|
141
254
|
),
|
|
142
|
-
pageNumberFormat:
|
|
143
|
-
|
|
255
|
+
pageNumberFormat: Type3.Optional(
|
|
256
|
+
Type3.Union([Type3.Literal("9"), Type3.Literal("09")], {
|
|
144
257
|
description: 'Format for {PAGE_NUMBER} placeholders: "9" = bare number (default), "09" = zero-padded',
|
|
145
258
|
default: "9"
|
|
146
259
|
})
|
|
147
260
|
),
|
|
148
|
-
componentDefaults:
|
|
149
|
-
grid:
|
|
150
|
-
templates:
|
|
151
|
-
|
|
261
|
+
componentDefaults: Type3.Optional(PptxComponentDefaultsSchema),
|
|
262
|
+
grid: Type3.Optional(GridConfigSchema),
|
|
263
|
+
templates: Type3.Optional(
|
|
264
|
+
Type3.Array(TemplateSlideDefinitionSchema, {
|
|
152
265
|
description: "Template slide definitions (reusable slide templates)"
|
|
153
266
|
})
|
|
154
267
|
)
|
|
@@ -160,24 +273,24 @@ var PresentationPropsSchema = Type2.Object(
|
|
|
160
273
|
);
|
|
161
274
|
|
|
162
275
|
// src/schemas/components/slide.ts
|
|
163
|
-
import { Type as
|
|
164
|
-
var SlidePropsSchema =
|
|
276
|
+
import { Type as Type4 } from "@sinclair/typebox";
|
|
277
|
+
var SlidePropsSchema = Type4.Object(
|
|
165
278
|
{
|
|
166
|
-
background:
|
|
167
|
-
transition:
|
|
168
|
-
notes:
|
|
169
|
-
|
|
279
|
+
background: Type4.Optional(SlideBackgroundSchema),
|
|
280
|
+
transition: Type4.Optional(TransitionSchema),
|
|
281
|
+
notes: Type4.Optional(
|
|
282
|
+
Type4.String({ description: "Speaker notes for this slide" })
|
|
170
283
|
),
|
|
171
|
-
layout:
|
|
172
|
-
|
|
284
|
+
layout: Type4.Optional(
|
|
285
|
+
Type4.String({
|
|
173
286
|
description: 'Slide layout name (e.g., "Title Slide", "Blank")'
|
|
174
287
|
})
|
|
175
288
|
),
|
|
176
|
-
hidden:
|
|
177
|
-
|
|
289
|
+
hidden: Type4.Optional(
|
|
290
|
+
Type4.Boolean({ description: "Hide this slide from presentation" })
|
|
178
291
|
),
|
|
179
|
-
template:
|
|
180
|
-
|
|
292
|
+
template: Type4.Optional(
|
|
293
|
+
Type4.String({ description: "Template slide name to apply" })
|
|
181
294
|
)
|
|
182
295
|
// Note: `placeholders` is added dynamically by the component registry
|
|
183
296
|
// with the recursive component ref, to avoid circular imports.
|
|
@@ -208,63 +321,14 @@ var PPTX_STANDARD_COMPONENTS_REGISTRY = [
|
|
|
208
321
|
name: "slide",
|
|
209
322
|
propsSchema: SlidePropsSchema,
|
|
210
323
|
hasChildren: true,
|
|
211
|
-
allowedChildren:
|
|
212
|
-
"text",
|
|
213
|
-
"image",
|
|
214
|
-
"shape",
|
|
215
|
-
"table",
|
|
216
|
-
"highcharts",
|
|
217
|
-
"chart"
|
|
218
|
-
],
|
|
324
|
+
allowedChildren: PPTX_SLIDE_CONTENT_COMPONENTS.map(({ name }) => name),
|
|
219
325
|
hasPlaceholders: true,
|
|
220
326
|
category: "container",
|
|
221
327
|
description: "Slide container - groups content elements on a single slide."
|
|
222
328
|
},
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
{
|
|
227
|
-
name: "text",
|
|
228
|
-
propsSchema: TextPropsSchema,
|
|
229
|
-
hasChildren: false,
|
|
230
|
-
category: "content",
|
|
231
|
-
description: "Text element - displays text with formatting, positioning and styling options."
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: "image",
|
|
235
|
-
propsSchema: PptxImagePropsSchema,
|
|
236
|
-
hasChildren: false,
|
|
237
|
-
category: "content",
|
|
238
|
-
description: "Image element - displays images from file path, URL, or base64 data."
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "shape",
|
|
242
|
-
propsSchema: ShapePropsSchema,
|
|
243
|
-
hasChildren: false,
|
|
244
|
-
category: "content",
|
|
245
|
-
description: "Shape element - draws geometric shapes with optional text, fill, and line styling."
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
name: "table",
|
|
249
|
-
propsSchema: PptxTablePropsSchema,
|
|
250
|
-
hasChildren: false,
|
|
251
|
-
category: "content",
|
|
252
|
-
description: "Table element - displays tabular data with rows and columns."
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
name: "highcharts",
|
|
256
|
-
propsSchema: PptxHighchartsPropsSchema,
|
|
257
|
-
hasChildren: false,
|
|
258
|
-
category: "content",
|
|
259
|
-
description: "Highcharts element - renders charts via Highcharts Export Server."
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
name: "chart",
|
|
263
|
-
propsSchema: PptxChartPropsSchema,
|
|
264
|
-
hasChildren: false,
|
|
265
|
-
category: "content",
|
|
266
|
-
description: "Native PowerPoint chart - editable, scalable, no external server needed."
|
|
267
|
-
}
|
|
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
|
|
268
332
|
];
|
|
269
333
|
function getPptxStandardComponent(name) {
|
|
270
334
|
return PPTX_STANDARD_COMPONENTS_REGISTRY.find((c) => c.name === name);
|
|
@@ -288,30 +352,30 @@ function isPptxStandardComponent(name) {
|
|
|
288
352
|
}
|
|
289
353
|
function createPptxComponentSchemaObject(component, recursiveRef, placeholderRef) {
|
|
290
354
|
const schema = {
|
|
291
|
-
name:
|
|
292
|
-
id:
|
|
293
|
-
enabled:
|
|
294
|
-
|
|
355
|
+
name: Type5.Literal(component.name),
|
|
356
|
+
id: Type5.Optional(Type5.String()),
|
|
357
|
+
enabled: Type5.Optional(
|
|
358
|
+
Type5.Boolean({
|
|
295
359
|
default: true,
|
|
296
360
|
description: "When false, this component is filtered out and not rendered. Defaults to true."
|
|
297
361
|
})
|
|
298
362
|
)
|
|
299
363
|
};
|
|
300
364
|
if (component.special?.hasSchemaField) {
|
|
301
|
-
schema.$schema =
|
|
365
|
+
schema.$schema = Type5.Optional(Type5.String({ format: "uri" }));
|
|
302
366
|
}
|
|
303
367
|
schema.props = component.propsSchema;
|
|
304
368
|
if (component.hasChildren && recursiveRef) {
|
|
305
|
-
schema.children =
|
|
369
|
+
schema.children = Type5.Optional(Type5.Array(recursiveRef));
|
|
306
370
|
}
|
|
307
371
|
if (component.hasPlaceholders && (placeholderRef ?? recursiveRef)) {
|
|
308
372
|
const baseProperties = component.propsSchema.properties ?? {};
|
|
309
373
|
const phRef = placeholderRef ?? recursiveRef;
|
|
310
|
-
schema.props =
|
|
374
|
+
schema.props = Type5.Object(
|
|
311
375
|
{
|
|
312
376
|
...baseProperties,
|
|
313
|
-
placeholders:
|
|
314
|
-
|
|
377
|
+
placeholders: Type5.Optional(
|
|
378
|
+
Type5.Record(Type5.String(), phRef, {
|
|
315
379
|
description: 'Content for named placeholders: { "title": { "name": "text", ... } }'
|
|
316
380
|
})
|
|
317
381
|
)
|
|
@@ -322,7 +386,7 @@ function createPptxComponentSchemaObject(component, recursiveRef, placeholderRef
|
|
|
322
386
|
}
|
|
323
387
|
);
|
|
324
388
|
}
|
|
325
|
-
return
|
|
389
|
+
return Type5.Object(schema, { additionalProperties: false });
|
|
326
390
|
}
|
|
327
391
|
function createAllPptxComponentSchemas(recursiveRef) {
|
|
328
392
|
return PPTX_STANDARD_COMPONENTS_REGISTRY.map(
|
|
@@ -362,7 +426,7 @@ function createAllPptxComponentSchemasNarrowed(selfRef, pluginSchemas = []) {
|
|
|
362
426
|
if (!containerDeps.every((d) => resolved.has(d))) continue;
|
|
363
427
|
const childSchemas = comp.allowedChildren.map((name) => resolved.get(name) ?? leafSchemas.get(name)).filter((s) => s !== void 0);
|
|
364
428
|
const allChildSchemas = [...childSchemas, ...pluginSchemas];
|
|
365
|
-
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] :
|
|
429
|
+
const childrenType = allChildSchemas.length === 1 ? allChildSchemas[0] : Type5.Union(allChildSchemas);
|
|
366
430
|
resolved.set(
|
|
367
431
|
comp.name,
|
|
368
432
|
createPptxComponentSchemaObject(comp, childrenType, selfRef)
|
|
@@ -379,6 +443,13 @@ function createAllPptxComponentSchemasNarrowed(selfRef, pluginSchemas = []) {
|
|
|
379
443
|
}
|
|
380
444
|
|
|
381
445
|
export {
|
|
446
|
+
PositionSchema,
|
|
447
|
+
SlideBackgroundSchema,
|
|
448
|
+
TransitionSchema,
|
|
449
|
+
PptxAlignmentSchema,
|
|
450
|
+
VerticalAlignmentSchema,
|
|
451
|
+
ShadowSchema,
|
|
452
|
+
GridPositionSchema,
|
|
382
453
|
PresentationPropsSchema,
|
|
383
454
|
SlidePropsSchema,
|
|
384
455
|
PPTX_STANDARD_COMPONENTS_REGISTRY,
|
|
@@ -392,4 +463,4 @@ export {
|
|
|
392
463
|
createAllPptxComponentSchemas,
|
|
393
464
|
createAllPptxComponentSchemasNarrowed
|
|
394
465
|
};
|
|
395
|
-
//# sourceMappingURL=chunk-
|
|
466
|
+
//# sourceMappingURL=chunk-G3FMM4FX.js.map
|