@bendyline/squisq 1.4.1 → 1.5.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 (216) hide show
  1. package/dist/{Doc-BeSeH2iX.d.ts → Doc-BsMkmzH8.d.ts} +838 -268
  2. package/dist/{ImageEditDoc-BTIvw0oq.d.ts → ImageEditDoc-DvoeHMP9.d.ts} +11 -4
  3. package/dist/{chunk-ZTX4PFFT.js → chunk-2OIBZYKP.js} +75 -2
  4. package/dist/chunk-2OIBZYKP.js.map +1 -0
  5. package/dist/chunk-2UQOHYE2.js +45 -0
  6. package/dist/chunk-2UQOHYE2.js.map +1 -0
  7. package/dist/{chunk-B4EEON3N.js → chunk-4AKUQPEE.js} +536 -103
  8. package/dist/chunk-4AKUQPEE.js.map +1 -0
  9. package/dist/chunk-4ZFRZBU2.js +6582 -0
  10. package/dist/chunk-4ZFRZBU2.js.map +1 -0
  11. package/dist/{chunk-57CVQCFX.js → chunk-7MQGNR76.js} +79 -3
  12. package/dist/chunk-7MQGNR76.js.map +1 -0
  13. package/dist/{chunk-5WFRKURX.js → chunk-DLXZMS5K.js} +4 -2
  14. package/dist/chunk-DLXZMS5K.js.map +1 -0
  15. package/dist/{chunk-MYIH7FWD.js → chunk-FBKP5CAO.js} +1 -1
  16. package/dist/chunk-FBKP5CAO.js.map +1 -0
  17. package/dist/chunk-KZNXZ5SM.js +333 -0
  18. package/dist/chunk-KZNXZ5SM.js.map +1 -0
  19. package/dist/{chunk-WMOI7FN3.js → chunk-LRCV7N7F.js} +12 -2
  20. package/dist/{chunk-WMOI7FN3.js.map → chunk-LRCV7N7F.js.map} +1 -1
  21. package/dist/{chunk-3K5OG6KI.js → chunk-OH43RPTP.js} +403 -187
  22. package/dist/chunk-OH43RPTP.js.map +1 -0
  23. package/dist/{chunk-H3AXU4MJ.js → chunk-OKJOQXK4.js} +149 -2
  24. package/dist/chunk-OKJOQXK4.js.map +1 -0
  25. package/dist/chunk-PGGGKYWG.js +1 -0
  26. package/dist/chunk-PGGGKYWG.js.map +1 -0
  27. package/dist/{chunk-7UDSRZKG.js → chunk-Q3ROPT5H.js} +35 -14
  28. package/dist/chunk-Q3ROPT5H.js.map +1 -0
  29. package/dist/chunk-QE7TWGVT.js +178 -0
  30. package/dist/chunk-QE7TWGVT.js.map +1 -0
  31. package/dist/chunk-RUDYOTA6.js +345 -0
  32. package/dist/chunk-RUDYOTA6.js.map +1 -0
  33. package/dist/chunk-TVSGLUID.js +596 -0
  34. package/dist/chunk-TVSGLUID.js.map +1 -0
  35. package/dist/chunk-ZLQKNOZQ.js +1 -0
  36. package/dist/chunk-ZLQKNOZQ.js.map +1 -0
  37. package/dist/doc/index.d.ts +4 -4
  38. package/dist/doc/index.js +124 -6
  39. package/dist/generate/index.d.ts +9 -2
  40. package/dist/generate/index.js +1 -1
  41. package/dist/icons/index.d.ts +3 -26
  42. package/dist/icons/index.js +13 -0
  43. package/dist/icons/inlineIconMarker.d.ts +1 -0
  44. package/dist/icons/inlineIconMarker.js +15 -0
  45. package/dist/icons/inlineIconMarker.js.map +1 -0
  46. package/dist/imageEdit/index.d.ts +11 -5
  47. package/dist/imageEdit/index.js +4 -1
  48. package/dist/index.d.ts +11 -8
  49. package/dist/index.js +243 -24
  50. package/dist/inlineIconMarker-CiE8Hlvz.d.ts +59 -0
  51. package/dist/markdown/index.d.ts +212 -3
  52. package/dist/markdown/index.js +40 -7
  53. package/dist/recommend/index.d.ts +1 -1
  54. package/dist/recommend/index.js +3 -2
  55. package/dist/schemas/index.d.ts +28 -8
  56. package/dist/schemas/index.js +35 -5
  57. package/dist/spatial/index.d.ts +9 -4
  58. package/dist/spatial/index.js +1 -1
  59. package/dist/story/index.d.ts +906 -40
  60. package/dist/story/index.js +124 -6
  61. package/dist/{themeLibrary-BHjJ0Qx6.d.ts → themeLibrary-DQQKuRMx.d.ts} +1 -1
  62. package/dist/transform/index.d.ts +48 -10
  63. package/dist/transform/index.js +17 -481
  64. package/dist/transform/index.js.map +1 -1
  65. package/dist/{types-BdZkdJ3z.d.ts → types-DlAZ7MW4.d.ts} +115 -1
  66. package/package.json +6 -1
  67. package/src/__tests__/animationUtils.test.ts +40 -0
  68. package/src/__tests__/annotationCoercion.test.ts +243 -0
  69. package/src/__tests__/applyRenderStyle.test.ts +146 -0
  70. package/src/__tests__/atmosphereLayers.test.ts +108 -0
  71. package/src/__tests__/attrTokens.test.ts +162 -0
  72. package/src/__tests__/customTemplateSample.test.ts +83 -0
  73. package/src/__tests__/customTemplatesFrontmatter.test.ts +205 -0
  74. package/src/__tests__/customThemesFrontmatter.test.ts +118 -0
  75. package/src/__tests__/diagramBlock.test.ts +122 -0
  76. package/src/__tests__/diagramLayout.test.ts +134 -0
  77. package/src/__tests__/drawing.test.ts +109 -0
  78. package/src/__tests__/drawingBlock.test.ts +124 -0
  79. package/src/__tests__/drawingLayout.test.ts +171 -0
  80. package/src/__tests__/geohash.test.ts +6 -5
  81. package/src/__tests__/getLayers.test.ts +6 -2
  82. package/src/__tests__/getLayersFallback.test.ts +103 -0
  83. package/src/__tests__/imageEditExportSvg.test.ts +70 -0
  84. package/src/__tests__/imageEditVersions.test.ts +72 -0
  85. package/src/__tests__/inlineIconMarker.test.ts +36 -0
  86. package/src/__tests__/layoutBlock.test.ts +83 -0
  87. package/src/__tests__/layoutLayout.test.ts +169 -0
  88. package/src/__tests__/markdown.test.ts +23 -0
  89. package/src/__tests__/markdownSanitize.test.ts +64 -0
  90. package/src/__tests__/markdownToDoc.test.ts +223 -2
  91. package/src/__tests__/mediaAnnotations.test.ts +64 -0
  92. package/src/__tests__/mediaSchedule.test.ts +118 -0
  93. package/src/__tests__/pandocAttrParse.test.ts +187 -0
  94. package/src/__tests__/resolveDocTheme.test.ts +55 -0
  95. package/src/__tests__/rootExports.test.ts +43 -0
  96. package/src/__tests__/shapeGeometry.test.ts +89 -0
  97. package/src/__tests__/shapeVocabulary.test.ts +133 -0
  98. package/src/__tests__/structuredData.test.ts +179 -0
  99. package/src/__tests__/templateAnnotationParse.test.ts +108 -0
  100. package/src/__tests__/templateMetadata.test.ts +21 -0
  101. package/src/__tests__/templates.test.ts +145 -4
  102. package/src/__tests__/themeCompile.test.ts +42 -0
  103. package/src/__tests__/themeValidator.test.ts +6 -0
  104. package/src/__tests__/transformV2.test.ts +137 -0
  105. package/src/__tests__/transitionNormalize.test.ts +61 -0
  106. package/src/__tests__/validateDoc.test.ts +100 -0
  107. package/src/doc/customTemplatesFrontmatter.ts +308 -0
  108. package/src/doc/customThemesFrontmatter.ts +90 -0
  109. package/src/doc/docToMarkdown.ts +73 -4
  110. package/src/doc/getLayers.ts +40 -17
  111. package/src/doc/index.ts +35 -1
  112. package/src/doc/markdownToDoc.ts +333 -12
  113. package/src/doc/mediaAnnotations.ts +118 -0
  114. package/src/doc/resolveDocTheme.ts +55 -0
  115. package/src/doc/structuredData.ts +230 -0
  116. package/src/doc/templateInputs.ts +240 -0
  117. package/src/doc/templates/__tests__/customTemplate.test.ts +151 -0
  118. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +110 -0
  119. package/src/doc/templates/accentImage.ts +30 -6
  120. package/src/doc/templates/captionUtils.ts +23 -0
  121. package/src/doc/templates/comparisonBar.ts +26 -18
  122. package/src/doc/templates/coverBlock.ts +7 -4
  123. package/src/doc/templates/customTemplate.ts +45 -0
  124. package/src/doc/templates/dataTable.ts +37 -19
  125. package/src/doc/templates/dateEvent.ts +41 -20
  126. package/src/doc/templates/definitionCard.ts +26 -18
  127. package/src/doc/templates/diagramBlock.ts +204 -0
  128. package/src/doc/templates/diagramLayout.ts +159 -0
  129. package/src/doc/templates/drawingBlock.ts +325 -0
  130. package/src/doc/templates/drawingLayout.ts +539 -0
  131. package/src/doc/templates/factCard.ts +51 -25
  132. package/src/doc/templates/fallbackBlock.ts +123 -0
  133. package/src/doc/templates/featureBlock.ts +20 -13
  134. package/src/doc/templates/fullBleedQuote.ts +18 -8
  135. package/src/doc/templates/imageWithCaption.ts +22 -9
  136. package/src/doc/templates/index.ts +215 -46
  137. package/src/doc/templates/layoutBlock.ts +43 -0
  138. package/src/doc/templates/layoutLayout.ts +243 -0
  139. package/src/doc/templates/listBlock.ts +56 -30
  140. package/src/doc/templates/mapBlock.ts +15 -12
  141. package/src/doc/templates/metadata.ts +120 -0
  142. package/src/doc/templates/persistentLayers.ts +129 -11
  143. package/src/doc/templates/photoGrid.ts +23 -12
  144. package/src/doc/templates/pullQuote.ts +30 -12
  145. package/src/doc/templates/quoteBlock.ts +54 -29
  146. package/src/doc/templates/sectionHeader.ts +25 -11
  147. package/src/doc/templates/statHighlight.ts +39 -22
  148. package/src/doc/templates/titleBlock.ts +59 -21
  149. package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +221 -0
  150. package/src/doc/templates/tokens/resolveTokens.ts +0 -0
  151. package/src/doc/templates/twoColumn.ts +48 -30
  152. package/src/doc/templates/videoPullQuote.ts +22 -12
  153. package/src/doc/templates/videoWithCaption.ts +13 -8
  154. package/src/doc/utils/animationUtils.ts +267 -3
  155. package/src/doc/utils/applyRenderStyle.ts +113 -0
  156. package/src/doc/utils/imageTreatment.ts +70 -0
  157. package/src/doc/utils/shapeGeometry.ts +464 -0
  158. package/src/doc/utils/themeUtils.ts +75 -1
  159. package/src/doc/validate.ts +476 -0
  160. package/src/generate/slideshowGenerator.ts +7 -0
  161. package/src/icons/index.ts +8 -0
  162. package/src/icons/inlineIconMarker.ts +73 -0
  163. package/src/imageEdit/export.ts +85 -2
  164. package/src/imageEdit/index.ts +1 -0
  165. package/src/imageEdit/persistence.ts +51 -0
  166. package/src/index.ts +2 -0
  167. package/src/markdown/annotationCoercion.ts +295 -0
  168. package/src/markdown/attrTokens.ts +222 -0
  169. package/src/markdown/convert.ts +229 -26
  170. package/src/markdown/index.ts +36 -0
  171. package/src/markdown/sanitize.ts +298 -0
  172. package/src/markdown/stringify.ts +84 -3
  173. package/src/markdown/types.ts +66 -0
  174. package/src/markdown/utils.ts +49 -1
  175. package/src/recommend/templates.ts +24 -0
  176. package/src/schemas/BlockTemplates.ts +133 -4
  177. package/src/schemas/CustomTemplates.ts +74 -0
  178. package/src/schemas/Doc.ts +353 -29
  179. package/src/schemas/ImageEditDoc.ts +11 -4
  180. package/src/schemas/Media.ts +169 -0
  181. package/src/schemas/Theme.ts +23 -1
  182. package/src/schemas/Transitions.ts +224 -0
  183. package/src/schemas/colorUtils.ts +33 -0
  184. package/src/schemas/fontStacks.ts +5 -2
  185. package/src/schemas/index.ts +3 -0
  186. package/src/schemas/themeCompile.ts +23 -4
  187. package/src/schemas/themeValidator.ts +49 -11
  188. package/src/schemas/themes/cinematic.json +69 -12
  189. package/src/schemas/themes/documentary.json +58 -11
  190. package/src/schemas/themes/gezellig.json +60 -11
  191. package/src/schemas/themes/magazine.json +54 -9
  192. package/src/schemas/themes/morning-light.json +52 -9
  193. package/src/schemas/themes/standard-dark.json +48 -13
  194. package/src/schemas/themes/standard.json +44 -12
  195. package/src/schemas/themes/tech-dark.json +65 -12
  196. package/src/spatial/Geohash.ts +52 -21
  197. package/src/transform/applyTransform.ts +43 -4
  198. package/src/transform/index.ts +1 -0
  199. package/src/transform/registry.ts +44 -13
  200. package/src/transform/styles/dataDriven.ts +2 -1
  201. package/src/transform/styles/documentary.ts +2 -1
  202. package/src/transform/styles/magazine.ts +3 -1
  203. package/src/transform/styles/minimal.ts +2 -1
  204. package/src/transform/styles/narrative.ts +3 -1
  205. package/src/transform/templateSelector.ts +87 -11
  206. package/src/transform/types.ts +35 -2
  207. package/dist/chunk-3K5OG6KI.js.map +0 -1
  208. package/dist/chunk-57CVQCFX.js.map +0 -1
  209. package/dist/chunk-5WFRKURX.js.map +0 -1
  210. package/dist/chunk-7UDSRZKG.js.map +0 -1
  211. package/dist/chunk-B4EEON3N.js.map +0 -1
  212. package/dist/chunk-H3AXU4MJ.js.map +0 -1
  213. package/dist/chunk-KSWJR66U.js +0 -3706
  214. package/dist/chunk-KSWJR66U.js.map +0 -1
  215. package/dist/chunk-MYIH7FWD.js.map +0 -1
  216. package/dist/chunk-ZTX4PFFT.js.map +0 -1
