pptxgenjs-plus-jsx 4.1.17

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/README.md ADDED
@@ -0,0 +1,713 @@
1
+ # pptxgenjs-plus-jsx
2
+
3
+ A JSX runtime for building PowerPoint presentations with [pptxgenjs-plus](https://github.com/lofcz/pptxgenjs-plus). Write your slides as JSX components and render them to `.pptx` files.
4
+
5
+ ```tsx
6
+ import { Deck, Slide, Text, TextRun, Rect } from "pptxgenjs-plus-jsx";
7
+ import { renderPptx } from "pptxgenjs-plus-jsx/render";
8
+
9
+ await renderPptx(
10
+ <Deck title="My Deck">
11
+ <Slide>
12
+ <Rect x={0} y={0} w={13.333} h={7.5} fill={{ color: "1E1E2E" }} />
13
+ <Text x={1} y={3} w={11} h={1.5}>
14
+ <TextRun options={{ fontSize: 44, color: "FFFFFF", bold: true }}>
15
+ Hello, PowerPoint!
16
+ </TextRun>
17
+ </Text>
18
+ </Slide>
19
+ </Deck>,
20
+ { fileName: "output.pptx" },
21
+ );
22
+ ```
23
+
24
+ ## Table of Contents
25
+
26
+ - [Installation](#installation)
27
+ - [TypeScript Configuration](#typescript-configuration)
28
+ - [Component Reference](#component-reference)
29
+ - [Deck & Presentation](#deck--presentation)
30
+ - [Slide](#slide)
31
+ - [Text & TextRun](#text--textrun)
32
+ - [Shapes](#shapes)
33
+ - [Charts](#charts)
34
+ - [Tables](#tables)
35
+ - [Images & Media](#images--media)
36
+ - [Group](#group)
37
+ - [Raw (escape hatch)](#raw-escape-hatch)
38
+ - [Fragment](#fragment)
39
+ - [Async Components](#async-components)
40
+ - [Context Hooks](#context-hooks)
41
+ - [useSlideContext](#useslidecontext)
42
+ - [useDeckContext](#usedeckcontext)
43
+ - [useGroupContext](#usegroupcontext)
44
+ - [Lazy Slide Loading](#lazy-slide-loading)
45
+ - [Percentage Coordinates](#percentage-coordinates)
46
+ - [Sections & Masters](#sections--masters)
47
+ - [Validation](#validation)
48
+ - [Rendering](#rendering)
49
+ - [License](#license)
50
+
51
+ ---
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ npm install pptxgenjs-plus-jsx
57
+ ```
58
+
59
+ Peer dependency:
60
+
61
+ - **[pptxgenjs-plus](https://github.com/lofcz/pptxgenjs-plus)** — workspace dependency in this monorepo.
62
+
63
+ ## TypeScript Configuration
64
+
65
+ Set `jsx` and `jsxImportSource` in your `tsconfig.json`:
66
+
67
+ ```json
68
+ {
69
+ "compilerOptions": {
70
+ "jsx": "react-jsx",
71
+ "jsxImportSource": "pptxgenjs-plus-jsx"
72
+ }
73
+ }
74
+ ```
75
+
76
+ > **Note**: This is **not** React — the JSX transform produces `PptxNode` objects, not DOM elements. No React dependency is required.
77
+
78
+ ---
79
+
80
+ ## Component Reference
81
+
82
+ ### Deck / Presentation
83
+
84
+ The root element of every presentation. Maps to `new PptxGenJS()`.
85
+
86
+ ```tsx
87
+ <Deck>
88
+ <Slide>...</Slide>
89
+ </Deck>
90
+ ```
91
+
92
+ `<Presentation>` is an alias for `<Deck>`.
93
+
94
+ #### Layout
95
+
96
+ Use the `layout` prop to control slide dimensions. Two forms are supported:
97
+
98
+ **1. Built-in layout name** (string) — pptxgenjs provides four standard presets:
99
+
100
+ | Name | Dimensions | Aspect Ratio |
101
+ | ---------------- | ------------- | ------------ |
102
+ | `"LAYOUT_4x3"` | 10" × 7.5" | 4:3 |
103
+ | `"LAYOUT_16x9"` | 10" × 5.625" | 16:9 |
104
+ | `"LAYOUT_16x10"` | 10" × 6.25" | 16:10 |
105
+ | `"LAYOUT_WIDE"` | 13.33" × 7.5" | 16:9 (wide) |
106
+
107
+ Default: `"LAYOUT_WIDE"` (13.33" × 7.5").
108
+
109
+ ```tsx
110
+ <Deck layout="LAYOUT_16x9">
111
+ <Slide>...</Slide>
112
+ </Deck>
113
+ ```
114
+
115
+ **2. Custom layout** (object) — define arbitrary dimensions via a `PresLayout` object with `name`, `width`, and `height` (in inches):
116
+
117
+ ```tsx
118
+ <Deck layout={{ name: "A4", width: 10.83, height: 7.82 }}>
119
+ <Slide>...</Slide>
120
+ </Deck>
121
+ ```
122
+
123
+ For multiple custom layouts, use the `layouts` prop (array of `PresLayout`):
124
+
125
+ ```tsx
126
+ <Deck
127
+ layout="A4"
128
+ layouts={[
129
+ { name: "A4", width: 10.83, height: 7.82 },
130
+ { name: "Letter", width: 10, height: 7.5 },
131
+ ]}
132
+ >
133
+ <Slide>...</Slide>
134
+ </Deck>
135
+ ```
136
+
137
+ The first matching layout name becomes the presentation's active layout.
138
+
139
+ ### Slide
140
+
141
+ A single slide. Maps to `pptx.addSlide()`.
142
+
143
+ ```tsx
144
+ <Slide>
145
+ <Text>A simple slide</Text>
146
+ </Slide>
147
+ ```
148
+
149
+ **Lazy-loaded slide** (see [Lazy Slide Loading](#lazy-slide-loading)):
150
+
151
+ ```tsx
152
+ <Slide component={() => import("./slides/chart-slide")} />
153
+ ```
154
+
155
+ ### Text & TextRun
156
+
157
+ **`<Text>`** — a text box or rich text container. Maps to `slide.addText()`.
158
+
159
+ ```tsx
160
+ // Simple text (string from children)
161
+ <Text x={1} y={1} w={8} h={1} fontSize={24} color="333333">
162
+ Hello, World!
163
+ </Text>
164
+
165
+ // Rich text with multiple TextRun elements
166
+ <Text x={1} y={2.5} w={8} h={1.5} valign="middle">
167
+ <TextRun options={{ fontSize: 18, color: "666666" }}>Normal text </TextRun>
168
+ <TextRun options={{ fontSize: 18, color: "0066CC", bold: true }}>
169
+ bold and blue
170
+ </TextRun>
171
+ </Text>
172
+ ```
173
+
174
+ **`<TextRun>`** — a single formatted run inside `<Text>`. `options` accepts pptxgenjs `TextProps` (fontSize, color, bold, italic, fontFace, etc.). The run's text comes from its string children (or the `text` prop):
175
+
176
+ ```tsx
177
+ <TextRun options={{ fontSize: 18, color: "0066CC", bold: true }}>bold and blue</TextRun>
178
+ ```
179
+
180
+ **Text input modes.** A `<Text>` element has four ways to receive content. When more than one is present, this priority applies (higher wins, the rest is ignored):
181
+
182
+ 1. child `<TextRun />` nodes — plain string/number children mixed among them are converted to default-style runs (order preserved)
183
+ 2. the `runs` prop (rich text array — same shape as pptxgenjs `TextProps[]`)
184
+ 3. the `text` prop
185
+ 4. plain-string children
186
+
187
+ Plain strings mix freely with `<TextRun />` children — each string segment becomes a default-style run in place:
188
+
189
+ ```tsx
190
+ <Text x={1} y={4} w={8} h={1}>
191
+ {"Normal segment "}
192
+ <TextRun options={{ color: "0066CC", bold: true }}>highlighted</TextRun>
193
+ </Text>
194
+ ```
195
+
196
+ Whitespace-only text between elements (e.g. from multi-line JSX formatting) is ignored — attach explicit spaces to a run's text (`<TextRun>A </TextRun>`) instead. Mixing the other modes (e.g. `runs` or `text` props alongside children) still drops the lower-priority content.
197
+
198
+ ```tsx
199
+ // runs prop (imperative rich text)
200
+ <Text
201
+ x={1}
202
+ y={1}
203
+ w={8}
204
+ h={1}
205
+ runs={[
206
+ { text: "Normal ", options: { fontSize: 18 } },
207
+ { text: "bold", options: { fontSize: 18, bold: true } },
208
+ ]}
209
+ />
210
+ ```
211
+
212
+ **Text with a shape background.** `shape` is a valid pptxgenjs text option and is forwarded to `slide.addText()`:
213
+
214
+ ```tsx
215
+ <Text
216
+ x={1}
217
+ y={1}
218
+ w={4}
219
+ h={2}
220
+ shape="roundRect"
221
+ fill={{ color: "EDE9FE" }}
222
+ margin={18} // text margin uses POINTS (~0.25"), not inches
223
+ valign="middle"
224
+ >
225
+ Shaped text box
226
+ </Text>
227
+ ```
228
+
229
+ > Note: pptxgenjs text `margin` values are in **points** (e.g. `18` ≈ 0.25"), not inches.
230
+
231
+ ### Shapes
232
+
233
+ All pptxgenjs shapes are available as JSX components. Each supports standard positioning props (`x`, `y`, `w`, `h`) plus shape-specific options via `options` or as top-level props.
234
+
235
+ > **Shapes are leaf elements** — they do not render children. Nested content
236
+ > (e.g. `<RoundRect><Text>…</Text></RoundRect>`) is a compile-time error in TSX
237
+ > and a hard runtime error otherwise; it is never silently dropped.
238
+ >
239
+ > To put text on a shape, use **one** of:
240
+ >
241
+ > 1. A single text box with a shape background: `<Text shape="roundRect" …>` (recommended when the text and shape share one box — see [Text & TextRun](#text--textrun)).
242
+ > 2. A sibling `<Text>` layered over the shape (when text and shape need independent styles/shadows/geometry).
243
+ > 3. A `<Group>` only when you need a relative coordinate system or want to move/scale the pair together.
244
+
245
+ ```tsx
246
+ <Rect x={0} y={0} w={13.333} h={7.5} fill={{ color: "1E1E2E" }} />
247
+ <Ellipse x={1} y={1} w={3} h={2} fill={{ color: "FF6B6B" }} />
248
+ <Triangle x={5} y={1} w={2} h={2} fill={{ color: "4ECDC4" }} />
249
+ <RoundRect x={1} y={4} w={4} h={2} fill={{ color: "45B7D1" }} rectRadius={0.3} />
250
+ <Line x={1} y={1} w={5} h={0} line={{ color: "FF0000", width: 2 }} />
251
+ <Cloud x={1} y={1} w={3} h={2} fill={{ color: "E8F4FD" }} />
252
+ <Heart x={5} y={1} w={2} h={2} fill={{ color: "FF4081" }} />
253
+ ```
254
+
255
+ **`<LineBetween>`** — a line connecting two absolute coordinates. Supports percentage coordinates.
256
+
257
+ ```tsx
258
+ <LineBetween
259
+ x1={0}
260
+ y1={0}
261
+ x2={13.333}
262
+ y2={7.5}
263
+ line={{ color: "999999", width: 1, dashType: "dash" }}
264
+ />
265
+ ```
266
+
267
+ Available shape components:
268
+
269
+ | Component | pptxgenjs shape |
270
+ | -------------------------- | ----------------------------------- |
271
+ | `Rect` | `rect` |
272
+ | `RoundRect` | `roundRect` |
273
+ | `Ellipse` / `Oval` | `ellipse` |
274
+ | `Triangle` | `triangle` |
275
+ | `RightTriangle` | `rtTriangle` |
276
+ | `Diamond` | `diamond` |
277
+ | `Pentagon` | `pentagon` |
278
+ | `Hexagon` | `hexagon` |
279
+ | `Star` / `Star5` | `star5` |
280
+ | `Star4` | `star4` |
281
+ | `Star6` | `star6` |
282
+ | `Star8` | `star8` |
283
+ | `Star10` | `star10` |
284
+ | `Line` | `line` |
285
+ | `LineBetween` | `line` (with computed bounding box) |
286
+ | `Arc` | `arc` |
287
+ | `BlockArc` | `blockArc` |
288
+ | `PieShape` | `pie` |
289
+ | `CustomGeometry` | `custGeom` |
290
+ | `LeftArrow` / `RightArrow` | `leftArrow` / `rightArrow` |
291
+ | `UpArrow` / `DownArrow` | `upArrow` / `downArrow` |
292
+ | `LeftRightArrow` | `leftRightArrow` |
293
+ | `UpDownArrow` | `upDownArrow` |
294
+ | `Chevron` | `chevron` |
295
+ | `Cloud` | `cloud` |
296
+ | `Heart` | `heart` |
297
+ | `Donut` | `donut` |
298
+ | `Plus` | `plus` |
299
+
300
+ ### Charts
301
+
302
+ ```tsx
303
+ // Generic chart with explicit `type`
304
+ <Chart
305
+ x={1} y={1} w={10} h={5}
306
+ type="bar"
307
+ data={[
308
+ { name: "Q1", labels: ["Jan", "Feb", "Mar"], values: [100, 150, 200] },
309
+ { name: "Q2", labels: ["Jan", "Feb", "Mar"], values: [120, 180, 160] },
310
+ ]}
311
+ showTitle="Quarterly Sales"
312
+ showLegend={true}
313
+ />
314
+
315
+ // Or use a typed chart component
316
+ <BarChart x={1} y={1} w={10} h={5} data={[...]} showValue={true} />
317
+ <LineChart x={1} y={1} w={10} h={5} data={[...]} lineSize={3} />
318
+ <PieChart x={1} y={1} w={6} h={5} data={[...]} showPercent={true} />
319
+ ```
320
+
321
+ Available chart components: `AreaChart`, `BarChart`, `Bar3DChart`, `BubbleChart`, `DoughnutChart`, `LineChart`, `PieChart`, `RadarChart`, `ScatterChart`.
322
+
323
+ ### Tables
324
+
325
+ ```tsx
326
+ <Table x={1} y={1} w={10} h={3} fontSize={12} border={{ type: "solid", color: "CCCCCC" }}>
327
+ <TableRow>
328
+ <TableCell options={{ fill: { color: "4472C4" }, color: "FFFFFF", bold: true }}>Name</TableCell>
329
+ <TableCell options={{ fill: { color: "4472C4" }, color: "FFFFFF", bold: true }}>
330
+ Value
331
+ </TableCell>
332
+ </TableRow>
333
+ <TableRow>
334
+ <TableCell>Item A</TableCell>
335
+ <TableCell>100</TableCell>
336
+ </TableRow>
337
+ <TableRow>
338
+ <TableCell>Item B</TableCell>
339
+ <TableCell>200</TableCell>
340
+ </TableRow>
341
+ </Table>
342
+ ```
343
+
344
+ `TableToSlides` splits an HTML table across multiple slides (browser runtime only).
345
+
346
+ ### Images & Media
347
+
348
+ ```tsx
349
+ <Image
350
+ x={1} y={1} w={5} h={3}
351
+ path="https://example.com/image.png"
352
+ sizing={{ type: "contain", w: 5, h: 3 }}
353
+ />
354
+
355
+ <Media
356
+ x={1} y={1} w={6} h={4}
357
+ path="https://example.com/video.mp4"
358
+ mediaType="video"
359
+ />
360
+ ```
361
+
362
+ ### Group
363
+
364
+ A PresentationML group (`p:grpSp`). Child coordinates are relative to the group's origin. Maps to `slide.addGroup()`.
365
+
366
+ ```tsx
367
+ <Group x={1} y={1} w={10} h={5}>
368
+ {/* (0, 0) inside group → group-relative; the group itself sits at (1, 1) */}
369
+ <Rect x={0} y={0} w={10} h={5} fill={{ color: "F0F0F0" }} />
370
+ {/* "50%" inside group → 5" from the group origin */}
371
+ <Text x="50%" y="50%" w={4} h={1}>
372
+ <TextRun options={{ fontSize: 18 }}>Centered in group</TextRun>
373
+ </Text>
374
+ </Group>
375
+ ```
376
+
377
+ Key features:
378
+
379
+ - **Native group shape**: children move and transform together in PowerPoint.
380
+ - **Coordinate transformation**: Child `x`, `y`, `w`, `h` are relative to the group origin. Percentage strings resolve against the group's `w` (for x/w) or `h` (for y/h).
381
+ - **Nested groups**: Groups can nest via `group.addGroup()`.
382
+ - **Valid children**: shapes, text, images, and nested groups. Tables, charts, media, notes, and WordArt must stay on the slide.
383
+ - **Context-aware**: Children can use `useGroupContext()` for the group's virtual canvas (`width` / `height`) and slide origin (`x` / `y`).
384
+
385
+ ### Raw (escape hatch)
386
+
387
+ For pptxgenjs features not covered by a dedicated component.
388
+
389
+ ```tsx
390
+ <Raw
391
+ render={({ pptx, slide, node }) => {
392
+ // Direct access to slide.addShape(), slide.addText(), etc.
393
+ slide.addShape("rect", { x: 1, y: 1, w: 5, h: 3, fill: { color: "FF0000" } });
394
+ }}
395
+ />
396
+ ```
397
+
398
+ > Raw children are **not** auto-rendered — they are only accessible via
399
+ > `context.node.children` inside the `render` callback. Use props for
400
+ > configuration; use children only when the callback reads them itself.
401
+
402
+ ### Fragment
403
+
404
+ Groups multiple children without producing a wrapper element. Useful when a component needs to return multiple siblings (e.g., in a lazy-loaded slide or inside a map).
405
+
406
+ **Shorthand form `<>...</>`** — for simple grouping without props:
407
+
408
+ ```tsx
409
+ // slides/title-slide.tsx
410
+ export default function TitleSlide() {
411
+ return (
412
+ <>
413
+ <Text x={1} y={3} w={10} h={1.5} fontSize={44} bold>
414
+ Welcome
415
+ </Text>
416
+ <Text x={1} y={4.5} w={10} h={1} fontSize={18} color="666666">
417
+ Subtitle text
418
+ </Text>
419
+ </>
420
+ );
421
+ }
422
+ ```
423
+
424
+ **Explicit `<Fragment>`** — when you need a `key` prop (e.g., in a `.map()` loop):
425
+
426
+ ```tsx
427
+ import { Fragment } from "pptxgenjs-plus-jsx";
428
+
429
+ <Slide>
430
+ {items.map((item) => (
431
+ <Fragment key={item.id}>
432
+ <Text x={1} y={item.y}>
433
+ {item.name}
434
+ </Text>
435
+ <Text x={5} y={item.y}>
436
+ {item.value}
437
+ </Text>
438
+ </Fragment>
439
+ ))}
440
+ </Slide>;
441
+ ```
442
+
443
+ > **Note**: `<>...</>` is a JSX compile-time syntax — it does not support props like `key`. For dynamic lists, always use `<Fragment key={...}>`.
444
+
445
+ ---
446
+
447
+ ## Async Components
448
+
449
+ Components can be `async` functions — they are automatically detected and lazily resolved during rendering:
450
+
451
+ ```tsx
452
+ // slides/data-slide.tsx
453
+ export default async function DataSlide() {
454
+ const res = await fetch("https://api.example.com/data");
455
+ const data = await res.json();
456
+
457
+ return (
458
+ <Slide>
459
+ <Text x={1} y={1} w={8} h={1} fontSize={32} bold>
460
+ {data.title}
461
+ </Text>
462
+ <Text x={1} y={2.5} w={8} h={4} fontSize={16}>
463
+ {data.description}
464
+ </Text>
465
+ </Slide>
466
+ );
467
+ }
468
+ ```
469
+
470
+ ```tsx
471
+ // main.tsx
472
+ await renderPptx(
473
+ <Deck>
474
+ <Slide>{/* ... */}</Slide>
475
+ <DataSlide /> {/* async — resolves automatically */}
476
+ </Deck>,
477
+ { fileName: "output.pptx" },
478
+ );
479
+ ```
480
+
481
+ This works because the JSX factory (`jsx`) wraps async component results in a `PptxNodePromise`, and the renderer resolves them during tree traversal.
482
+
483
+ ---
484
+
485
+ ## Context Hooks
486
+
487
+ Context hooks provide runtime information about the current rendering environment.
488
+
489
+ **How it works**: When TypeScript compiles your JSX, component factories are NOT called during JSX construction. Instead, they are wrapped in a deferred node and executed later during rendering — at which point the renderer has set up the context store via `AsyncLocalStorage`. This is why you can write components that call `useSlideContext()` as direct children of `<Slide>`, even though the JSX appears to be built "eagerly."
490
+
491
+ ### useSlideContext
492
+
493
+ Exposes the current slide's index and total.
494
+
495
+ ```tsx
496
+ import { useSlideContext } from "pptxgenjs-plus-jsx";
497
+
498
+ function SlideNumber() {
499
+ const { index, total, sectionTitle } = useSlideContext();
500
+
501
+ return (
502
+ <Text x={1} y={6.5} w={10} h={0.5} fontSize={10} color="999999">
503
+ Slide {index} of {total}
504
+ {sectionTitle ? ` · ${sectionTitle}` : ""}
505
+ </Text>
506
+ );
507
+ }
508
+ ```
509
+
510
+ ```tsx
511
+ // Usage inside a Slide:
512
+ <Slide>
513
+ {/* ... slide content ... */}
514
+ <SlideNumber />
515
+ </Slide>
516
+ ```
517
+
518
+ ### useDeckContext
519
+
520
+ Exposes the deck's slide dimensions (width, height in inches).
521
+
522
+ ```tsx
523
+ import { useDeckContext } from "pptxgenjs-plus-jsx";
524
+
525
+ function FullBleedBackground() {
526
+ const { width, height } = useDeckContext();
527
+ return <Rect x={0} y={0} w={width} h={height} fill={{ color: "1E1E2E" }} />;
528
+ }
529
+ ```
530
+
531
+ ### useGroupContext
532
+
533
+ Exposes the current group's origin on the slide and its virtual canvas. When called outside a `<Group>`, falls back to deck dimensions with zero offset (`relative: false`). Inside a group, child coordinates are group-relative (`relative: true`).
534
+
535
+ ```tsx
536
+ import { useGroupContext } from "pptxgenjs-plus-jsx";
537
+
538
+ function ProgressBar() {
539
+ const { width } = useGroupContext();
540
+ return <Rect x={0} y={0} w={width * 0.7} h={0.4} fill={{ color: "4CAF50" }} />;
541
+ }
542
+ ```
543
+
544
+ ---
545
+
546
+ ## Lazy Slide Loading
547
+
548
+ Use the `component` prop on `<Slide>` to defer loading of slide definitions — analogous to React Router's lazy route loading.
549
+
550
+ ```tsx
551
+ // slides/title-slide.tsx
552
+ export default function TitleSlide() {
553
+ return (
554
+ <>
555
+ <Text x={1} y={3} w={10} h={1.5} fontSize={44} bold>
556
+ Welcome
557
+ </Text>
558
+ </>
559
+ );
560
+ }
561
+ ```
562
+
563
+ ```tsx
564
+ // main.tsx
565
+ <Slide component={() => import("./slides/title-slide")} />
566
+ ```
567
+
568
+ The component's return value is rendered **inside** the `<Slide>` that declares `component`, so it should provide slide **content only** — not another `<Slide>` element. Context hooks work inside lazy-loaded components.
569
+
570
+ ---
571
+
572
+ ## Percentage Coordinates
573
+
574
+ `x`, `y`, `w`, `h` values can be specified as percentage strings (e.g. `"50%"`, `"100%"`), which are resolved relative to the enclosing context:
575
+
576
+ - **Inside a `<Group>`**: resolved against the group's `w` (for x/w) or `h` (for y/h).
577
+ - **Directly inside a `<Slide>`**: resolved against the slide's dimensions from the deck layout.
578
+
579
+ ```tsx
580
+ <Group x={1} y={1} w={10} h={5}>
581
+ {/* 50% of group width (5"), 25% of group height (1.25") */}
582
+ <Rect x="25%" y="25%" w="50%" h="50%" fill={{ color: "4ECDC4" }} />
583
+ </Group>
584
+ ```
585
+
586
+ This works for all positioning props: `x`, `y`, `w`, `h` on all shape/text/image components, and `x1`, `y1`, `x2`, `y2` on `LineBetween`.
587
+
588
+ ---
589
+
590
+ ## Sections & Masters
591
+
592
+ ### Sections
593
+
594
+ Group slides into named sections in the PowerPoint outline view.
595
+
596
+ ```tsx
597
+ <Deck>
598
+ <Slide>...</Slide>
599
+ <Section title="Overview">
600
+ <Slide>...</Slide>
601
+ <Slide>...</Slide>
602
+ </Section>
603
+ <Section title="Details">
604
+ <Slide>...</Slide>
605
+ </Section>
606
+ </Deck>
607
+ ```
608
+
609
+ ### Masters
610
+
611
+ Define slide masters with reusable layout objects.
612
+
613
+ ```tsx
614
+ <Deck>
615
+ <Master name="myMaster" background={{ fill: "F5F5F5" }}>
616
+ <Text x={1} y={0.3} w={10} h={0.5} fontSize={10} color="999999">
617
+ Confidential
618
+ </Text>
619
+ <Rect x={0} y={7} w={13.333} h={0.5} fill={{ color: "4472C4" }} />
620
+ </Master>
621
+ <Slide masterName="myMaster">...</Slide>
622
+ </Deck>
623
+ ```
624
+
625
+ You can also use `<Placeholder>` inside masters:
626
+
627
+ ```tsx
628
+ <Master name="content">
629
+ <Placeholder options={{ name: "Body", type: "body", x: 1, y: 1, w: 10, h: 5 }} />
630
+ </Master>
631
+ ```
632
+
633
+ ## Validation
634
+
635
+ The `validateDeck()` function checks your slide tree for common mistakes before rendering. It is **async** — always `await` it:
636
+
637
+ ```tsx
638
+ import { validateDeck } from "pptxgenjs-plus-jsx/render";
639
+
640
+ const deck = <Deck>{/* ... */}</Deck>;
641
+ const issues = await validateDeck(deck);
642
+
643
+ if (issues.length > 0) {
644
+ for (const issue of issues) {
645
+ console.error(`[${issue.level}] ${issue.message}`);
646
+ }
647
+ }
648
+ ```
649
+
650
+ Validation catches:
651
+
652
+ - Invalid child types (e.g., a `<Text>` directly inside a `<Deck>`)
653
+ - **Leaf components with children** (`child.leaf`, e.g. `<RoundRect>` containing a `<Text>`)
654
+ - Missing required props (e.g., `CustomGeometry` without `points`)
655
+ - Suspicious prop usage (e.g., `angleRange` on `RoundRect`)
656
+ - Mixed `<Text>` input modes (`text.input.mixed`) — warns whenever a lower-priority source would be ignored and recommends `<TextRun />` children for rich text
657
+ - Invalid `LineBetween` endpoints
658
+
659
+ ---
660
+
661
+ ## Rendering
662
+
663
+ ### To a File
664
+
665
+ ```tsx
666
+ import { renderPptx } from "pptxgenjs-plus-jsx/render";
667
+
668
+ await renderPptx(<Deck>{/* ... */}</Deck>, {
669
+ fileName: "output/presentation.pptx",
670
+ });
671
+ ```
672
+
673
+ Additional pptxgenjs `writeFile` options are also supported:
674
+
675
+ ```tsx
676
+ await renderPptx(<Deck>{/* ... */}</Deck>, {
677
+ fileName: "output.pptx",
678
+ compression: true, // Enable ZIP compression
679
+ zipOptions: { level: 9 }, // Compression level
680
+ });
681
+ ```
682
+
683
+ ### To a Buffer / Blob
684
+
685
+ ```tsx
686
+ import { writePptx } from "pptxgenjs-plus-jsx/render";
687
+
688
+ const buffer = await writePptx(<Deck>{/* ... */}</Deck>, {
689
+ outputType: "arraybuffer", // "arraybuffer" | "blob" | "uint8array" | "base64" | "nodebuffer"
690
+ });
691
+ ```
692
+
693
+ ### Reuse an Existing PptxGenJS Instance
694
+
695
+ ```tsx
696
+ import PptxGenJS from "pptxgenjs-plus";
697
+
698
+ const pptx = new PptxGenJS();
699
+ // ... configure the instance ...
700
+ await renderPptx(<Deck>{/* ... */}</Deck>, { pptx });
701
+ ```
702
+
703
+ ### Aliases
704
+
705
+ ```tsx
706
+ import { render, write } from "pptxgenjs-plus-jsx/render";
707
+
708
+ await render(<Deck>{/* ... */}</Deck>, { fileName: "output.pptx" });
709
+ ```
710
+
711
+ ## License
712
+
713
+ MIT