@bendyline/squisq 2.0.1 → 2.1.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.
Files changed (79) hide show
  1. package/dist/{Doc-ylqWKDc_.d.ts → Doc-DynJleo-.d.ts} +159 -2
  2. package/dist/{ImageEditDoc-D828IXJ1.d.ts → ImageEditDoc-Ca4Tr9uN.d.ts} +1 -1
  3. package/dist/{chunk-PXLVXTLW.js → chunk-ILWDXLUK.js} +24 -6
  4. package/dist/chunk-ILWDXLUK.js.map +1 -0
  5. package/dist/{chunk-W4O2TX5I.js → chunk-JHZWYRSW.js} +569 -1
  6. package/dist/chunk-JHZWYRSW.js.map +1 -0
  7. package/dist/{chunk-X6DUONGT.js → chunk-JI77MGAK.js} +123 -10
  8. package/dist/chunk-JI77MGAK.js.map +1 -0
  9. package/dist/{chunk-TFJVXUHH.js → chunk-OTKVFVL6.js} +1403 -41
  10. package/dist/chunk-OTKVFVL6.js.map +1 -0
  11. package/dist/{chunk-MMPBOUK7.js → chunk-QUUPYOSP.js} +8 -2
  12. package/dist/chunk-QUUPYOSP.js.map +1 -0
  13. package/dist/chunk-VWCJ2WXC.js +215 -0
  14. package/dist/chunk-VWCJ2WXC.js.map +1 -0
  15. package/dist/{chunk-2PWOO4ZE.js → chunk-VYFRI7R6.js} +2 -2
  16. package/dist/{chunk-CY2R2VPR.js → chunk-XNLB57UD.js} +2 -2
  17. package/dist/doc/index.d.ts +144 -5
  18. package/dist/doc/index.js +24 -4
  19. package/dist/generate/index.d.ts +1 -1
  20. package/dist/imageEdit/index.d.ts +3 -3
  21. package/dist/index.d.ts +6 -5
  22. package/dist/index.js +66 -8
  23. package/dist/jsonForm/index.d.ts +1 -1
  24. package/dist/jsonForm/index.js +4 -4
  25. package/dist/materializePageSection-DDzubQXo.d.ts +223 -0
  26. package/dist/narration/index.d.ts +1 -1
  27. package/dist/narration/index.js +3 -3
  28. package/dist/schemas/index.d.ts +30 -5
  29. package/dist/schemas/index.js +41 -3
  30. package/dist/{themeLibrary-RjVgLpUi.d.ts → themeLibrary-B72m0W1y.d.ts} +1 -1
  31. package/dist/transform/index.d.ts +8 -9
  32. package/dist/transform/index.js +1 -1
  33. package/package.json +1 -1
  34. package/src/__tests__/materializeBlockLayers.test.ts +32 -0
  35. package/src/__tests__/materializePageSections.test.ts +404 -0
  36. package/src/__tests__/pageStyle.test.ts +258 -0
  37. package/src/__tests__/templateAnnotationParse.test.ts +13 -0
  38. package/src/doc/index.ts +34 -0
  39. package/src/doc/materializeBlockLayers.ts +170 -9
  40. package/src/doc/page/PageSection.ts +174 -0
  41. package/src/doc/page/materializePageSection.ts +616 -0
  42. package/src/doc/page/resolvePageBlock.ts +108 -0
  43. package/src/doc/page/sectionExtractors.ts +466 -0
  44. package/src/doc/pageCss.ts +628 -0
  45. package/src/doc/templateInputs.ts +1 -0
  46. package/src/schemas/Doc.ts +22 -1
  47. package/src/schemas/PageStyle.ts +213 -0
  48. package/src/schemas/Theme.ts +7 -0
  49. package/src/schemas/index.ts +2 -0
  50. package/src/schemas/pageStyleDefaults.ts +204 -0
  51. package/src/schemas/themeCompile.ts +7 -0
  52. package/src/schemas/themeValidator.ts +183 -0
  53. package/src/schemas/themes/bold.json +29 -0
  54. package/src/schemas/themes/cinematic.json +32 -0
  55. package/src/schemas/themes/documentary.json +29 -0
  56. package/src/schemas/themes/gezellig.json +30 -0
  57. package/src/schemas/themes/magazine.json +37 -0
  58. package/src/schemas/themes/minimalist.json +29 -0
  59. package/src/schemas/themes/morning-light.json +32 -0
  60. package/src/schemas/themes/standard-dark.json +24 -0
  61. package/src/schemas/themes/standard.json +24 -0
  62. package/src/schemas/themes/tech-dark.json +42 -0
  63. package/src/schemas/themes/warm-earth.json +24 -0
  64. package/src/transform/registry.ts +19 -0
  65. package/src/transform/styles/dataDriven.ts +1 -0
  66. package/src/transform/styles/documentary.ts +1 -0
  67. package/src/transform/styles/magazine.ts +1 -0
  68. package/src/transform/styles/minimal.ts +1 -0
  69. package/src/transform/styles/narrative.ts +1 -0
  70. package/src/transform/types.ts +7 -0
  71. package/dist/chunk-FVJUUTEM.js +0 -74
  72. package/dist/chunk-FVJUUTEM.js.map +0 -1
  73. package/dist/chunk-MMPBOUK7.js.map +0 -1
  74. package/dist/chunk-PXLVXTLW.js.map +0 -1
  75. package/dist/chunk-TFJVXUHH.js.map +0 -1
  76. package/dist/chunk-W4O2TX5I.js.map +0 -1
  77. package/dist/chunk-X6DUONGT.js.map +0 -1
  78. /package/dist/{chunk-2PWOO4ZE.js.map → chunk-VYFRI7R6.js.map} +0 -0
  79. /package/dist/{chunk-CY2R2VPR.js.map → chunk-XNLB57UD.js.map} +0 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Resolve a doc block into the typed template input the page pipeline