@@ -10,8 +10,13 @@
10
10
 
11
11
  import type { Layer } from '../../schemas/Doc.js';
12
12
  import type { ListBlockInput, TemplateContext } from '../../schemas/BlockTemplates.js';
13
- import { scaledFontSize } from '../../schemas/BlockTemplates.js';
14
- import { getThemeFont } from '../utils/themeUtils.js';
13
+ import {
14
+ getThemeFont,
15
+ shouldUseShadow,
16
+ themedEntrance,
17
+ themedFontSize,
18
+ themedImageTreatment,
19
+ } from '../utils/themeUtils.js';
15
20
  import { createAccentLayers, getAccentLayout, adjustY, DEFAULT_LAYOUT } from './accentImage.js';
16
21
 
17
22
  export function listBlock(input: ListBlockInput, context: TemplateContext): Layer[] {
@@ -27,8 +32,8 @@ export function listBlock(input: ListBlockInput, context: TemplateContext): Laye
27
32
  // Get layout adjustments if accent image is present
28
33
  const accentLayout = accentImage ? getAccentLayout(accentImage.position) : DEFAULT_LAYOUT;
29
34
 
30
- const titleFontSize = scaledFontSize(44, context, true);
31
- const itemFontSize = scaledFontSize(34, context, false);
35
+ const titleFontSize = themedFontSize(44, context, true);
36
+ const itemFontSize = themedFontSize(34, context, false);
32
37
 
33
38
  const layers: Layer[] = [
34
39
  // Background — gradient
@@ -45,11 +50,27 @@ export function listBlock(input: ListBlockInput, context: TemplateContext): Laye
45
50
 
46
51
  // Add accent image layers
47
52
  if (accentImage) {
48
- layers.push(...createAccentLayers(accentImage, input.id));
53
+ layers.push(
54
+ ...createAccentLayers(
55
+ accentImage,
56
+ input.id,
57
+ themedImageTreatment(context, input.imageTreatment),
58
+ ),
59
+ );
49
60
  }
50
61
 
62
+ // Left edge of the text column — derived from the center+width pair so
63
+ // the title and items share one left axis instead of a centered title
64
+ // floating over a left-aligned column. Falls back to a safe 8% if the
65
+ // layout strings ever turn out unparseable (they're authored, but
66
+ // defensive against future edits to the accent-layout types).
67
+ const centerX = parseFloat(accentLayout.textCenterX);
68
+ const widthPct = parseFloat(accentLayout.textWidth);
69
+ const leftX =
70
+ Number.isFinite(centerX) && Number.isFinite(widthPct) ? `${centerX - widthPct / 2}%` : '8%';
71
+
51
72
  // Title if provided
52
- const startY = title ? 30 : 22;
73
+ const startY = title ? 34 : 26;
53
74
  if (title) {
54
75
  layers.push({
55
76
  type: 'text',
@@ -61,35 +82,36 @@ export function listBlock(input: ListBlockInput, context: TemplateContext): Laye
61
82
  fontFamily: getThemeFont(context, 'title'),
62
83
  fontWeight: 'bold',
63
84
  color: theme.colors.text,
64
- textAlign: 'center',
65
- shadow: !!accentImage,
85
+ textAlign: 'left',
86
+ shadow: shouldUseShadow(context),
66
87
  },
67
88
  },
68
89
  position: {
69
- x: accentLayout.textCenterX,
70
- y: adjustY('16%', accentLayout),
71
- anchor: 'center',
90
+ x: leftX,
91
+ y: adjustY('20%', accentLayout),
92
+ width: accentLayout.textWidth,
72
93
  },
73
- animation: { type: 'fadeIn', duration: 1 },
94
+ animation: themedEntrance(context, 'text', { type: 'fadeIn', duration: 1 }),
74
95
  });
75
96
  }
