| 30 | * fragment's notes, separated by a horizontal-rule line. |
| 31 | */ |
| 32 | export const buildSubslideNotes = <C extends { id: CellId }>( |
| 33 | subslide: ComposedSubslide<C>, |
| 34 | slideConfigs: ReadonlyMap<CellId, SlideConfig>, |
| 35 | ): SubslideNotes => { |
| 36 | const blockNotes = subslide.blocks.map((block) => |
| 37 | collectBlockNotes(block.cells, slideConfigs), |
| 38 | ); |
| 39 | |
| 40 | const slideLevel = subslide.blocks |
| 41 | .map((block, i) => (block.isFragment ? "" : blockNotes[i])) |
| 42 | .filter((note) => note.length > 0) |
| 43 | .join("\n\n"); |
| 44 | |
| 45 | const cumulativeByBlock = new Map<number, string>(); |
| 46 | const revealsSoFar: string[] = []; |
| 47 | subslide.blocks.forEach((block, i) => { |
| 48 | if (!block.isFragment) { |
| 49 | return; |
| 50 | } |
| 51 | const myNotes = blockNotes[i]; |
| 52 | if (myNotes.length > 0) { |
| 53 | revealsSoFar.push(myNotes); |
| 54 | } |
| 55 | const accumulated = [slideLevel, ...revealsSoFar] |
| 56 | .filter((s) => s.length > 0) |
| 57 | .join(BLOCK_JOIN); |
| 58 | if (accumulated.length > 0) { |
| 59 | cumulativeByBlock.set(i, accumulated); |
| 60 | } |
| 61 | }); |
| 62 | |
| 63 | return { slideLevel, cumulativeByBlock }; |
| 64 | }; |