3
+ * (and the SVG canvas embed) should render.
4
+ *
5
+ * This is the block-input merge that previously lived inline in
6
+ * `LinearDocView` — hoisted into core so the React page view, the string
7
+ * HTML exporter, and tests share one derivation:
8
+ *
9
+ * - Authored blocks with a heading `{[template]}` annotation derive typed
10
+ * inputs from the heading/body (`deriveTemplateInputs` with placeholders),
11
+ * then overlay `templateData` and coerced annotation params / overrides.
12
+ * - Auto-templated blocks (`block.autoTemplate`) already carry derived
13
+ * `templateData`; same overlay applies.
14
+ * - Transform-generated blocks (no `sourceHeading`) already ARE typed
15
+ * template inputs; overlay `templateData` / overrides like
16
+ * `materializeBlockLayers` does.
17
+ * - Everything else is prose.
18
+ */
19
+
20
+ import type { Block } from '../../schemas/Doc.js';
21
+ import type { DocBlock, TemplateBlock } from '../../schemas/BlockTemplates.js';
22
+ import { isTemplateBlock } from '../../schemas/BlockTemplates.js';
23
+ import { extractPlainText } from '../../markdown/utils.js';
24
+ import { deriveTemplateInputs } from '../templateInputs.js';
25
+ import { coerceTemplateParams } from '../templates/inputDescriptors.js';
26
+ import { resolveTemplateName } from '../templates/templateNames.js';
27
+
28
+ /** The page pipeline's view of one block. */
29
+ export interface ResolvedPageBlock {
30
+ /** True when the block renders as a typed section (not prose). */
31
+ templated: boolean;
32
+ /** Canonical template id (post-alias). Only when `templated`. */
33
+ templateName?: string;
34
+ /**
35
+ * Fully merged typed template input, ready for a section extractor or
36
+ * `materializeBlockLayers`. Only when `templated`.
37
+ */
38
+ templateBlock?: TemplateBlock;
39
+ }
40
+
41
+ /**
42
+ * True when the block should render as a typed template section in Page
43
+ * mode: heading annotation, content-aware auto template, or a template
44
+ * block without authoring nodes (transform output, standalone annotation).
45
+ */
46
+ export function isTemplatedPageBlock(block: Block): boolean {
47
+ if (block.sourceHeading?.templateAnnotation?.template) return true;
48
+ if (block.autoTemplate && block.template) return true;
49
+ return !block.sourceHeading && isTemplateBlock(block as DocBlock);
50
+ }
51
+
52
+ /** Template id as authored (pre-alias), when the block is templated. */
53
+ function templatedName(block: Block): string | undefined {
54
+ return block.sourceHeading?.templateAnnotation?.template ?? block.template;
55
+ }
56
+
57
+ /**
58
+ * Merge a block into its typed template input. Mirrors the merge order
59
+ * `materializeBlockLayers` applies at execution time:
60
+ * derived inputs → `templateData` → coerced annotation params/overrides.
61
+ */
62
+ export function resolvePageBlock(block: Block): ResolvedPageBlock {
63
+ if (!isTemplatedPageBlock(block)) return { templated: false };
64
+
65
+ const annotation = block.sourceHeading?.templateAnnotation;
66
+ const rawName = templatedName(block) ?? 'sectionHeader';
67
+ const templateName = resolveTemplateName(rawName);
68
+
69
+ const rawParams: Record<string, string> = {
70
+ ...(annotation?.params ?? {}),
71
+ ...(block.templateOverrides ?? {}),
72
+ };
73
+ const coercedParams = coerceTemplateParams(rawName, rawParams).input;
74
+
75
+ let base: Record<string, unknown>;
76
+ if (annotation) {
77
+ const headingText = extractPlainText(block.sourceHeading!);
78
+ base = {
79
+ id: block.id,
80
+ template: rawName,
81
+ startTime: 0,
82
+ duration: 1,
83
+ audioSegment: 0,
84
+ title: headingText,
85
+ contents: block.contents,
86
+ children: block.children,
87
+ ...(deriveTemplateInputs(rawName, headingText, block.contents, {
88
+ placeholders: true,
89
+ }) ?? {}),
90
+ };
91
+ } else {
92
+ base = {
93
+ ...block,
94
+ startTime: block.startTime ?? 0,
95
+ duration: block.duration ?? 1,
96
+ audioSegment: block.audioSegment ?? 0,
97
+ template: rawName,
98
+ };
99
+ }
100
+
101
+ const templateBlock = {
102
+ ...base,
103
+ ...(block.templateData ?? {}),
104
+ ...coercedParams,
105
+ } as unknown as TemplateBlock;
106
+
107
+ return { templated: true, templateName, templateBlock };
108
+ }
@@ -0,0 +1,466 @@
1
+ /**
2
+ * Per-template section extractors — the page analog of the SVG template
3
+ * registry. Each extractor maps one typed template input onto a
4
+ * `PageSection` draft: a section kind, a variant, and filled content slots.
5
+ *
6
+ * Inherently spatial templates (diagram/tree/timeline/map/drawing/layout)
7
+ * become `canvas-embed` drafts that carry the merged template block; the
8
+ * SVG pipeline renders those internally (including their own titles), so
9
+ * canvas drafts deliberately leave the text slots empty.
10
+ *
11
+ * The registry is total over the built-in template registry — a coverage
12
+ * test asserts every registered template id resolves to an extractor.
13
+ */
14
+
15
+ import type { Block } from '../../schemas/Doc.js';
16
+ import type {
17
+ AccentImage,
18
+ ComparisonBarInput,
19
+ DataTableInput,
20
+ DateEventInput,
21
+ DefinitionCardInput,
22
+ FactCardInput,
23
+ FullBleedQuoteInput,
24
+ ImageWithCaptionInput,
25
+ LeftFeatureInput,
26
+ ListBlockInput,
27
+ PhotoGridInput,
28
+ PullQuoteInput,
29
+ QuoteBlockInput,
30
+ RightFeatureInput,
31
+ SectionHeaderInput,
32
+ StatHighlightInput,
33
+ TemplateBlock,
34
+ TitleBlockInput,
35
+ TwoColumnInput,
36
+ VideoPullQuoteInput,
37
+ VideoWithCaptionInput,
38
+ } from '../../schemas/BlockTemplates.js';
39
+ import type { MarkdownBlockNode } from '../../markdown/types.js';
40
+ import { extractPlainText } from '../../markdown/utils.js';
41
+ import type { PageEmphasis } from '../../schemas/PageStyle.js';
42
+ import type { PageMedia, PageRichText, PageSection, PageSpatialKind } from './PageSection.js';
43
+
44
+ /** Extraction context passed to each extractor. */
45
+ export interface PageSectionContext {
46
+ /** The source block (for canvas embeds and ids). */
47
+ block: Block;
48
+ /** Aspect reference for canvas embeds. */
49
+ viewport: { width: number; height: number };
50
+ }
51
+
52
+ /** What an extractor produces before the art-direction pass. */
53
+ export interface PageSectionDraft {
54
+ kind: PageSection['kind'];
55
+ variant?: string;
56
+ slots: PageSection['slots'];
57
+ /** Suggested emphasis (default 'standard'); art direction may override. */
58
+ emphasis?: PageEmphasis;
59
+ /** True when the section sits on its own full-bleed media background. */
60
+ mediaBackground?: boolean;
61
+ /** Block-authored color-scheme name — wins over theme accent rotation. */
62
+ colorScheme?: string;
63
+ hints?: Record<string, string | number | boolean>;
64
+ }
65
+
66
+ export type SectionExtractor = (input: TemplateBlock, ctx: PageSectionContext) => PageSectionDraft;
67
+
68
+ /** Rich text from the merged input's body contents, when it has any. */
69
+ function bodyRichText(input: TemplateBlock): PageRichText | undefined {
70
+ const contents = (input as unknown as { contents?: MarkdownBlockNode[] }).contents;
71
+ if (!contents || contents.length === 0) return undefined;
72
+ const text = contents
73
+ .map((node) => extractPlainText(node))
74
+ .join('\n')
75
+ .trim();
76
+ return text ? { text, markdown: contents } : undefined;
77
+ }
78
+
79
+ function accentImageMedia(accent?: AccentImage): PageMedia | undefined {
80
+ if (!accent?.src) return undefined;
81
+ return {
82
+ type: 'image',
83
+ src: accent.src,
84
+ alt: accent.alt ?? '',
85
+ credit: accent.credit,
86
+ license: accent.license,
87
+ };
88
+ }
89
+
90
+ /** Build a canvas-embed draft around the merged template block. */
91
+ function canvasDraft(
92
+ spatial: PageSpatialKind,
93
+ ctx: PageSectionContext,
94
+ block?: Block,
95
+ ): PageSectionDraft {
96
+ return {
97
+ kind: 'canvas-embed',
98
+ variant: spatial,
99
+ slots: {
100
+ media: {
101
+ type: 'canvas',
102
+ spatial,
103
+ block: block ?? ctx.block,
104
+ aspect: { width: ctx.viewport.width, height: ctx.viewport.height },
105
+ },
106
+ },
107
+ };
108
+ }
109
+
110
+ const title: SectionExtractor = (input) => {
111
+ const t = input as TitleBlockInput;
112
+ // The slide template ignores body content (a title card's body only feeds
113
+ // narration), but on a page that text would be silently lost — fall back
114
+ // to the block's first paragraph as the hero subtitle.
115
+ const contents = (input as unknown as { contents?: MarkdownBlockNode[] }).contents;
116
+ const firstParagraph = contents?.find((node) => node.type === 'paragraph');
117
+ const subtitle = t.subtitle ?? (firstParagraph ? extractPlainText(firstParagraph) : undefined);
118
+ return {
119
+ kind: 'hero',
120
+ variant: 'title',
121
+ slots: { title: t.title, subtitle },
122
+ emphasis: 'lead',
123
+ hints: t.backgroundColor ? { backgroundColor: t.backgroundColor } : undefined,
124
+ };
125
+ };
126
+
127
+ const sectionHeader: SectionExtractor = (input) => {
128
+ const s = input as SectionHeaderInput;
129
+ const media: PageMedia | undefined = s.imageSrc
130
+ ? { type: 'image', src: s.imageSrc, alt: s.imageAlt ?? '' }
131
+ : undefined;
132
+ return {
133
+ kind: 'banner',
134
+ slots: { title: s.title, media },
135
+ colorScheme: s.colorScheme,
136
+ mediaBackground: !!s.imageSrc,
137
+ };
138
+ };
139
+
140
+ const statHighlight: SectionExtractor = (input) => {
141
+ const s = input as StatHighlightInput;
142
+ return {
143
+ kind: 'stat-band',
144
+ variant: 'single',
145
+ slots: {
146
+ items: [{ value: s.stat, title: s.description, body: s.detail }],
147
+ media: accentImageMedia(s.accentImage),
148
+ },
149
+ emphasis: 'strong',
150
+ colorScheme: s.colorScheme,
151
+ };
152
+ };
153
+
154
+ const quote: SectionExtractor = (input) => {
155
+ const q = input as QuoteBlockInput;
156
+ return {
157
+ kind: 'quote-band',
158
+ variant: 'plain',
159
+ slots: {
160
+ body: { text: q.quote ?? '' },
161
+ attribution: q.attribution,
162
+ media: accentImageMedia(q.accentImage),
163
+ },
164
+ };
165
+ };
166
+
167
+ const factCard: SectionExtractor = (input) => {
168
+ const f = input as FactCardInput;
169
+ return {
170
+ kind: 'callout',
171
+ variant: 'fact',
172
+ slots: {
173
+ title: f.fact,
174
+ body: { text: f.explanation ?? '' },
175
+ meta: f.source,
176
+ media: accentImageMedia(f.accentImage),
177
+ },
178
+ };
179
+ };
180
+
181
+ const twoColumn: SectionExtractor = (input) => {
182
+ const t = input as TwoColumnInput;
183
+ return {
184
+ kind: 'card-grid',
185
+ variant: 'two-column',
186
+ slots: {
187
+ title: t.header,
188
+ items: [
189
+ { title: t.left?.label, body: t.left?.sublabel, accentScheme: t.leftColor },
190
+ { title: t.right?.label, body: t.right?.sublabel, accentScheme: t.rightColor },
191
+ ],
192
+ },
193
+ };
194
+ };
195
+
196
+ const dateEvent: SectionExtractor = (input) => {
197
+ const d = input as DateEventInput;
198
+ return {
199
+ kind: 'timeline-rail',
200
+ slots: {
201
+ milestone: {
202
+ date: d.date ?? '',
203
+ description: d.description ?? '',
204
+ footer: d.footer,
205
+ mood: d.mood,
206
+ },
207
+ media: accentImageMedia(d.accentImage),
208
+ },
209
+ };
210
+ };
211
+
212
+ const imageWithCaption: SectionExtractor = (input) => {
213
+ const i = input as ImageWithCaptionInput;
214
+ const media: PageMedia = {
215
+ type: 'image',
216
+ src: i.imageSrc,
217
+ alt: i.imageAlt ?? '',
218
+ credit: i.imageCredit,
219
+ license: i.imageLicense,
220
+ };
221
+ if (i.isTitle) {
222
+ return {
223
+ kind: 'hero',
224
+ variant: 'media',
225
+ slots: { title: i.caption, subtitle: i.subtitle, media },
226
+ emphasis: 'lead',
227
+ mediaBackground: true,
228
+ };
229
+ }
230
+ return {
231
+ kind: 'media-figure',
232
+ variant: 'image',
233
+ slots: { media, caption: i.caption },
234
+ };
235
+ };
236
+
237
+ function featureDraft(
238
+ input: LeftFeatureInput | RightFeatureInput,
239
+ side: 'left' | 'right',
240
+ ): PageSectionDraft {
241
+ return {
242
+ kind: 'feature-split',
243
+ variant: side === 'left' ? 'media-left' : 'media-right',
244
+ slots: {
245
+ title: input.title,
246
+ body: input.body ? { text: input.body } : undefined,
247
+ media: {
248
+ type: 'image',
249
+ src: input.imageSrc,
250
+ alt: input.imageAlt ?? '',
251
+ width: input.imageWidth,
252
+ height: input.imageHeight,
253
+ },
254
+ },
255
+ };
256
+ }
257
+
258
+ const leftFeature: SectionExtractor = (input) => featureDraft(input as LeftFeatureInput, 'left');
259
+ const rightFeature: SectionExtractor = (input) => featureDraft(input as RightFeatureInput, 'right');
260
+
261
+ const fullBleedQuote: SectionExtractor = (input) => {
262
+ const f = input as FullBleedQuoteInput;
263
+ return {
264
+ kind: 'quote-band',
265
+ variant: 'display',
266
+ slots: { body: { text: f.text ?? '' } },
267
+ emphasis: 'strong',
268
+ colorScheme: f.colorScheme,
269
+ };
270
+ };
271
+
272
+ const list: SectionExtractor = (input) => {
273
+ const l = input as ListBlockInput;
274
+ return {
275
+ kind: 'item-list',
276
+ slots: {
277
+ title: l.title,
278
+ items: (l.items ?? []).map((item) => ({ body: item })),
279
+ media: accentImageMedia(l.accentImage),
280
+ },
281
+ colorScheme: l.colorScheme,
282
+ };
283
+ };
284
+
285
+ const photoGrid: SectionExtractor = (input) => {
286
+ const p = input as PhotoGridInput;
287
+ const images = p.images ?? [];
288
+ // A gallery block whose body has no images yet would render as an empty
289
+ // band — keep the authored heading/body text visible instead.
290
+ const fallback =
291
+ images.length === 0
292
+ ? {
293
+ title: (input as unknown as { title?: string }).title,
294
+ body: bodyRichText(input),
295
+ }
296
+ : undefined;
297
+ return {
298
+ kind: 'gallery',
299
+ slots: {
300
+ ...fallback,
301
+ caption: p.caption,
302
+ items: images.map((img) => ({
303
+ media: {
304
+ type: 'image',
305
+ src: img.src,
306
+ alt: img.alt ?? '',
307
+ credit: img.credit,
308
+ license: img.license,
309
+ } as PageMedia,
310
+ })),
311
+ },
312
+ };
313
+ };
314
+
315
+ const definitionCard: SectionExtractor = (input) => {
316
+ const d = input as DefinitionCardInput;
317
+ return {
318
+ kind: 'callout',
319
+ variant: 'definition',
320
+ slots: {
321
+ title: d.term,
322
+ body: { text: d.definition ?? '' },
323
+ meta: d.origin,
324
+ media: accentImageMedia(d.accentImage),
325
+ },
326
+ colorScheme: d.colorScheme,
327
+ };
328
+ };
329
+
330
+ const comparisonBar: SectionExtractor = (input) => {
331
+ const c = input as ComparisonBarInput;
332
+ return {
333
+ kind: 'stat-band',
334
+ variant: 'comparison',
335
+ slots: {
336
+ items: [
337
+ { title: c.leftLabel, value: c.leftValue },
338
+ { title: c.rightLabel, value: c.rightValue },
339
+ ],
340
+ meta: c.unit,
341
+ },
342
+ emphasis: 'strong',
343
+ colorScheme: c.colorScheme,
344
+ };
345
+ };
346
+
347
+ const pullQuote: SectionExtractor = (input) => {
348
+ const p = input as PullQuoteInput;
349
+ const bg = p.backgroundImage;
350
+ return {
351
+ kind: 'quote-band',
352
+ variant: 'full-bleed',
353
+ slots: {
354
+ body: { text: p.text ?? '' },
355
+ attribution: p.attribution,
356
+ media: bg?.src
357
+ ? { type: 'image', src: bg.src, alt: bg.alt ?? '', credit: bg.credit, license: bg.license }
358
+ : undefined,
359
+ },
360
+ emphasis: 'strong',
361
+ mediaBackground: !!bg?.src,
362
+ };
363
+ };
364
+
365
+ const videoWithCaption: SectionExtractor = (input) => {
366
+ const v = input as VideoWithCaptionInput;
367
+ return {
368
+ kind: 'media-figure',
369
+ variant: 'video',
370
+ slots: {
371
+ media: {
372
+ type: 'video',
373
+ src: v.videoSrc,
374
+ posterSrc: v.posterSrc,
375
+ alt: v.videoAlt ?? '',
376
+ clipStart: v.clipStart,
377
+ clipEnd: v.clipEnd,
378
+ credit: v.videoCredit,
379
+ license: v.videoLicense,
380
+ },
381
+ caption: v.caption,
382
+ },
383
+ };
384
+ };
385
+
386
+ const videoPullQuote: SectionExtractor = (input) => {
387
+ const v = input as VideoPullQuoteInput;
388
+ const bg = v.backgroundVideo;
389
+ return {
390
+ kind: 'quote-band',
391
+ variant: 'full-bleed',
392
+ slots: {
393
+ body: { text: v.text ?? '' },
394
+ attribution: v.attribution,
395
+ media: bg?.src
396
+ ? {
397
+ type: 'video',
398
+ src: bg.src,
399
+ posterSrc: bg.posterSrc,
400
+ alt: bg.alt ?? '',
401
+ clipStart: bg.clipStart,
402
+ clipEnd: bg.clipEnd,
403
+ credit: bg.credit,
404
+ license: bg.license,
405
+ }
406
+ : undefined,
407
+ },
408
+ emphasis: 'strong',
409
+ mediaBackground: !!bg?.src,
410
+ };
411
+ };
412
+
413
+ const dataTable: SectionExtractor = (input) => {
414
+ const d = input as DataTableInput;
415
+ return {
416
+ kind: 'table-section',
417
+ slots: {
418
+ title: d.title,
419
+ table: { headers: d.headers ?? [], rows: d.rows ?? [], align: d.align },
420
+ },
421
+ colorScheme: d.colorScheme,
422
+ };
423
+ };
424
+
425
+ const diagram: SectionExtractor = (input, ctx) =>
426
+ canvasDraft('diagram', ctx, input as unknown as Block);
427
+ const tree: SectionExtractor = (input, ctx) => canvasDraft('tree', ctx, input as unknown as Block);
428
+ const timeline: SectionExtractor = (input, ctx) =>
429
+ canvasDraft('timeline', ctx, input as unknown as Block);
430
+ const map: SectionExtractor = (input, ctx) => canvasDraft('map', ctx, input as unknown as Block);
431
+ const drawing: SectionExtractor = (input, ctx) =>
432
+ canvasDraft('drawing', ctx, input as unknown as Block);
433
+ const layout: SectionExtractor = (input, ctx) =>
434
+ canvasDraft('layout', ctx, input as unknown as Block);
435
+
436
+ /**
437
+ * Extractors keyed by canonical template id — 1:1 with the SVG template
438
+ * registry (`templates/registry.ts`).
439
+ */
440
+ export const sectionExtractors: Record<string, SectionExtractor> = {
441
+ title,
442
+ sectionHeader,
443
+ statHighlight,
444
+ quote,
445
+ factCard,
446
+ twoColumn,
447
+ dateEvent,
448
+ imageWithCaption,
449
+ leftFeature,
450
+ rightFeature,
451
+ map,
452
+ fullBleedQuote,
453
+ list,
454
+ photoGrid,
455
+ definitionCard,
456
+ comparisonBar,
457
+ pullQuote,
458
+ videoWithCaption,
459
+ videoPullQuote,
460
+ dataTable,
461
+ diagram,
462
+ tree,
463
+ timeline,
464
+ layout,
465
+ drawing,
466
+ };