76
97
 
77
- // Left edge of the text column derived from the center+width pair so
78
- // items sit flush with the column's left margin instead of being
79
- // centered. Falls back to a safe 8% if the layout strings ever turn
80
- // out unparseable (they're authored, but defensive against future
81
- // edits to the accent-layout types).
82
- const centerX = parseFloat(accentLayout.textCenterX);
83
- const widthPct = parseFloat(accentLayout.textWidth);
84
- const leftX =
85
- Number.isFinite(centerX) && Number.isFinite(widthPct) ? `${centerX - widthPct / 2}%` : '8%';
86
-
87
- // Calculate vertical spacing for items. We keep the available band
88
- // (startY endY) but use a tighter line-height (1.2) so wrapped
89
- // items don't bleed into the next entry as aggressively as the old
90
- // 1.4 value did.
91
- const endY = 80;
92
- const spacing = items.length > 1 ? (endY - startY) / (items.length - 1) : 0;
98
+ // Stack items with a fixed compact gap rather than stretching them
99
+ // across the available band. Distributing items across (startY 80%)
100
+ // left big vertical gaps for short lists and made the slide read as a
101
+ // sparse menu instead of a tight enumeration; conversely a bare
102
+ // line-height gap read as a cramped paragraph — 18px of air keeps each
103
+ // entry its own line without breaking the group.
104
+ //
105
+ // Spacing = item line-height (34px base × 1.2) + 18px gap, expressed
106
+ // as % of the 1080px design canvas (~5.4%). Wrapped items push the
107
+ // next entry down via their own line-height, so this sets the
108
+ // minimum baseline-to-baseline distance for unwrapped items.
109
+ const LIST_ITEM_BASE_PX = 34;
110
+ const LIST_ITEM_LINE_HEIGHT = 1.2;
111
+ const LIST_ITEM_GAP_PX = 18;
112
+ const DESIGN_HEIGHT_PX = 1080;
113
+ const spacing =
114
+ ((LIST_ITEM_BASE_PX * LIST_ITEM_LINE_HEIGHT + LIST_ITEM_GAP_PX) / DESIGN_HEIGHT_PX) * 100;
93
115
 
