@bendyline/squisq-editor-react 1.2.1 → 1.2.2
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/PreviewPanel.d.ts +3 -8
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +4 -282
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/buildPreviewDoc.d.ts +22 -0
- package/dist/buildPreviewDoc.d.ts.map +1 -0
- package/dist/buildPreviewDoc.js +212 -0
- package/dist/buildPreviewDoc.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/PreviewPanel.tsx +5 -333
- package/src/buildPreviewDoc.ts +254 -0
- package/src/index.ts +3 -0
package/dist/PreviewPanel.d.ts
CHANGED
|
@@ -6,14 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The markdown-derived Doc (from markdownToDoc) contains hierarchical blocks
|
|
8
8
|
* with template names, heading text, and body content — but no audio or
|
|
9
|
-
* visual layers. This component bridges the gap by
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 2. Converting each block into a TemplateBlock-compatible object
|
|
13
|
-
* (mapping heading text → title, templateOverrides → template fields)
|
|
14
|
-
* 3. Synthesizing a dummy audio segment so DocPlayer's timing works
|
|
15
|
-
* (the player enters fallback-timer mode when audio can't load)
|
|
16
|
-
* 4. Passing the prepared Doc to DocPlayer for SVG-based rendering
|
|
9
|
+
* visual layers. This component bridges the gap by using buildPreviewDoc()
|
|
10
|
+
* to flatten blocks, convert them to TemplateBlock slides with interleaved
|
|
11
|
+
* images, and synthesize timing.
|
|
17
12
|
*/
|
|
18
13
|
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
19
14
|
export interface PreviewPanelProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewPanel.d.ts","sourceRoot":"","sources":["../src/PreviewPanel.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PreviewPanel.d.ts","sourceRoot":"","sources":["../src/PreviewPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKlE,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACrC;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAc,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,iBAAiB,2CA2HvF"}
|
package/dist/PreviewPanel.js
CHANGED
|
@@ -7,295 +7,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
*
|
|
8
8
|
* The markdown-derived Doc (from markdownToDoc) contains hierarchical blocks
|
|
9
9
|
* with template names, heading text, and body content — but no audio or
|
|
10
|
-
* visual layers. This component bridges the gap by
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* 2. Converting each block into a TemplateBlock-compatible object
|
|
14
|
-
* (mapping heading text → title, templateOverrides → template fields)
|
|
15
|
-
* 3. Synthesizing a dummy audio segment so DocPlayer's timing works
|
|
16
|
-
* (the player enters fallback-timer mode when audio can't load)
|
|
17
|
-
* 4. Passing the prepared Doc to DocPlayer for SVG-based rendering
|
|
10
|
+
* visual layers. This component bridges the gap by using buildPreviewDoc()
|
|
11
|
+
* to flatten blocks, convert them to TemplateBlock slides with interleaved
|
|
12
|
+
* images, and synthesize timing.
|
|
18
13
|
*/
|
|
19
14
|
import { useState, useEffect } from 'react';
|
|
20
15
|
import { DocPlayer, LinearDocView } from '@bendyline/squisq-react';
|
|
21
|
-
import { flattenBlocks } from '@bendyline/squisq/doc';
|
|
22
|
-
import { hasTemplate } from '@bendyline/squisq/doc';
|
|
23
|
-
import { extractPlainText } from '@bendyline/squisq/markdown';
|
|
24
|
-
import { getChildren } from '@bendyline/squisq/markdown';
|
|
25
16
|
import { applyTransform } from '@bendyline/squisq/transform';
|
|
26
17
|
import { resolveAudioMapping } from '@bendyline/squisq/doc';
|
|
27
18
|
import { useEditorContext } from './EditorContext';
|
|
28
19
|
import { usePreviewSettings } from './PreviewControls';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Extract plain text from an array of markdown block nodes.
|
|
32
|
-
* Walks paragraphs, blockquotes, and list items to collect all text.
|
|
33
|
-
*/
|
|
34
|
-
function extractBodyText(contents) {
|
|
35
|
-
if (!contents || contents.length === 0)
|
|
36
|
-
return '';
|
|
37
|
-
const parts = [];
|
|
38
|
-
for (const node of contents) {
|
|
39
|
-
parts.push(extractPlainText(node));
|
|
40
|
-
}
|
|
41
|
-
return parts.join('\n').trim();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Extract images from a block's markdown contents.
|
|
45
|
-
* Walks the node tree recursively to find all MarkdownImage nodes.
|
|
46
|
-
*/
|
|
47
|
-
function extractBlockImages(contents) {
|
|
48
|
-
if (!contents || contents.length === 0)
|
|
49
|
-
return [];
|
|
50
|
-
const images = [];
|
|
51
|
-
function walk(node) {
|
|
52
|
-
if ('type' in node && node.type === 'image' && 'url' in node) {
|
|
53
|
-
const img = node;
|
|
54
|
-
if (img.url) {
|
|
55
|
-
images.push({ src: img.url, alt: img.alt ?? '' });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const child of getChildren(node)) {
|
|
59
|
-
walk(child);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
for (const node of contents) {
|
|
63
|
-
walk(node);
|
|
64
|
-
}
|
|
65
|
-
return images;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Collect all unique images from an entire Doc's block tree.
|
|
69
|
-
* Walks nested children to find every image across all blocks.
|
|
70
|
-
*/
|
|
71
|
-
function collectAllDocImages(blocks) {
|
|
72
|
-
const seen = new Set();
|
|
73
|
-
const images = [];
|
|
74
|
-
function walkBlocks(blockList) {
|
|
75
|
-
for (const block of blockList) {
|
|
76
|
-
for (const img of extractBlockImages(block.contents)) {
|
|
77
|
-
if (!seen.has(img.src)) {
|
|
78
|
-
seen.add(img.src);
|
|
79
|
-
images.push(img);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (block.children) {
|
|
83
|
-
walkBlocks(block.children);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
walkBlocks(blocks);
|
|
88
|
-
return images;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Extract list items from markdown body content.
|
|
92
|
-
* Returns an array of plain text strings for each list item found.
|
|
93
|
-
*/
|
|
94
|
-
function extractListItems(contents) {
|
|
95
|
-
if (!contents)
|
|
96
|
-
return [];
|
|
97
|
-
const items = [];
|
|
98
|
-
for (const node of contents) {
|
|
99
|
-
if (node.type === 'list') {
|
|
100
|
-
for (const item of node.children) {
|
|
101
|
-
const text = extractPlainText(item).trim();
|
|
102
|
-
if (text)
|
|
103
|
-
items.push(text);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return items;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Provide sensible default fields for templates that require more than
|
|
111
|
-
* just a `title`. This prevents crashes from undefined required fields
|
|
112
|
-
* when the markdown annotations don't supply all template-specific values.
|
|
113
|
-
*/
|
|
114
|
-
function getTemplateDefaults(templateName, headingText, block) {
|
|
115
|
-
const body = extractBodyText(block.contents);
|
|
116
|
-
switch (templateName) {
|
|
117
|
-
case 'statHighlight':
|
|
118
|
-
return {
|
|
119
|
-
stat: headingText,
|
|
120
|
-
description: body || headingText,
|
|
121
|
-
};
|
|
122
|
-
case 'quoteBlock':
|
|
123
|
-
case 'fullBleedQuote':
|
|
124
|
-
case 'pullQuote':
|
|
125
|
-
return {
|
|
126
|
-
quote: body || headingText,
|
|
127
|
-
};
|
|
128
|
-
case 'factCard':
|
|
129
|
-
return {
|
|
130
|
-
fact: headingText,
|
|
131
|
-
explanation: body || headingText,
|
|
132
|
-
};
|
|
133
|
-
case 'comparisonBar':
|
|
134
|
-
return {
|
|
135
|
-
leftLabel: 'A',
|
|
136
|
-
leftValue: 60,
|
|
137
|
-
rightLabel: 'B',
|
|
138
|
-
rightValue: 40,
|
|
139
|
-
};
|
|
140
|
-
case 'listBlock':
|
|
141
|
-
return {
|
|
142
|
-
items: extractListItems(block.contents) || ['Item 1', 'Item 2', 'Item 3'],
|
|
143
|
-
};
|
|
144
|
-
case 'definitionCard':
|
|
145
|
-
return {
|
|
146
|
-
term: headingText,
|
|
147
|
-
definition: body || headingText,
|
|
148
|
-
};
|
|
149
|
-
case 'dateEvent':
|
|
150
|
-
return {
|
|
151
|
-
date: headingText,
|
|
152
|
-
description: body || headingText,
|
|
153
|
-
};
|
|
154
|
-
default:
|
|
155
|
-
return {};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Convert a markdown-derived Block into a TemplateBlock-compatible object.
|
|
160
|
-
*
|
|
161
|
-
* The block's heading text becomes `title` (works for sectionHeader,
|
|
162
|
-
* titleBlock, factCard, etc.). Any templateOverrides from annotation
|
|
163
|
-
* syntax `{[template key=value]}` are spread on top so template-specific
|
|
164
|
-
* fields (stat, quote, description, …) are available.
|
|
165
|
-
*
|
|
166
|
-
* If the requested template doesn't exist in the registry, falls back
|
|
167
|
-
* to `sectionHeader` to avoid "Unknown template" warnings.
|
|
168
|
-
*/
|
|
169
|
-
function blockToSlide(block, index) {
|
|
170
|
-
const headingText = block.sourceHeading
|
|
171
|
-
? extractPlainText(block.sourceHeading)
|
|
172
|
-
: block.title || block.id || `Slide ${index + 1}`;
|
|
173
|
-
// Validate template name — fall back to sectionHeader for unknowns
|
|
174
|
-
const requestedTemplate = block.template || 'sectionHeader';
|
|
175
|
-
const template = hasTemplate(requestedTemplate) ? requestedTemplate : 'sectionHeader';
|
|
176
|
-
// Get sensible defaults for templates that need more than just `title`
|
|
177
|
-
const defaults = getTemplateDefaults(template, headingText, block);
|
|
178
|
-
// Spread the block itself to pick up any template-specific fields
|
|
179
|
-
// placed directly on the block by applyTransform (e.g. stat, description,
|
|
180
|
-
// quote, colorScheme). These are not in templateOverrides — they live
|
|
181
|
-
// on the block object because the transform produces hybrid Block+Template
|
|
182
|
-
// objects via the timing allocator.
|
|
183
|
-
const { id: _id, startTime: _st, duration: _d, audioSegment: _as, layers: _l, transition: _tr, template: _t, title: _ti, children: _c, contents: _co, sourceHeading: _sh, templateOverrides: _to, ...extraFields } = block;
|
|
184
|
-
return {
|
|
185
|
-
id: block.id,
|
|
186
|
-
template,
|
|
187
|
-
duration: block.duration,
|
|
188
|
-
audioSegment: 0,
|
|
189
|
-
transition: index > 0 ? { type: 'fade', duration: 0.5 } : undefined,
|
|
190
|
-
// Provide heading text as title — consumed by sectionHeader, titleBlock, etc.
|
|
191
|
-
title: headingText,
|
|
192
|
-
// Template-specific defaults (safe fallbacks for required fields)
|
|
193
|
-
...defaults,
|
|
194
|
-
// Template-specific fields from transform (stat, description, quote, etc.)
|
|
195
|
-
...extraFields,
|
|
196
|
-
// Spread annotation overrides last so explicit values win
|
|
197
|
-
...block.templateOverrides,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
/** Ambient motions to rotate on image slides. */
|
|
201
|
-
const IMAGE_MOTIONS = [
|
|
202
|
-
'zoomIn',
|
|
203
|
-
'zoomOut',
|
|
204
|
-
'panLeft',
|
|
205
|
-
'panRight',
|
|
206
|
-
];
|
|
207
|
-
/**
|
|
208
|
-
* Build a player-ready Doc from the markdown-derived Doc.
|
|
209
|
-
*
|
|
210
|
-
* Flattens hierarchical blocks, converts each to a TemplateBlock-compatible
|
|
211
|
-
* slide, recalculates timing, and adds a synthetic audio segment.
|
|
212
|
-
*
|
|
213
|
-
* Images found in the markdown are used in two ways:
|
|
214
|
-
* 1. Per-block: if a block has images, its first image becomes the background
|
|
215
|
-
* (via imageWithCaption template) or an accent image on text templates.
|
|
216
|
-
* 2. Global: remaining images are interleaved as standalone image slides
|
|
217
|
-
* for visual variety.
|
|
218
|
-
*/
|
|
219
|
-
function buildPreviewDoc(doc) {
|
|
220
|
-
const flat = flattenBlocks(doc.blocks);
|
|
221
|
-
// Collect all images from the doc for global interleaving
|
|
222
|
-
const allImages = collectAllDocImages(doc.blocks);
|
|
223
|
-
// Track which images are used per-block so we can interleave the rest
|
|
224
|
-
const usedImageSrcs = new Set();
|
|
225
|
-
// First pass: convert blocks to slides, using per-block images
|
|
226
|
-
const slides = [];
|
|
227
|
-
let motionIndex = 0;
|
|
228
|
-
for (let i = 0; i < flat.length; i++) {
|
|
229
|
-
const block = flat[i];
|
|
230
|
-
const blockImages = extractBlockImages(block.contents);
|
|
231
|
-
const slide = blockToSlide(block, i);
|
|
232
|
-
// If the block has images and is using the default sectionHeader template,
|
|
233
|
-
// upgrade it to imageWithCaption so the image becomes the slide background.
|
|
234
|
-
if (blockImages.length > 0 && slide.template === 'sectionHeader') {
|
|
235
|
-
const img = blockImages[0];
|
|
236
|
-
usedImageSrcs.add(img.src);
|
|
237
|
-
slide.template = 'imageWithCaption';
|
|
238
|
-
slide.imageSrc = img.src;
|
|
239
|
-
slide.imageAlt = img.alt;
|
|
240
|
-
slide.caption = slide.title;
|
|
241
|
-
slide.captionPosition = 'bottom';
|
|
242
|
-
slide.ambientMotion = IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length];
|
|
243
|
-
}
|
|
244
|
-
else if (blockImages.length > 0) {
|
|
245
|
-
// For other templates, add the first image as an accent
|
|
246
|
-
const img = blockImages[0];
|
|
247
|
-
usedImageSrcs.add(img.src);
|
|
248
|
-
if (!slide.accentImage) {
|
|
249
|
-
slide.accentImage = {
|
|
250
|
-
src: img.src,
|
|
251
|
-
alt: img.alt,
|
|
252
|
-
position: 'left-strip',
|
|
253
|
-
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
slides.push(slide);
|
|
258
|
-
}
|
|
259
|
-
// Second pass: interleave unused images as standalone imageWithCaption slides.
|
|
260
|
-
// Spread them evenly through the sequence for visual variety.
|
|
261
|
-
const unusedImages = allImages.filter((img) => !usedImageSrcs.has(img.src));
|
|
262
|
-
if (unusedImages.length > 0 && slides.length > 0) {
|
|
263
|
-
const interval = Math.max(2, Math.floor(slides.length / (unusedImages.length + 1)));
|
|
264
|
-
let insertOffset = 0;
|
|
265
|
-
for (let imgIdx = 0; imgIdx < unusedImages.length; imgIdx++) {
|
|
266
|
-
const insertAt = Math.min((imgIdx + 1) * interval + insertOffset, slides.length);
|
|
267
|
-
const img = unusedImages[imgIdx];
|
|
268
|
-
slides.splice(insertAt, 0, {
|
|
269
|
-
id: `img-interleave-${imgIdx}`,
|
|
270
|
-
template: 'imageWithCaption',
|
|
271
|
-
duration: 5,
|
|
272
|
-
audioSegment: 0,
|
|
273
|
-
imageSrc: img.src,
|
|
274
|
-
imageAlt: img.alt,
|
|
275
|
-
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
276
|
-
transition: { type: 'fade', duration: 0.5 },
|
|
277
|
-
});
|
|
278
|
-
insertOffset++;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
// Recalculate sequential timing
|
|
282
|
-
let t = 0;
|
|
283
|
-
for (const slide of slides) {
|
|
284
|
-
slide.startTime = t;
|
|
285
|
-
t += slide.duration;
|
|
286
|
-
}
|
|
287
|
-
return {
|
|
288
|
-
articleId: doc.articleId,
|
|
289
|
-
duration: t,
|
|
290
|
-
blocks: slides,
|
|
291
|
-
audio: {
|
|
292
|
-
// Synthetic segment — audio will fail to load and DocPlayer will use
|
|
293
|
-
// its fallback timer to advance currentTime via requestAnimationFrame.
|
|
294
|
-
segments: t > 0 ? [{ src: '', name: 'preview', duration: t, startTime: 0 }] : [],
|
|
295
|
-
},
|
|
296
|
-
...(doc.captions ? { captions: doc.captions } : {}),
|
|
297
|
-
};
|
|
298
|
-
}
|
|
20
|
+
import { buildPreviewDoc } from './buildPreviewDoc';
|
|
299
21
|
// ── Component ──────────────────────────────────────────────────────
|
|
300
22
|
/**
|
|
301
23
|
* Live preview panel that renders the current document as a slideshow
|
package/dist/PreviewPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewPanel.js","sourceRoot":"","sources":["../src/PreviewPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAWvD,sEAAsE;AAEtE;;;GAGG;AACH,SAAS,eAAe,CAAC,QAAyC;IAChE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAA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,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildPreviewDoc — Converts a markdown-derived Doc into a player-ready Doc
|
|
3
|
+
* with TemplateBlock slides and interleaved images.
|
|
4
|
+
*
|
|
5
|
+
* Shared between PreviewPanel (live preview) and export flows (HTML/video).
|
|
6
|
+
*
|
|
7
|
+
* Pipeline:
|
|
8
|
+
* 1. Flatten hierarchical blocks into a linear slide sequence
|
|
9
|
+
* 2. Convert each block into a TemplateBlock-compatible object
|
|
10
|
+
* 3. Interleave images as standalone imageWithCaption slides
|
|
11
|
+
* 4. Synthesize a dummy audio segment for timer-based playback
|
|
12
|
+
*/
|
|
13
|
+
import type { Doc } from '@bendyline/squisq/schemas';
|
|
14
|
+
/**
|
|
15
|
+
* Build a player-ready Doc from a markdown-derived Doc.
|
|
16
|
+
*
|
|
17
|
+
* Flattens hierarchical blocks, converts each to a TemplateBlock-compatible
|
|
18
|
+
* slide, interleaves images, recalculates timing, and adds a synthetic
|
|
19
|
+
* audio segment.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildPreviewDoc(doc: Doc): Doc;
|
|
22
|
+
//# sourceMappingURL=buildPreviewDoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildPreviewDoc.d.ts","sourceRoot":"","sources":["../src/buildPreviewDoc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAS,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAwJ5D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CA8E7C"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildPreviewDoc — Converts a markdown-derived Doc into a player-ready Doc
|
|
3
|
+
* with TemplateBlock slides and interleaved images.
|
|
4
|
+
*
|
|
5
|
+
* Shared between PreviewPanel (live preview) and export flows (HTML/video).
|
|
6
|
+
*
|
|
7
|
+
* Pipeline:
|
|
8
|
+
* 1. Flatten hierarchical blocks into a linear slide sequence
|
|
9
|
+
* 2. Convert each block into a TemplateBlock-compatible object
|
|
10
|
+
* 3. Interleave images as standalone imageWithCaption slides
|
|
11
|
+
* 4. Synthesize a dummy audio segment for timer-based playback
|
|
12
|
+
*/
|
|
13
|
+
import { flattenBlocks, hasTemplate } from '@bendyline/squisq/doc';
|
|
14
|
+
import { extractPlainText } from '@bendyline/squisq/markdown';
|
|
15
|
+
import { getChildren } from '@bendyline/squisq/markdown';
|
|
16
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
17
|
+
function extractBodyText(contents) {
|
|
18
|
+
if (!contents || contents.length === 0)
|
|
19
|
+
return '';
|
|
20
|
+
const parts = [];
|
|
21
|
+
for (const node of contents) {
|
|
22
|
+
parts.push(extractPlainText(node));
|
|
23
|
+
}
|
|
24
|
+
return parts.join('\n').trim();
|
|
25
|
+
}
|
|
26
|
+
function extractBlockImages(contents) {
|
|
27
|
+
if (!contents || contents.length === 0)
|
|
28
|
+
return [];
|
|
29
|
+
const images = [];
|
|
30
|
+
function walk(node) {
|
|
31
|
+
if ('type' in node && node.type === 'image' && 'url' in node) {
|
|
32
|
+
const img = node;
|
|
33
|
+
if (img.url) {
|
|
34
|
+
images.push({ src: img.url, alt: img.alt ?? '' });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const child of getChildren(node)) {
|
|
38
|
+
walk(child);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
for (const node of contents) {
|
|
42
|
+
walk(node);
|
|
43
|
+
}
|
|
44
|
+
return images;
|
|
45
|
+
}
|
|
46
|
+
function collectAllDocImages(blocks) {
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
const images = [];
|
|
49
|
+
function walkBlocks(blockList) {
|
|
50
|
+
for (const block of blockList) {
|
|
51
|
+
for (const img of extractBlockImages(block.contents)) {
|
|
52
|
+
if (!seen.has(img.src)) {
|
|
53
|
+
seen.add(img.src);
|
|
54
|
+
images.push(img);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (block.children) {
|
|
58
|
+
walkBlocks(block.children);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
walkBlocks(blocks);
|
|
63
|
+
return images;
|
|
64
|
+
}
|
|
65
|
+
function extractListItems(contents) {
|
|
66
|
+
if (!contents)
|
|
67
|
+
return [];
|
|
68
|
+
const items = [];
|
|
69
|
+
for (const node of contents) {
|
|
70
|
+
if (node.type === 'list') {
|
|
71
|
+
for (const item of node.children) {
|
|
72
|
+
const text = extractPlainText(item).trim();
|
|
73
|
+
if (text)
|
|
74
|
+
items.push(text);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return items;
|
|
79
|
+
}
|
|
80
|
+
function getTemplateDefaults(templateName, headingText, block) {
|
|
81
|
+
const body = extractBodyText(block.contents);
|
|
82
|
+
switch (templateName) {
|
|
83
|
+
case 'statHighlight':
|
|
84
|
+
return { stat: headingText, description: body || headingText };
|
|
85
|
+
case 'quoteBlock':
|
|
86
|
+
case 'fullBleedQuote':
|
|
87
|
+
case 'pullQuote':
|
|
88
|
+
return { quote: body || headingText };
|
|
89
|
+
case 'factCard':
|
|
90
|
+
return { fact: headingText, explanation: body || headingText };
|
|
91
|
+
case 'comparisonBar':
|
|
92
|
+
return { leftLabel: 'A', leftValue: 60, rightLabel: 'B', rightValue: 40 };
|
|
93
|
+
case 'listBlock': {
|
|
94
|
+
const items = extractListItems(block.contents);
|
|
95
|
+
return { items: items.length > 0 ? items : ['Item 1', 'Item 2', 'Item 3'] };
|
|
96
|
+
}
|
|
97
|
+
case 'definitionCard':
|
|
98
|
+
return { term: headingText, definition: body || headingText };
|
|
99
|
+
case 'dateEvent':
|
|
100
|
+
return { date: headingText, description: body || headingText };
|
|
101
|
+
default:
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function blockToSlide(block, index) {
|
|
106
|
+
const headingText = block.sourceHeading
|
|
107
|
+
? extractPlainText(block.sourceHeading)
|
|
108
|
+
: block.title || block.id || `Slide ${index + 1}`;
|
|
109
|
+
const requestedTemplate = block.template || 'sectionHeader';
|
|
110
|
+
const template = hasTemplate(requestedTemplate) ? requestedTemplate : 'sectionHeader';
|
|
111
|
+
const defaults = getTemplateDefaults(template, headingText, block);
|
|
112
|
+
const { id: _id, startTime: _st, duration: _d, audioSegment: _as, layers: _l, transition: _tr, template: _t, title: _ti, children: _c, contents: _co, sourceHeading: _sh, templateOverrides: _to, ...extraFields } = block;
|
|
113
|
+
return {
|
|
114
|
+
id: block.id,
|
|
115
|
+
template,
|
|
116
|
+
duration: block.duration,
|
|
117
|
+
audioSegment: 0,
|
|
118
|
+
transition: index > 0 ? { type: 'fade', duration: 0.5 } : undefined,
|
|
119
|
+
title: headingText,
|
|
120
|
+
...defaults,
|
|
121
|
+
...extraFields,
|
|
122
|
+
...block.templateOverrides,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const IMAGE_MOTIONS = [
|
|
126
|
+
'zoomIn',
|
|
127
|
+
'zoomOut',
|
|
128
|
+
'panLeft',
|
|
129
|
+
'panRight',
|
|
130
|
+
];
|
|
131
|
+
// ── Public API ─────────────────────────────────────────────────────
|
|
132
|
+
/**
|
|
133
|
+
* Build a player-ready Doc from a markdown-derived Doc.
|
|
134
|
+
*
|
|
135
|
+
* Flattens hierarchical blocks, converts each to a TemplateBlock-compatible
|
|
136
|
+
* slide, interleaves images, recalculates timing, and adds a synthetic
|
|
137
|
+
* audio segment.
|
|
138
|
+
*/
|
|
139
|
+
export function buildPreviewDoc(doc) {
|
|
140
|
+
const flat = flattenBlocks(doc.blocks);
|
|
141
|
+
const allImages = collectAllDocImages(doc.blocks);
|
|
142
|
+
const usedImageSrcs = new Set();
|
|
143
|
+
const slides = [];
|
|
144
|
+
let motionIndex = 0;
|
|
145
|
+
for (let i = 0; i < flat.length; i++) {
|
|
146
|
+
const block = flat[i];
|
|
147
|
+
const blockImages = extractBlockImages(block.contents);
|
|
148
|
+
const slide = blockToSlide(block, i);
|
|
149
|
+
if (blockImages.length > 0 && slide.template === 'sectionHeader') {
|
|
150
|
+
const img = blockImages[0];
|
|
151
|
+
usedImageSrcs.add(img.src);
|
|
152
|
+
slide.template = 'imageWithCaption';
|
|
153
|
+
slide.imageSrc = img.src;
|
|
154
|
+
slide.imageAlt = img.alt;
|
|
155
|
+
slide.caption = slide.title;
|
|
156
|
+
slide.captionPosition = 'bottom';
|
|
157
|
+
slide.ambientMotion = IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length];
|
|
158
|
+
}
|
|
159
|
+
else if (blockImages.length > 0) {
|
|
160
|
+
const img = blockImages[0];
|
|
161
|
+
usedImageSrcs.add(img.src);
|
|
162
|
+
if (!slide.accentImage) {
|
|
163
|
+
slide.accentImage = {
|
|
164
|
+
src: img.src,
|
|
165
|
+
alt: img.alt,
|
|
166
|
+
position: 'left-strip',
|
|
167
|
+
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
slides.push(slide);
|
|
172
|
+
}
|
|
173
|
+
// Interleave unused images
|
|
174
|
+
const unusedImages = allImages.filter((img) => !usedImageSrcs.has(img.src));
|
|
175
|
+
if (unusedImages.length > 0 && slides.length > 0) {
|
|
176
|
+
const interval = Math.max(2, Math.floor(slides.length / (unusedImages.length + 1)));
|
|
177
|
+
let insertOffset = 0;
|
|
178
|
+
for (let imgIdx = 0; imgIdx < unusedImages.length; imgIdx++) {
|
|
179
|
+
const insertAt = Math.min((imgIdx + 1) * interval + insertOffset, slides.length);
|
|
180
|
+
const img = unusedImages[imgIdx];
|
|
181
|
+
slides.splice(insertAt, 0, {
|
|
182
|
+
id: `img-interleave-${imgIdx}`,
|
|
183
|
+
template: 'imageWithCaption',
|
|
184
|
+
duration: 5,
|
|
185
|
+
audioSegment: 0,
|
|
186
|
+
imageSrc: img.src,
|
|
187
|
+
imageAlt: img.alt,
|
|
188
|
+
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
189
|
+
transition: { type: 'fade', duration: 0.5 },
|
|
190
|
+
});
|
|
191
|
+
insertOffset++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Recalculate timing
|
|
195
|
+
let t = 0;
|
|
196
|
+
for (const slide of slides) {
|
|
197
|
+
slide.startTime = t;
|
|
198
|
+
t += slide.duration;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
articleId: doc.articleId,
|
|
202
|
+
duration: t,
|
|
203
|
+
blocks: slides,
|
|
204
|
+
audio: {
|
|
205
|
+
segments: t > 0 ? [{ src: '', name: 'preview', duration: t, startTime: 0 }] : [],
|
|
206
|
+
},
|
|
207
|
+
...(doc.captions ? { captions: doc.captions } : {}),
|
|
208
|
+
...(doc.startBlock ? { startBlock: doc.startBlock } : {}),
|
|
209
|
+
...(doc.themeId ? { themeId: doc.themeId } : {}),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=buildPreviewDoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildPreviewDoc.js","sourceRoot":"","sources":["../src/buildPreviewDoc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD,sEAAsE;AAEtE,SAAS,eAAe,CAAC,QAAyC;IAChE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAA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,aAAa,CAAC,MAAM,CAAC;gBAClE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE;aAC5C,CAAC,CAAC;YACH,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QACpB,CAAC,IAAI,KAAK,CAAC,QAAkB,CAAC;IAChC,CAAC;IAED,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,QAAQ,EAAE,CAAC;QACX,MAAM,EAAE,MAA4B;QACpC,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;SACjF;QACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,5 +42,6 @@ export { useFileDrop, classifyFile } from './hooks/useFileDrop.js';
|
|
|
42
42
|
export type { FileCategory, DragContentType, DropTarget, UseFileDropOptions, UseFileDropResult, } from './hooks/useFileDrop.js';
|
|
43
43
|
export { partitionFiles, processMediaFiles, processTextFile, processTextFiles, } from './utils/dropUtils.js';
|
|
44
44
|
export { markdownToTiptap, tiptapToMarkdown } from './tiptapBridge.js';
|
|
45
|
+
export { buildPreviewDoc } from './buildPreviewDoc.js';
|
|
45
46
|
export { HeadingWithTemplate } from './TemplateAnnotation.js';
|
|
46
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtE,YAAY,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBA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AO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,8 @@ export { useFileDrop, classifyFile } from './hooks/useFileDrop.js';
|
|
|
36
36
|
export { partitionFiles, processMediaFiles, processTextFile, processTextFiles, } from './utils/dropUtils.js';
|
|
37
37
|
// Bridge utilities
|
|
38
38
|
export { markdownToTiptap, tiptapToMarkdown } from './tiptapBridge.js';
|
|
39
|
+
// Slideshow builder (shared between PreviewPanel and export flows)
|
|
40
|
+
export { buildPreviewDoc } from './buildPreviewDoc.js';
|
|
39
41
|
// Tiptap extension: Heading with template annotation support
|
|
40
42
|
export { HeadingWithTemplate } from './TemplateAnnotation.js';
|
|
41
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8BAA8B;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,UAAU;AACV,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStE,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,8BAA8B;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG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,YAAY,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,mEAAmE;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,6DAA6D;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/squisq-editor-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "React editor shell with raw/WYSIWYG/preview modes for Squisq documents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bendyline",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@bendyline/squisq": "1.2.
|
|
50
|
-
"@bendyline/squisq-formats": "1.2.
|
|
51
|
-
"@bendyline/squisq-react": "1.1.
|
|
49
|
+
"@bendyline/squisq": "1.2.2",
|
|
50
|
+
"@bendyline/squisq-formats": "1.2.2",
|
|
51
|
+
"@bendyline/squisq-react": "1.1.2",
|
|
52
52
|
"@monaco-editor/react": "4.7.0",
|
|
53
53
|
"@tiptap/extension-image": "2.27.2",
|
|
54
54
|
"@tiptap/extension-placeholder": "2.27.2",
|
package/src/PreviewPanel.tsx
CHANGED
|
@@ -6,29 +6,20 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The markdown-derived Doc (from markdownToDoc) contains hierarchical blocks
|
|
8
8
|
* with template names, heading text, and body content — but no audio or
|
|
9
|
-
* visual layers. This component bridges the gap by
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* 2. Converting each block into a TemplateBlock-compatible object
|
|
13
|
-
* (mapping heading text → title, templateOverrides → template fields)
|
|
14
|
-
* 3. Synthesizing a dummy audio segment so DocPlayer's timing works
|
|
15
|
-
* (the player enters fallback-timer mode when audio can't load)
|
|
16
|
-
* 4. Passing the prepared Doc to DocPlayer for SVG-based rendering
|
|
9
|
+
* visual layers. This component bridges the gap by using buildPreviewDoc()
|
|
10
|
+
* to flatten blocks, convert them to TemplateBlock slides with interleaved
|
|
11
|
+
* images, and synthesize timing.
|
|
17
12
|
*/
|
|
18
13
|
|
|
19
14
|
import { useState, useEffect } from 'react';
|
|
20
15
|
import { DocPlayer, LinearDocView } from '@bendyline/squisq-react';
|
|
21
|
-
import {
|
|
22
|
-
import { hasTemplate } from '@bendyline/squisq/doc';
|
|
23
|
-
import { extractPlainText } from '@bendyline/squisq/markdown';
|
|
24
|
-
import type { Block, Doc } from '@bendyline/squisq/schemas';
|
|
25
|
-
import type { MarkdownBlockNode, MarkdownList, MarkdownNode } from '@bendyline/squisq/markdown';
|
|
26
|
-
import { getChildren } from '@bendyline/squisq/markdown';
|
|
16
|
+
import type { Doc } from '@bendyline/squisq/schemas';
|
|
27
17
|
import { applyTransform } from '@bendyline/squisq/transform';
|
|
28
18
|
import { resolveAudioMapping } from '@bendyline/squisq/doc';
|
|
29
19
|
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
30
20
|
import { useEditorContext } from './EditorContext';
|
|
31
21
|
import { usePreviewSettings } from './PreviewControls';
|
|
22
|
+
import { buildPreviewDoc } from './buildPreviewDoc';
|
|
32
23
|
|
|
33
24
|
export interface PreviewPanelProps {
|
|
34
25
|
/** Base path for resolving media URLs in DocPlayer */
|
|
@@ -39,325 +30,6 @@ export interface PreviewPanelProps {
|
|
|
39
30
|
container?: ContentContainer | null;
|
|
40
31
|
}
|
|
41
32
|
|
|
42
|
-
// ── Helpers ────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Extract plain text from an array of markdown block nodes.
|
|
46
|
-
* Walks paragraphs, blockquotes, and list items to collect all text.
|
|
47
|
-
*/
|
|
48
|
-
function extractBodyText(contents: MarkdownBlockNode[] | undefined): string {
|
|
49
|
-
if (!contents || contents.length === 0) return '';
|
|
50
|
-
const parts: string[] = [];
|
|
51
|
-
for (const node of contents) {
|
|
52
|
-
parts.push(extractPlainText(node));
|
|
53
|
-
}
|
|
54
|
-
return parts.join('\n').trim();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Extract images from a block's markdown contents.
|
|
59
|
-
* Walks the node tree recursively to find all MarkdownImage nodes.
|
|
60
|
-
*/
|
|
61
|
-
function extractBlockImages(
|
|
62
|
-
contents: MarkdownBlockNode[] | undefined,
|
|
63
|
-
): Array<{ src: string; alt: string }> {
|
|
64
|
-
if (!contents || contents.length === 0) return [];
|
|
65
|
-
const images: Array<{ src: string; alt: string }> = [];
|
|
66
|
-
|
|
67
|
-
function walk(node: MarkdownNode): void {
|
|
68
|
-
if ('type' in node && node.type === 'image' && 'url' in node) {
|
|
69
|
-
const img = node as { url: string; alt?: string };
|
|
70
|
-
if (img.url) {
|
|
71
|
-
images.push({ src: img.url, alt: img.alt ?? '' });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
for (const child of getChildren(node)) {
|
|
75
|
-
walk(child);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
for (const node of contents) {
|
|
80
|
-
walk(node);
|
|
81
|
-
}
|
|
82
|
-
return images;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Collect all unique images from an entire Doc's block tree.
|
|
87
|
-
* Walks nested children to find every image across all blocks.
|
|
88
|
-
*/
|
|
89
|
-
function collectAllDocImages(blocks: Block[]): Array<{ src: string; alt: string }> {
|
|
90
|
-
const seen = new Set<string>();
|
|
91
|
-
const images: Array<{ src: string; alt: string }> = [];
|
|
92
|
-
|
|
93
|
-
function walkBlocks(blockList: Block[]): void {
|
|
94
|
-
for (const block of blockList) {
|
|
95
|
-
for (const img of extractBlockImages(block.contents)) {
|
|
96
|
-
if (!seen.has(img.src)) {
|
|
97
|
-
seen.add(img.src);
|
|
98
|
-
images.push(img);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (block.children) {
|
|
102
|
-
walkBlocks(block.children);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
walkBlocks(blocks);
|
|
108
|
-
return images;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Extract list items from markdown body content.
|
|
113
|
-
* Returns an array of plain text strings for each list item found.
|
|
114
|
-
*/
|
|
115
|
-
function extractListItems(contents: MarkdownBlockNode[] | undefined): string[] {
|
|
116
|
-
if (!contents) return [];
|
|
117
|
-
const items: string[] = [];
|
|
118
|
-
for (const node of contents) {
|
|
119
|
-
if (node.type === 'list') {
|
|
120
|
-
for (const item of (node as MarkdownList).children) {
|
|
121
|
-
const text = extractPlainText(item).trim();
|
|
122
|
-
if (text) items.push(text);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return items;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Provide sensible default fields for templates that require more than
|
|
131
|
-
* just a `title`. This prevents crashes from undefined required fields
|
|
132
|
-
* when the markdown annotations don't supply all template-specific values.
|
|
133
|
-
*/
|
|
134
|
-
function getTemplateDefaults(
|
|
135
|
-
templateName: string,
|
|
136
|
-
headingText: string,
|
|
137
|
-
block: Block,
|
|
138
|
-
): Record<string, unknown> {
|
|
139
|
-
const body = extractBodyText(block.contents);
|
|
140
|
-
|
|
141
|
-
switch (templateName) {
|
|
142
|
-
case 'statHighlight':
|
|
143
|
-
return {
|
|
144
|
-
stat: headingText,
|
|
145
|
-
description: body || headingText,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
case 'quoteBlock':
|
|
149
|
-
case 'fullBleedQuote':
|
|
150
|
-
case 'pullQuote':
|
|
151
|
-
return {
|
|
152
|
-
quote: body || headingText,
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
case 'factCard':
|
|
156
|
-
return {
|
|
157
|
-
fact: headingText,
|
|
158
|
-
explanation: body || headingText,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
case 'comparisonBar':
|
|
162
|
-
return {
|
|
163
|
-
leftLabel: 'A',
|
|
164
|
-
leftValue: 60,
|
|
165
|
-
rightLabel: 'B',
|
|
166
|
-
rightValue: 40,
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
case 'listBlock':
|
|
170
|
-
return {
|
|
171
|
-
items: extractListItems(block.contents) || ['Item 1', 'Item 2', 'Item 3'],
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
case 'definitionCard':
|
|
175
|
-
return {
|
|
176
|
-
term: headingText,
|
|
177
|
-
definition: body || headingText,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
case 'dateEvent':
|
|
181
|
-
return {
|
|
182
|
-
date: headingText,
|
|
183
|
-
description: body || headingText,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
default:
|
|
187
|
-
return {};
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Convert a markdown-derived Block into a TemplateBlock-compatible object.
|
|
193
|
-
*
|
|
194
|
-
* The block's heading text becomes `title` (works for sectionHeader,
|
|
195
|
-
* titleBlock, factCard, etc.). Any templateOverrides from annotation
|
|
196
|
-
* syntax `{[template key=value]}` are spread on top so template-specific
|
|
197
|
-
* fields (stat, quote, description, …) are available.
|
|
198
|
-
*
|
|
199
|
-
* If the requested template doesn't exist in the registry, falls back
|
|
200
|
-
* to `sectionHeader` to avoid "Unknown template" warnings.
|
|
201
|
-
*/
|
|
202
|
-
function blockToSlide(block: Block, index: number): Record<string, unknown> {
|
|
203
|
-
const headingText = block.sourceHeading
|
|
204
|
-
? extractPlainText(block.sourceHeading)
|
|
205
|
-
: block.title || block.id || `Slide ${index + 1}`;
|
|
206
|
-
|
|
207
|
-
// Validate template name — fall back to sectionHeader for unknowns
|
|
208
|
-
const requestedTemplate = block.template || 'sectionHeader';
|
|
209
|
-
const template = hasTemplate(requestedTemplate) ? requestedTemplate : 'sectionHeader';
|
|
210
|
-
|
|
211
|
-
// Get sensible defaults for templates that need more than just `title`
|
|
212
|
-
const defaults = getTemplateDefaults(template, headingText, block);
|
|
213
|
-
|
|
214
|
-
// Spread the block itself to pick up any template-specific fields
|
|
215
|
-
// placed directly on the block by applyTransform (e.g. stat, description,
|
|
216
|
-
// quote, colorScheme). These are not in templateOverrides — they live
|
|
217
|
-
// on the block object because the transform produces hybrid Block+Template
|
|
218
|
-
// objects via the timing allocator.
|
|
219
|
-
const {
|
|
220
|
-
id: _id,
|
|
221
|
-
startTime: _st,
|
|
222
|
-
duration: _d,
|
|
223
|
-
audioSegment: _as,
|
|
224
|
-
layers: _l,
|
|
225
|
-
transition: _tr,
|
|
226
|
-
template: _t,
|
|
227
|
-
title: _ti,
|
|
228
|
-
children: _c,
|
|
229
|
-
contents: _co,
|
|
230
|
-
sourceHeading: _sh,
|
|
231
|
-
templateOverrides: _to,
|
|
232
|
-
...extraFields
|
|
233
|
-
} = block as unknown as Record<string, unknown>;
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
id: block.id,
|
|
237
|
-
template,
|
|
238
|
-
duration: block.duration,
|
|
239
|
-
audioSegment: 0,
|
|
240
|
-
transition: index > 0 ? { type: 'fade', duration: 0.5 } : undefined,
|
|
241
|
-
// Provide heading text as title — consumed by sectionHeader, titleBlock, etc.
|
|
242
|
-
title: headingText,
|
|
243
|
-
// Template-specific defaults (safe fallbacks for required fields)
|
|
244
|
-
...defaults,
|
|
245
|
-
// Template-specific fields from transform (stat, description, quote, etc.)
|
|
246
|
-
...extraFields,
|
|
247
|
-
// Spread annotation overrides last so explicit values win
|
|
248
|
-
...block.templateOverrides,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/** Ambient motions to rotate on image slides. */
|
|
253
|
-
const IMAGE_MOTIONS: Array<'zoomIn' | 'zoomOut' | 'panLeft' | 'panRight'> = [
|
|
254
|
-
'zoomIn',
|
|
255
|
-
'zoomOut',
|
|
256
|
-
'panLeft',
|
|
257
|
-
'panRight',
|
|
258
|
-
];
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Build a player-ready Doc from the markdown-derived Doc.
|
|
262
|
-
*
|
|
263
|
-
* Flattens hierarchical blocks, converts each to a TemplateBlock-compatible
|
|
264
|
-
* slide, recalculates timing, and adds a synthetic audio segment.
|
|
265
|
-
*
|
|
266
|
-
* Images found in the markdown are used in two ways:
|
|
267
|
-
* 1. Per-block: if a block has images, its first image becomes the background
|
|
268
|
-
* (via imageWithCaption template) or an accent image on text templates.
|
|
269
|
-
* 2. Global: remaining images are interleaved as standalone image slides
|
|
270
|
-
* for visual variety.
|
|
271
|
-
*/
|
|
272
|
-
function buildPreviewDoc(doc: Doc): Doc {
|
|
273
|
-
const flat = flattenBlocks(doc.blocks);
|
|
274
|
-
|
|
275
|
-
// Collect all images from the doc for global interleaving
|
|
276
|
-
const allImages = collectAllDocImages(doc.blocks);
|
|
277
|
-
|
|
278
|
-
// Track which images are used per-block so we can interleave the rest
|
|
279
|
-
const usedImageSrcs = new Set<string>();
|
|
280
|
-
|
|
281
|
-
// First pass: convert blocks to slides, using per-block images
|
|
282
|
-
const slides: Record<string, unknown>[] = [];
|
|
283
|
-
let motionIndex = 0;
|
|
284
|
-
|
|
285
|
-
for (let i = 0; i < flat.length; i++) {
|
|
286
|
-
const block = flat[i];
|
|
287
|
-
const blockImages = extractBlockImages(block.contents);
|
|
288
|
-
const slide = blockToSlide(block, i);
|
|
289
|
-
|
|
290
|
-
// If the block has images and is using the default sectionHeader template,
|
|
291
|
-
// upgrade it to imageWithCaption so the image becomes the slide background.
|
|
292
|
-
if (blockImages.length > 0 && slide.template === 'sectionHeader') {
|
|
293
|
-
const img = blockImages[0];
|
|
294
|
-
usedImageSrcs.add(img.src);
|
|
295
|
-
slide.template = 'imageWithCaption';
|
|
296
|
-
slide.imageSrc = img.src;
|
|
297
|
-
slide.imageAlt = img.alt;
|
|
298
|
-
slide.caption = slide.title as string;
|
|
299
|
-
slide.captionPosition = 'bottom';
|
|
300
|
-
slide.ambientMotion = IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length];
|
|
301
|
-
} else if (blockImages.length > 0) {
|
|
302
|
-
// For other templates, add the first image as an accent
|
|
303
|
-
const img = blockImages[0];
|
|
304
|
-
usedImageSrcs.add(img.src);
|
|
305
|
-
if (!slide.accentImage) {
|
|
306
|
-
slide.accentImage = {
|
|
307
|
-
src: img.src,
|
|
308
|
-
alt: img.alt,
|
|
309
|
-
position: 'left-strip',
|
|
310
|
-
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
slides.push(slide);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Second pass: interleave unused images as standalone imageWithCaption slides.
|
|
319
|
-
// Spread them evenly through the sequence for visual variety.
|
|
320
|
-
const unusedImages = allImages.filter((img) => !usedImageSrcs.has(img.src));
|
|
321
|
-
if (unusedImages.length > 0 && slides.length > 0) {
|
|
322
|
-
const interval = Math.max(2, Math.floor(slides.length / (unusedImages.length + 1)));
|
|
323
|
-
let insertOffset = 0;
|
|
324
|
-
for (let imgIdx = 0; imgIdx < unusedImages.length; imgIdx++) {
|
|
325
|
-
const insertAt = Math.min((imgIdx + 1) * interval + insertOffset, slides.length);
|
|
326
|
-
const img = unusedImages[imgIdx];
|
|
327
|
-
slides.splice(insertAt, 0, {
|
|
328
|
-
id: `img-interleave-${imgIdx}`,
|
|
329
|
-
template: 'imageWithCaption',
|
|
330
|
-
duration: 5,
|
|
331
|
-
audioSegment: 0,
|
|
332
|
-
imageSrc: img.src,
|
|
333
|
-
imageAlt: img.alt,
|
|
334
|
-
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
335
|
-
transition: { type: 'fade', duration: 0.5 },
|
|
336
|
-
});
|
|
337
|
-
insertOffset++;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Recalculate sequential timing
|
|
342
|
-
let t = 0;
|
|
343
|
-
for (const slide of slides) {
|
|
344
|
-
slide.startTime = t;
|
|
345
|
-
t += slide.duration as number;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return {
|
|
349
|
-
articleId: doc.articleId,
|
|
350
|
-
duration: t,
|
|
351
|
-
blocks: slides as unknown as Block[],
|
|
352
|
-
audio: {
|
|
353
|
-
// Synthetic segment — audio will fail to load and DocPlayer will use
|
|
354
|
-
// its fallback timer to advance currentTime via requestAnimationFrame.
|
|
355
|
-
segments: t > 0 ? [{ src: '', name: 'preview', duration: t, startTime: 0 }] : [],
|
|
356
|
-
},
|
|
357
|
-
...(doc.captions ? { captions: doc.captions } : {}),
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
33
|
// ── Component ──────────────────────────────────────────────────────
|
|
362
34
|
|
|
363
35
|
/**
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildPreviewDoc — Converts a markdown-derived Doc into a player-ready Doc
|
|
3
|
+
* with TemplateBlock slides and interleaved images.
|
|
4
|
+
*
|
|
5
|
+
* Shared between PreviewPanel (live preview) and export flows (HTML/video).
|
|
6
|
+
*
|
|
7
|
+
* Pipeline:
|
|
8
|
+
* 1. Flatten hierarchical blocks into a linear slide sequence
|
|
9
|
+
* 2. Convert each block into a TemplateBlock-compatible object
|
|
10
|
+
* 3. Interleave images as standalone imageWithCaption slides
|
|
11
|
+
* 4. Synthesize a dummy audio segment for timer-based playback
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { flattenBlocks, hasTemplate } from '@bendyline/squisq/doc';
|
|
15
|
+
import { extractPlainText } from '@bendyline/squisq/markdown';
|
|
16
|
+
import { getChildren } from '@bendyline/squisq/markdown';
|
|
17
|
+
import type { Block, Doc } from '@bendyline/squisq/schemas';
|
|
18
|
+
import type { MarkdownBlockNode, MarkdownList, MarkdownNode } from '@bendyline/squisq/markdown';
|
|
19
|
+
|
|
20
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
function extractBodyText(contents: MarkdownBlockNode[] | undefined): string {
|
|
23
|
+
if (!contents || contents.length === 0) return '';
|
|
24
|
+
const parts: string[] = [];
|
|
25
|
+
for (const node of contents) {
|
|
26
|
+
parts.push(extractPlainText(node));
|
|
27
|
+
}
|
|
28
|
+
return parts.join('\n').trim();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function extractBlockImages(
|
|
32
|
+
contents: MarkdownBlockNode[] | undefined,
|
|
33
|
+
): Array<{ src: string; alt: string }> {
|
|
34
|
+
if (!contents || contents.length === 0) return [];
|
|
35
|
+
const images: Array<{ src: string; alt: string }> = [];
|
|
36
|
+
|
|
37
|
+
function walk(node: MarkdownNode): void {
|
|
38
|
+
if ('type' in node && node.type === 'image' && 'url' in node) {
|
|
39
|
+
const img = node as { url: string; alt?: string };
|
|
40
|
+
if (img.url) {
|
|
41
|
+
images.push({ src: img.url, alt: img.alt ?? '' });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
for (const child of getChildren(node)) {
|
|
45
|
+
walk(child);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const node of contents) {
|
|
50
|
+
walk(node);
|
|
51
|
+
}
|
|
52
|
+
return images;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function collectAllDocImages(blocks: Block[]): Array<{ src: string; alt: string }> {
|
|
56
|
+
const seen = new Set<string>();
|
|
57
|
+
const images: Array<{ src: string; alt: string }> = [];
|
|
58
|
+
|
|
59
|
+
function walkBlocks(blockList: Block[]): void {
|
|
60
|
+
for (const block of blockList) {
|
|
61
|
+
for (const img of extractBlockImages(block.contents)) {
|
|
62
|
+
if (!seen.has(img.src)) {
|
|
63
|
+
seen.add(img.src);
|
|
64
|
+
images.push(img);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (block.children) {
|
|
68
|
+
walkBlocks(block.children);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
walkBlocks(blocks);
|
|
74
|
+
return images;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function extractListItems(contents: MarkdownBlockNode[] | undefined): string[] {
|
|
78
|
+
if (!contents) return [];
|
|
79
|
+
const items: string[] = [];
|
|
80
|
+
for (const node of contents) {
|
|
81
|
+
if (node.type === 'list') {
|
|
82
|
+
for (const item of (node as MarkdownList).children) {
|
|
83
|
+
const text = extractPlainText(item).trim();
|
|
84
|
+
if (text) items.push(text);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getTemplateDefaults(
|
|
92
|
+
templateName: string,
|
|
93
|
+
headingText: string,
|
|
94
|
+
block: Block,
|
|
95
|
+
): Record<string, unknown> {
|
|
96
|
+
const body = extractBodyText(block.contents);
|
|
97
|
+
|
|
98
|
+
switch (templateName) {
|
|
99
|
+
case 'statHighlight':
|
|
100
|
+
return { stat: headingText, description: body || headingText };
|
|
101
|
+
case 'quoteBlock':
|
|
102
|
+
case 'fullBleedQuote':
|
|
103
|
+
case 'pullQuote':
|
|
104
|
+
return { quote: body || headingText };
|
|
105
|
+
case 'factCard':
|
|
106
|
+
return { fact: headingText, explanation: body || headingText };
|
|
107
|
+
case 'comparisonBar':
|
|
108
|
+
return { leftLabel: 'A', leftValue: 60, rightLabel: 'B', rightValue: 40 };
|
|
109
|
+
case 'listBlock': {
|
|
110
|
+
const items = extractListItems(block.contents);
|
|
111
|
+
return { items: items.length > 0 ? items : ['Item 1', 'Item 2', 'Item 3'] };
|
|
112
|
+
}
|
|
113
|
+
case 'definitionCard':
|
|
114
|
+
return { term: headingText, definition: body || headingText };
|
|
115
|
+
case 'dateEvent':
|
|
116
|
+
return { date: headingText, description: body || headingText };
|
|
117
|
+
default:
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function blockToSlide(block: Block, index: number): Record<string, unknown> {
|
|
123
|
+
const headingText = block.sourceHeading
|
|
124
|
+
? extractPlainText(block.sourceHeading)
|
|
125
|
+
: block.title || block.id || `Slide ${index + 1}`;
|
|
126
|
+
|
|
127
|
+
const requestedTemplate = block.template || 'sectionHeader';
|
|
128
|
+
const template = hasTemplate(requestedTemplate) ? requestedTemplate : 'sectionHeader';
|
|
129
|
+
const defaults = getTemplateDefaults(template, headingText, block);
|
|
130
|
+
|
|
131
|
+
const {
|
|
132
|
+
id: _id,
|
|
133
|
+
startTime: _st,
|
|
134
|
+
duration: _d,
|
|
135
|
+
audioSegment: _as,
|
|
136
|
+
layers: _l,
|
|
137
|
+
transition: _tr,
|
|
138
|
+
template: _t,
|
|
139
|
+
title: _ti,
|
|
140
|
+
children: _c,
|
|
141
|
+
contents: _co,
|
|
142
|
+
sourceHeading: _sh,
|
|
143
|
+
templateOverrides: _to,
|
|
144
|
+
...extraFields
|
|
145
|
+
} = block as unknown as Record<string, unknown>;
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
id: block.id,
|
|
149
|
+
template,
|
|
150
|
+
duration: block.duration,
|
|
151
|
+
audioSegment: 0,
|
|
152
|
+
transition: index > 0 ? { type: 'fade', duration: 0.5 } : undefined,
|
|
153
|
+
title: headingText,
|
|
154
|
+
...defaults,
|
|
155
|
+
...extraFields,
|
|
156
|
+
...block.templateOverrides,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const IMAGE_MOTIONS: Array<'zoomIn' | 'zoomOut' | 'panLeft' | 'panRight'> = [
|
|
161
|
+
'zoomIn',
|
|
162
|
+
'zoomOut',
|
|
163
|
+
'panLeft',
|
|
164
|
+
'panRight',
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
// ── Public API ─────────────────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Build a player-ready Doc from a markdown-derived Doc.
|
|
171
|
+
*
|
|
172
|
+
* Flattens hierarchical blocks, converts each to a TemplateBlock-compatible
|
|
173
|
+
* slide, interleaves images, recalculates timing, and adds a synthetic
|
|
174
|
+
* audio segment.
|
|
175
|
+
*/
|
|
176
|
+
export function buildPreviewDoc(doc: Doc): Doc {
|
|
177
|
+
const flat = flattenBlocks(doc.blocks);
|
|
178
|
+
const allImages = collectAllDocImages(doc.blocks);
|
|
179
|
+
const usedImageSrcs = new Set<string>();
|
|
180
|
+
|
|
181
|
+
const slides: Record<string, unknown>[] = [];
|
|
182
|
+
let motionIndex = 0;
|
|
183
|
+
|
|
184
|
+
for (let i = 0; i < flat.length; i++) {
|
|
185
|
+
const block = flat[i];
|
|
186
|
+
const blockImages = extractBlockImages(block.contents);
|
|
187
|
+
const slide = blockToSlide(block, i);
|
|
188
|
+
|
|
189
|
+
if (blockImages.length > 0 && slide.template === 'sectionHeader') {
|
|
190
|
+
const img = blockImages[0];
|
|
191
|
+
usedImageSrcs.add(img.src);
|
|
192
|
+
slide.template = 'imageWithCaption';
|
|
193
|
+
slide.imageSrc = img.src;
|
|
194
|
+
slide.imageAlt = img.alt;
|
|
195
|
+
slide.caption = slide.title as string;
|
|
196
|
+
slide.captionPosition = 'bottom';
|
|
197
|
+
slide.ambientMotion = IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length];
|
|
198
|
+
} else if (blockImages.length > 0) {
|
|
199
|
+
const img = blockImages[0];
|
|
200
|
+
usedImageSrcs.add(img.src);
|
|
201
|
+
if (!slide.accentImage) {
|
|
202
|
+
slide.accentImage = {
|
|
203
|
+
src: img.src,
|
|
204
|
+
alt: img.alt,
|
|
205
|
+
position: 'left-strip',
|
|
206
|
+
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
slides.push(slide);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Interleave unused images
|
|
215
|
+
const unusedImages = allImages.filter((img) => !usedImageSrcs.has(img.src));
|
|
216
|
+
if (unusedImages.length > 0 && slides.length > 0) {
|
|
217
|
+
const interval = Math.max(2, Math.floor(slides.length / (unusedImages.length + 1)));
|
|
218
|
+
let insertOffset = 0;
|
|
219
|
+
for (let imgIdx = 0; imgIdx < unusedImages.length; imgIdx++) {
|
|
220
|
+
const insertAt = Math.min((imgIdx + 1) * interval + insertOffset, slides.length);
|
|
221
|
+
const img = unusedImages[imgIdx];
|
|
222
|
+
slides.splice(insertAt, 0, {
|
|
223
|
+
id: `img-interleave-${imgIdx}`,
|
|
224
|
+
template: 'imageWithCaption',
|
|
225
|
+
duration: 5,
|
|
226
|
+
audioSegment: 0,
|
|
227
|
+
imageSrc: img.src,
|
|
228
|
+
imageAlt: img.alt,
|
|
229
|
+
ambientMotion: IMAGE_MOTIONS[motionIndex++ % IMAGE_MOTIONS.length],
|
|
230
|
+
transition: { type: 'fade', duration: 0.5 },
|
|
231
|
+
});
|
|
232
|
+
insertOffset++;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Recalculate timing
|
|
237
|
+
let t = 0;
|
|
238
|
+
for (const slide of slides) {
|
|
239
|
+
slide.startTime = t;
|
|
240
|
+
t += slide.duration as number;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
articleId: doc.articleId,
|
|
245
|
+
duration: t,
|
|
246
|
+
blocks: slides as unknown as Block[],
|
|
247
|
+
audio: {
|
|
248
|
+
segments: t > 0 ? [{ src: '', name: 'preview', duration: t, startTime: 0 }] : [],
|
|
249
|
+
},
|
|
250
|
+
...(doc.captions ? { captions: doc.captions } : {}),
|
|
251
|
+
...(doc.startBlock ? { startBlock: doc.startBlock } : {}),
|
|
252
|
+
...(doc.themeId ? { themeId: doc.themeId } : {}),
|
|
253
|
+
};
|
|
254
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -83,5 +83,8 @@ export {
|
|
|
83
83
|
// Bridge utilities
|
|
84
84
|
export { markdownToTiptap, tiptapToMarkdown } from './tiptapBridge.js';
|
|
85
85
|
|
|
86
|
+
// Slideshow builder (shared between PreviewPanel and export flows)
|
|
87
|
+
export { buildPreviewDoc } from './buildPreviewDoc.js';
|
|
88
|
+
|
|
86
89
|
// Tiptap extension: Heading with template annotation support
|
|
87
90
|
export { HeadingWithTemplate } from './TemplateAnnotation.js';
|