94
116
  // List items with staggered animation
95
117
  for (let i = 0; i < items.length; i++) {
@@ -107,7 +129,7 @@ export function listBlock(input: ListBlockInput, context: TemplateContext): Laye
107
129
  color: theme.colors.text,
108
130
  textAlign: 'left',
109
131
  lineHeight: 1.2,
110
- shadow: !!accentImage,
132
+ shadow: shouldUseShadow(context),
111
133
  },
112
134
  },
113
135
  position: {
@@ -115,7 +137,11 @@ export function listBlock(input: ListBlockInput, context: TemplateContext): Laye
115
137
  y: adjustY(`${y}%`, accentLayout),
116
138
  width: accentLayout.textWidth,
117
139
  },
118
- animation: { type: 'fadeIn', duration: 0.8, delay: 0.3 + 0.3 * i },
140
+ animation: themedEntrance(context, 'text', {
141
+ type: 'fadeIn',
142
+ duration: 0.8,
143
+ delay: 0.3 + 0.3 * i,
144
+ }),
119
145
  });
120
146
  }
121
147
 
@@ -14,8 +14,8 @@
14
14
 
15
15
  import type { Layer } from '../../schemas/Doc.js';
16
16
  import type { MapBlockInput, TemplateContext } from '../../schemas/BlockTemplates.js';
17
- import { scaledFontSize } from '../../schemas/BlockTemplates.js';
18
- import { getThemeFont } from '../utils/themeUtils.js';
17
+ import { getThemeFont, shouldUseShadow, themedFontSize } from '../utils/themeUtils.js';
18
+ import { withAlpha } from '../../schemas/colorUtils.js';
19
19
  import { mapAmbientMotion } from './accentImage.js';
20
20
 
21
21
  export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[] {
@@ -32,8 +32,8 @@ export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[
32
32
  const { theme, layout } = context;
33
33
 
34
34
  // Scale font sizes for viewport
35
- const titleFontSize = scaledFontSize(64, context, true);
36
- const captionFontSize = scaledFontSize(32, context, false);
35
+ const titleFontSize = themedFontSize(64, context, true);
36
+ const captionFontSize = themedFontSize(32, context, false);
37
37
 
38
38
  // Determine animation based on ambientMotion setting
39
39
  const mapAnimation = mapAmbientMotion(ambientMotion);
@@ -56,17 +56,21 @@ export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[
56
56
  },
57
57
  ];
58
58
 
59
+ // Overlay bands are tinted from the theme background so the theme text
60
+ // color on them stays readable in light and dark themes alike; they
61
+ // fade out toward the map so the band doesn't read as a hard seam.
62
+ const bg = theme.colors.background;
63
+
59
64
  // Add title overlay if provided
60
65
  if (title) {
61
- // Gradient overlay at top for title readability
62
66
  layers.push({
63
67
  type: 'shape',
64
68
  id: 'title-overlay',
65
69
  content: {
66
70
  shape: 'rect',
67
- fill: 'rgba(0,0,0,0.6)',
71
+ fill: `linear-gradient(180deg, ${withAlpha(bg, 0.85)} 0%, ${withAlpha(bg, 0.6)} 70%, ${withAlpha(bg, 0)} 100%)`,
68
72
  },
69
- position: { x: 0, y: 0, width: '100%', height: '18%' },
73
+ position: { x: 0, y: 0, width: '100%', height: '20%' },
70
74
  });
71
75
 
72
76
  // Title text - positioned at top of slide
@@ -81,7 +85,7 @@ export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[
81
85
  fontWeight: 'bold',
82
86
  color: theme.colors.text,
83
87
  textAlign: 'center',
84
- shadow: true,
88
+ shadow: shouldUseShadow(context),
85
89
  },
86
90
  },
87
91
  position: {
@@ -96,15 +100,14 @@ export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[
96
100
 
97
101
  // Add caption if provided
98
102
  if (caption) {
99
- // Gradient overlay at bottom for caption readability
100
103
  layers.push({
101
104
  type: 'shape',
102
105
  id: 'caption-overlay',
103
106
  content: {
104
107
  shape: 'rect',
105
- fill: 'rgba(0,0,0,0.6)',
108
+ fill: `linear-gradient(0deg, ${withAlpha(bg, 0.85)} 0%, ${withAlpha(bg, 0.6)} 70%, ${withAlpha(bg, 0)} 100%)`,
106
109
  },
107
- position: { x: 0, y: '82%', width: '100%', height: '18%' },
110
+ position: { x: 0, y: '80%', width: '100%', height: '20%' },
108
111
  });
109
112
 
110
113
  // Caption text
@@ -118,7 +121,7 @@ export function mapBlock(input: MapBlockInput, context: TemplateContext): Layer[
118
121
  fontFamily: getThemeFont(context, 'body'),
119
122
  color: theme.colors.text,
120
123
  textAlign: 'center',
121
- shadow: true,
124
+ shadow: shouldUseShadow(context),
122
125
  },
123
126
  },
124
127
  position: {
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Canonical, framework-free UI metadata for every built-in block template.
3
+ *
4
+ * This is the single source of truth for the human-readable label and the
5
+ * one-sentence description of each template id in {@link templateRegistry}.
6
+ * The editor's `TemplatePicker` renders its gallery from this map (joining
7
+ * each id with a locally-defined SVG icon, which can't live in this
8
+ * framework-free package), so a template only has to be added here and to
9
+ * `templateRegistry` for it to surface in the editor.
10
+ *
11
+ * `templateMetadata.test.ts` asserts this map and `templateRegistry` stay
12
+ * exactly 1:1 — adding a template to one without the other fails the build.
13
+ *
14
+ * Order matters: pickers iterate this object's insertion order, so it doubles
15
+ * as the canonical gallery order.
16
+ */
17
+
18
+ export interface TemplateMetadata {
19
+ /** Human-readable label shown in pickers (e.g. "Image with Caption"). */
20
+ label: string;
21
+ /** One-sentence description of when to reach for this template. */
22
+ description: string;
23
+ }
24
+
25
+ export const TEMPLATE_METADATA: Record<string, TemplateMetadata> = {
26
+ title: {
27
+ label: 'Title',
28
+ description: 'A bold opening slide with large title text, perfect for covers and chapters.',
29
+ },
30
+ sectionHeader: {
31
+ label: 'Section Header',
32
+ description: 'A clean section break with a prominent title and optional subtitle.',
33
+ },
34
+ statHighlight: {
35
+ label: 'Stat Highlight',
36
+ description: 'Showcases a single key number or metric with supporting context.',
37
+ },
38
+ quote: {
39
+ label: 'Quote',
40
+ description: 'Displays a stylized pull quote with decorative marks and attribution.',
41
+ },
42
+ factCard: {
43
+ label: 'Fact Card',
44
+ description: 'Presents a focused fact or insight with a labeled header and body text.',
45
+ },
46
+ twoColumn: {
47
+ label: 'Two Column',
48
+ description: 'Divides the slide into two equal side-by-side content columns.',
49
+ },
50
+ dateEvent: {
51
+ label: 'Date Event',
52
+ description: 'Highlights a date-based event or milestone with a prominent date display.',
53
+ },
54
+ imageWithCaption: {
55
+ label: 'Image with Caption',
56
+ description: 'Displays a full-bleed image with an optional caption below.',
57
+ },
58
+ leftFeature: {
59
+ label: 'Left Feature',
60
+ description: 'Image on the left, title and body text stacked on the right.',
61
+ },
62
+ rightFeature: {
63
+ label: 'Right Feature',
64
+ description: 'Image on the right, title and body text stacked on the left.',
65
+ },
66
+ map: {
67
+ label: 'Map',
68
+ description: 'Embeds an interactive map centered on a geographic location.',
69
+ },
70
+ fullBleedQuote: {
71
+ label: 'Full Bleed Quote',
72
+ description: 'A full-width quote that spans the entire slide for maximum impact.',
73
+ },
74
+ list: {
75
+ label: 'List',
76
+ description: 'Renders a bulleted or numbered list in a clean, card-style layout.',
77
+ },
78
+ photoGrid: {
79
+ label: 'Photo Grid',
80
+ description: 'Arranges multiple photos in a 2×2 or 3×3 mosaic grid.',
81
+ },
82
+ definitionCard: {
83
+ label: 'Definition Card',
84
+ description: 'Shows a term and its definition in a structured, dictionary-style card.',
85
+ },
86
+ comparisonBar: {
87
+ label: 'Comparison Bar',
88
+ description: 'Visualizes two or more values side-by-side with labeled horizontal bars.',
89
+ },
90
+ pullQuote: {
91
+ label: 'Pull Quote',
92
+ description: 'A stylized pull quote with large decorative marks and centered text.',
93
+ },
94
+ videoWithCaption: {
95
+ label: 'Video with Caption',
96
+ description: 'Embeds a video player with an optional caption below.',
97
+ },
98
+ videoPullQuote: {
99
+ label: 'Video Pull Quote',
100
+ description: 'Combines a video panel with a highlighted pull quote side-by-side.',
101
+ },
102
+ dataTable: {
103
+ label: 'Data Table',
104
+ description: 'Renders tabular data in a clean, styled table with a header row.',
105
+ },
106
+ diagram: {
107
+ label: 'Diagram',
108
+ description:
109
+ 'Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.',
110
+ },
111
+ layout: {
112
+ label: 'Layout',
113
+ description:
114
+ "Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.",
115
+ },
116
+ drawing: {
117
+ label: 'Drawing',
118
+ description: 'Free-form sketches — draw shapes, paths, and text directly on a 2D surface.',
119
+ },
120
+ };
@@ -20,12 +20,15 @@ import type {
20
20
  GradientBackgroundConfig,
21
21
  ImageBackgroundConfig,
22
22
  PatternBackgroundConfig,
23
+ VignetteConfig,
24
+ AmbientGradientConfig,
23
25
  TitleCaptionConfig,
24
26
  CornerBrandingConfig,
25
27
  ProgressIndicatorConfig,
26
28
  } from '../../schemas/BlockTemplates.js';
27
29
  import type { Theme } from '../../schemas/Theme.js';
28
30
  import { isPersistentLayerTemplate } from '../../schemas/BlockTemplates.js';
31
+ import { oklchDarken, withAlpha } from '../../schemas/colorUtils.js';
29
32
 
30
33
  // ============================================
31
34
  // Gradient Presets
@@ -35,9 +38,11 @@ const GRADIENT_PRESETS: Record<string, string> = {
35
38
  'dark-vignette':
36
39
  'radial-gradient(ellipse at center, rgba(26,32,44,0.8) 0%, rgba(0,0,0,0.95) 100%)',
37
40
  'radial-dark': 'radial-gradient(ellipse at center, #1a202c 0%, #000000 100%)',
38
- 'warm-sunset': 'linear-gradient(135deg, rgba(124,58,48,0.9) 0%, rgba(26,32,44,0.95) 100%)',
41
+ // Warm presets deepen within their own hue — ending in the shared navy
42
+ // made warm themes drift cold halfway down the frame.
43
+ 'warm-sunset': 'linear-gradient(135deg, rgba(124,58,48,0.9) 0%, rgba(46,20,16,0.95) 100%)',
39
44
  'cool-blue': 'linear-gradient(135deg, rgba(26,54,93,0.9) 0%, rgba(26,32,44,0.95) 100%)',
40
- 'earth-tones': 'linear-gradient(135deg, rgba(68,51,34,0.9) 0%, rgba(26,32,44,0.95) 100%)',
45
+ 'earth-tones': 'linear-gradient(135deg, rgba(68,51,34,0.9) 0%, rgba(30,22,15,0.95) 100%)',
41
46
  };
42
47
 
43
48
  // ============================================
@@ -84,7 +89,9 @@ function expandImageBackground(config: ImageBackgroundConfig): Layer[] {
84
89
  const layers: Layer[] = [];
85
90
  const opacity = config.opacity ?? 0.4;
86
91
 
87
- // Base image layer
92
+ // Base image layer. `blur` softens the photo into an atmosphere layer
93
+ // (the ImageLayer renderer over-scans blurred images so soft edges never
94
+ // reveal the frame).
88
95
  const imageLayer: Layer = {
89
96
  type: 'image',
90
97
  id: 'persistent-bg-image',
@@ -92,6 +99,7 @@ function expandImageBackground(config: ImageBackgroundConfig): Layer[] {
92
99
  src: config.src,
93
100
  alt: 'Background',
94
101
  fit: 'cover',
102
+ ...(config.blur != null && config.blur > 0 ? { blur: config.blur } : {}),
95
103
  },
96
104
  position: { x: 0, y: 0, width: '100%', height: '100%' },
97
105
  animation: config.ambientMotion
@@ -122,22 +130,79 @@ function expandImageBackground(config: ImageBackgroundConfig): Layer[] {
122
130
  * Expand a pattern background config to a Layer.
123
131
  */
124
132
  function expandPatternBackground(config: PatternBackgroundConfig): Layer {
125
- const opacity = config.opacity ?? 0.1;
126
- const color = config.color ?? `rgba(255,255,255,${opacity})`;
133
+ // 'noise' is film grain: a full-bleed rect whose paint is replaced by a
134
+ // static feTurbulence field clipped to the rect (see ShapeFilter).
135
+ if (config.pattern === 'noise') {
136
+ return {
137
+ type: 'shape',
138
+ id: 'persistent-grain',
139
+ content: {
140
+ shape: 'rect',
141
+ fill: '#000000',
142
+ filter: { type: 'noise', opacity: config.opacity ?? 0.05 },
143
+ },
144
+ position: { x: 0, y: 0, width: '100%', height: '100%' },
145
+ };
146
+ }
127
147
 
128
- // Pattern as SVG data URI for rect patterns
129
- // For simplicity, use a solid subtle color with reduced opacity
148
+ // dots / grid / diagonal render as native SVG <pattern> fills.
149
+ const opacity = config.opacity ?? 0.06;
130
150
  return {
131
151
  type: 'shape',
132
152
  id: 'persistent-bg-pattern',
133
153
  content: {
134
154
  shape: 'rect',
135
- fill: color,
155
+ pattern: {
156
+ kind: config.pattern,
157
+ color: config.color ?? '#ffffff',
158
+ size: Math.round(24 * (config.scale ?? 1)),
159
+ opacity,
160
+ },
136
161
  },
137
162
  position: { x: 0, y: 0, width: '100%', height: '100%' },
138
163
  };
139
164
  }
140
165
 
166
+ /**
167
+ * Expand a vignette config: transparent center darkening toward the frame
168
+ * edges. Rides the CSS-gradient rect path in the renderer.
169
+ */
170
+ function expandVignette(config: VignetteConfig): Layer {
171
+ const strength = Math.max(0, Math.min(1, config.strength ?? 0.3));
172
+ const color = config.color ?? '#000000';
173
+ const edge = withAlpha(color, strength);
174
+ const clear = withAlpha(color, 0);
175
+ return {
176
+ type: 'shape',
177
+ id: 'persistent-vignette',
178
+ content: {
179
+ shape: 'rect',
180
+ fill: `radial-gradient(ellipse at center, ${clear} 55%, ${edge} 100%)`,
181
+ },
182
+ position: { x: 0, y: 0, width: '100%', height: '100%' },
183
+ };
184
+ }
185
+
186
+ /**
187
+ * Expand an ambient drifting gradient: an oversized surface gradient with
188
+ * a very slow Ken Burns loop. Deterministic (no randomness).
189
+ */
190
+ function expandAmbientGradient(config: AmbientGradientConfig, theme?: Theme): Layer {
191
+ const from = config.from ?? theme?.colors.backgroundLight ?? '#1a202c';
192
+ const to = config.to ?? (theme ? oklchDarken(theme.colors.background, 0.04) : '#0f141d');
193
+ return {
194
+ type: 'shape',
195
+ id: 'persistent-ambient-gradient',
196
+ content: {
197
+ shape: 'rect',
198
+ fill: `linear-gradient(150deg, ${from} 0%, ${to} 100%)`,
199
+ },
200
+ // Oversized so the slow pan never reveals the frame edge.
201
+ position: { x: '-5%', y: '-5%', width: '110%', height: '110%' },
202
+ animation: { type: 'slowZoom', panDirection: 'left', duration: config.duration ?? 40 },
203
+ };
204
+ }
205
+
141
206
  // ============================================
142
207
  // Overlay Layer Expansion
143
208
  // ============================================
@@ -349,7 +414,7 @@ function expandProgressIndicator(config: ProgressIndicatorConfig): Layer {
349
414
  /**
350
415
  * Expand a single persistent layer (template or raw) to raw Layer(s).
351
416
  */
352
- export function expandPersistentLayer(layer: PersistentLayer): Layer[] {
417
+ export function expandPersistentLayer(layer: PersistentLayer, theme?: Theme): Layer[] {
353
418
  // If already a raw Layer, return as-is
354
419
  if (!isPersistentLayerTemplate(layer)) {
355
420
  return [layer as Layer];
@@ -367,6 +432,10 @@ export function expandPersistentLayer(layer: PersistentLayer): Layer[] {
367
432
  return expandImageBackground(config);
368
433
  case 'patternBackground':
369
434
  return [expandPatternBackground(config)];
435
+ case 'vignette':
436
+ return [expandVignette(config)];
437
+ case 'ambientGradient':
438
+ return [expandAmbientGradient(config, theme)];
370
439
  case 'titleCaption':
371
440
  return expandTitleCaption(config);
372
441
  case 'cornerBranding':
@@ -382,13 +451,19 @@ export function expandPersistentLayer(layer: PersistentLayer): Layer[] {
382
451
  /**
383
452
  * Expand all persistent layers in a config to raw Layer arrays.
384
453
  */
385
- export function expandPersistentLayers(layers: PersistentLayer[] | undefined): Layer[] {
454
+ export function expandPersistentLayers(
455
+ layers: PersistentLayer[] | undefined,
456
+ theme?: Theme,
457
+ ): Layer[] {
386
458
  if (!layers || layers.length === 0) {
387
459
  return [];
388
460
  }
389
461
 
390
462
  // Use reduce+concat instead of flatMap for Coherent GT compatibility (ES2017)
391
- return layers.reduce<Layer[]>((acc, layer) => acc.concat(expandPersistentLayer(layer)), []);
463
+ return layers.reduce<Layer[]>(
464
+ (acc, layer) => acc.concat(expandPersistentLayer(layer, theme)),
465
+ [],
466
+ );
392
467
  }
393
468
 
394
469
  // ============================================
@@ -520,3 +595,46 @@ export function getDocStyleConfig(
520
595
  export function getPersistentLayersFromTheme(theme: Theme): PersistentLayerConfig {
521
596
  return theme.persistentLayers ?? {};
522
597
  }
598
+
599
+ /**
600
+ * Resolve the effective persistent-layer config for a doc: the doc's own
601
+ * config wins **wholesale** when present; only docs with no persistent
602
+ * layers inherit the theme's.
603
+ *
604
+ * Doc-wins-wholesale (rather than merging) protects pre-baked documents
605
+ * that carry their own background/branding layers — merging a theme's
606
+ * atmosphere on top of those would double up backgrounds and stack
607
+ * overlays the doc author never saw.
608
+ */
609
+ export function resolvePersistentLayers(
610
+ doc: { persistentLayers?: PersistentLayerConfig },
611
+ theme: Theme,
612
+ ): PersistentLayerConfig | undefined {
613
+ const docConfig = doc.persistentLayers;
614
+ const hasDocLayers =
615
+ !!docConfig &&
616
+ ((docConfig.bottomLayers?.length ?? 0) > 0 || (docConfig.topLayers?.length ?? 0) > 0);
617
+ if (hasDocLayers) return docConfig;
618
+ const themeConfig = theme.persistentLayers;
619
+ const hasThemeLayers =
620
+ !!themeConfig &&
621
+ ((themeConfig.bottomLayers?.length ?? 0) > 0 || (themeConfig.topLayers?.length ?? 0) > 0);
622
+ return hasThemeLayers ? themeConfig : docConfig;
623
+ }
624
+
625
+ /**
626
+ * Compose a block's layers between pre-expanded persistent bottom/top
627
+ * layers, honoring the per-block `useBottomLayer` / `useTopLayer` opt-outs.
628
+ * Single shared implementation for `expandDocBlocks` and `getLayers`.
629
+ */
630
+ export function wrapWithPersistentLayers(
631
+ layers: Layer[],
632
+ block: { useBottomLayer?: boolean; useTopLayer?: boolean },
633
+ bottomLayers: Layer[],
634
+ topLayers: Layer[],
635
+ ): Layer[] {
636
+ if (bottomLayers.length === 0 && topLayers.length === 0) return layers;
637
+ const useBottom = block.useBottomLayer !== false;
638
+ const useTop = block.useTopLayer !== false;
639
+ return [...(useBottom ? bottomLayers : []), ...layers, ...(useTop ? topLayers : [])];
640
+ }
@@ -17,12 +17,17 @@
17
17
 
18
18
  import type { Layer } from '../../schemas/Doc.js';
19
19
  import type { PhotoGridInput, TemplateContext } from '../../schemas/BlockTemplates.js';
20
- import { scaledFontSize } from '../../schemas/BlockTemplates.js';
21
- import { getThemeFont } from '../utils/themeUtils.js';
20
+ import {
21
+ getThemeFont,
22
+ shouldUseShadow,
23
+ themedFontSize,
24
+ themedImageTreatment,
25
+ } from '../utils/themeUtils.js';
26
+ import { withAlpha } from '../../schemas/colorUtils.js';
22
27
  import { cleanCaption } from './captionUtils.js';
23
28
 
24
29
  /** Gap between images as percentage */
25
- const GAP = 0.5;
30
+ const GAP = 1.2;
26
31
 
27
32
  export function photoGrid(input: PhotoGridInput, context: TemplateContext): Layer[] {
28
33
  const { images, caption: rawCaption, ambientMotion } = input;
@@ -33,24 +38,27 @@ export function photoGrid(input: PhotoGridInput, context: TemplateContext): Laye
33
38
  const caption = rawCaption ? cleanCaption(rawCaption) : rawCaption;
34
39
  const { theme, layout } = context;
35
40
 
41
+ const treatment = themedImageTreatment(context, input.imageTreatment);
42
+
36
43
  const layers: Layer[] = [
37
- // Black background (visible in gaps between images)
44
+ // Theme surface background (visible in gaps between images)
38
45
  {
39
46
  type: 'shape',
40
47
  id: 'bg',
41
- content: { shape: 'rect', fill: '#000000' },
48
+ content: { shape: 'rect', fill: theme.colors.background },
42
49
  position: { x: 0, y: 0, width: '100%', height: '100%' },
43
50
  },
44
51
  ];
45
52
 
46
- // Reserve bottom space for caption — more room in landscape for larger text
47
- const captionHeight = caption ? (layout.stackColumns ? 18 : 22) : 0;
53
+ // Reserve bottom space for caption — sized to the caption's one-to-two
54
+ // lines rather than a fixed fifth of the block (which left a dead band).
55
+ const captionHeight = caption ? (layout.stackColumns ? 16 : 14) : 0;
48
56
  const gridHeight = 100 - captionHeight;
49
57
 
50
58
  // Generate image positions based on count; stack vertically in portrait
51
59
  const positions = getGridPositions(images.length, gridHeight, layout.stackColumns);
52
60
 
53
- const altFontSize = scaledFontSize(24, context, false);
61
+ const altFontSize = themedFontSize(24, context, false);
54
62
 
55
63
  for (let i = 0; i < Math.min(images.length, 4); i++) {
56
64
  const img = images[i];
@@ -92,6 +100,7 @@ export function photoGrid(input: PhotoGridInput, context: TemplateContext): Laye
92
100
  fit: 'cover',
93
101
  credit: img.credit,
94
102
  license: img.license,
103
+ ...(treatment ? { treatment } : {}),
95
104
  },
96
105
  position: {
97
106
  x: `${pos.x}%`,
@@ -109,14 +118,16 @@ export function photoGrid(input: PhotoGridInput, context: TemplateContext): Laye
109
118
 
110
119
  // Caption with gradient overlay
111
120
  if (caption) {
112
- const captionFontSize = scaledFontSize(layout.stackColumns ? 28 : 40, context, false);
121
+ const captionFontSize = themedFontSize(layout.stackColumns ? 28 : 32, context, false);
113
122
 
123
+ // Caption band fades from the theme surface so the theme text color
124
+ // on it always reads (a fixed black band hid dark text in light themes).
114
125
  layers.push({
115
126
  type: 'shape',
116
127
  id: 'caption-bg',
117
128
  content: {
118
129
  shape: 'rect',
119
- fill: 'linear-gradient(transparent, rgba(0,0,0,0.8))',
130
+ fill: `linear-gradient(${withAlpha(theme.colors.background, 0)}, ${withAlpha(theme.colors.background, 0.85)})`,
120
131
  },
121
132
  position: { x: 0, y: `${gridHeight - 4}%`, width: '100%', height: `${captionHeight + 4}%` },
122
133
  });
@@ -131,12 +142,12 @@ export function photoGrid(input: PhotoGridInput, context: TemplateContext): Laye
131
142
  fontFamily: getThemeFont(context, 'body'),
132
143
  color: theme.colors.text,
133
144
  textAlign: 'center',
134
- shadow: true,
145
+ shadow: shouldUseShadow(context),
135
146
  },
136
147
  },
137
148
  position: {
138
149
  x: '50%',
139
- y: `${gridHeight + (layout.stackColumns ? captionHeight / 2 : captionHeight * 0.3)}%`,
150
+ y: `${gridHeight + captionHeight / 2}%`,
140
151
  anchor: 'center',
141
152
  width: '90%',
142
153
  },