Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
In-house speaker view: S opens a popup that actually works
nyblnet141ed90f6239
diff --git a/CLAUDE.md b/CLAUDE.mdindex 5a11b01a..43b2658f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -80,6 +80,12 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.- **Hover content is in-slide, not states**: `showOnHover` sets + slide`hover:'reveal'` (with a default set) swap content on pointer-over. Editor previewsone set at a time. Rule of thumb: click → state slide; hover → reveal set.+- **Speaker view**: OUR OWN popup (present.ts openSpeaker, S key) — current ++ next slide via renderSlide, notes, elapsed timer (click resets) + clock,+ synced on slidechanged, closed on present exit. Reveal's notes plugin is+ NOT used: its speaker window reloads the presentation URL in iframes,+ which boots the Bento EDITOR (a whole second app instance) — never+ reintroduce it.- **Animation robustness**: slide exit kills tweens AND restores model frames; a2.8s wall-clock settle guarantee lands entrances on starved render loops; neverput entrance tweens on motion-path elements (transform conflict).diff --git a/slides/src/present.ts b/slides/src/present.tsindex e4cbf7fd..b24ead5b 100644--- a/slides/src/present.ts+++ b/slides/src/present.ts@@ -3,7 +3,6 @@// ids match across the two slides (PowerPoint "Morph" behaviour).import Reveal from 'reveal.js'-import RevealNotes from 'reveal.js/plugin/notes/notes'import 'reveal.js/dist/reveal.css'import { anim, resetXform } from './anim'import { chartSnapshotSvg, mountChart } from './charts'@@ -105,11 +104,97 @@ export function startPresentation(// heavy decks: paint only the neighbourhood of the current slideviewDistance: 1,keyboardCondition: null,- plugins: [RevealNotes],+ plugins: [],})const onResize = () => deck.layout()+ // ——— speaker view (S) ———+ // Reveal's stock speaker window reloads the presentation URL in iframes —+ // which in a Bento file boots the EDITOR. Instead: our own popup, rendered+ // with the same renderer from this one app instance and synced directly.+ let speaker: Window | null = null+ let speakerTimer = 0+ let speakerStart = 0+ const nextVisibleIndex = (from: number) => {+ for (let i = (isState(from) ? anchorOf(from) : from) + 1; i < doc.slides.length; i++) {+ if (!isState(i)) return i+ }+ return -1+ }+ const svSlide = (idx: number, w: number): HTMLElement => {+ const frame = document.createElement('div')+ frame.className = 'sv-frame'+ const scale = w / doc.size.width+ frame.style.width = `${w}px`+ frame.style.height = `${doc.size.height * scale}px`+ if (idx >= 0) {+ const inner = document.createElement('div')+ inner.style.cssText = `transform:scale(${scale});transform-origin:0 0`+ inner.appendChild(renderSlide(doc.slides[idx], doc, { hidePlaceholders: true }))+ frame.appendChild(inner)+ } else {+ frame.classList.add('end')+ frame.textContent = 'End of deck'+ }+ return frame+ }+ const updateSpeaker = () => {+ if (!speaker || speaker.closed) return+ const d = speaker.document+ const cur = deck.getIndices().h+ const nxt = nextVisibleIndex(cur)+ const curBox = d.querySelector('.sv-current')+ const nxtBox = d.querySelector('.sv-nextbox')+ if (!curBox || !nxtBox) return+ curBox.innerHTML = ''+ curBox.appendChild(d.importNode(svSlide(cur, 660), true))+ nxtBox.innerHTML = ''+ nxtBox.appendChild(d.importNode(svSlide(nxt, 300), true))+ const notes = d.querySelector('.sv-notes')+ if (notes) notes.textContent = doc.slides[cur]?.notes || '— no notes for this slide —'+ const count = d.querySelector('.sv-count')+ if (count) count.textContent = `${visibleIndex(cur)} / ${visibleTotal}`+ }+ const openSpeaker = () => {+ if (speaker && !speaker.closed) {+ speaker.focus()+ return+ }+ speaker = window.open('', 'bento-speaker', 'width=1080,height=640')+ if (!speaker) return // popup blocked+ ;(window as unknown as Record<string, unknown>).__bentoSpeaker = speaker // diagnostics+ const d = speaker.document+ d.title = `${doc.title} — Speaker view`+ for (const st of document.querySelectorAll('style')) d.head.appendChild(d.importNode(st, true))+ d.body.className = 'bento-speaker'+ d.body.innerHTML =+ '<div class="sv-top"><div class="sv-timer" title="Click to reset">00:00</div>' ++ '<div class="sv-clock"></div><div class="sv-count"></div></div>' ++ '<div class="sv-main"><div class="sv-current"></div>' ++ '<div class="sv-side"><div><div class="sv-label">Next</div><div class="sv-nextbox"></div></div>' ++ '<div class="sv-notes-wrap"><div class="sv-label">Notes</div><div class="sv-notes"></div></div></div></div>'+ speakerStart = performance.now()+ d.querySelector('.sv-timer')?.addEventListener('click', () => { speakerStart = performance.now() })+ clearInterval(speakerTimer)+ speakerTimer = window.setInterval(() => {+ if (!speaker || speaker.closed) {+ clearInterval(speakerTimer)+ return+ }+ const el = speaker.document.querySelector('.sv-timer')+ if (el) {+ const t = Math.floor((performance.now() - speakerStart) / 1000)+ const mm = String(Math.floor(t / 60)).padStart(2, '0')+ const ss = String(t % 60).padStart(2, '0')+ el.textContent = `${mm}:${ss}`+ }+ const clock = speaker.document.querySelector('.sv-clock')+ if (clock) clock.textContent = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })+ }, 1000)+ updateSpeaker()+ }+const exit = () => {if (exited) returnexited = true@@ -122,6 +207,8 @@ export function startPresentation(overlay.remove()window.removeEventListener('resize', onResize)document.removeEventListener('keydown', onKeydown, true)+ clearInterval(speakerTimer)+ if (speaker && !speaker.closed) speaker.close()onExit(last)}@@ -137,6 +224,12 @@ export function startPresentation(exit()return}+ if (ev.key === 's' || ev.key === 'S') {+ ev.preventDefault()+ ev.stopPropagation()+ openSpeaker()+ return+ }const key = ev.key || ({ 32: ' ', 37: 'ArrowLeft', 39: 'ArrowRight', 33: 'PageUp', 34: 'PageDown' } as Record<number, string>)[ev.keyCode]if (key === 'ArrowRight' || key === 'PageDown' || key === ' ') {ev.preventDefault()@@ -186,6 +279,7 @@ export function startPresentation(wireHoverFocus(doc.slides[toIdx], to)if (from) disposeLiveCharts(doc.slides[fromIdx], from)mountLiveCharts(doc.slides[toIdx], to, morphing ? doc.slides[fromIdx] : undefined)+ updateSpeaker()}) as any)// Clicking an element with a link jumps to its target slide.diff --git a/slides/src/styles.css b/slides/src/styles.cssindex e58911b1..6d1d1f49 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -830,3 +830,58 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }.moveable-control-box {--moveable-color: var(--blue);}++/* ————— speaker view popup ————— */+.bento-speaker {+ margin: 0;+ background: #14181d;+ color: #e9edf3;+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;+ user-select: none;+}+.sv-top { display: flex; align-items: baseline; gap: 22px; padding: 14px 22px 10px; }+.sv-timer {+ font: 700 30px/1 ui-monospace, SFMono-Regular, Menlo, monospace;+ font-variant-numeric: tabular-nums;+ cursor: pointer;+}+.sv-timer:hover { color: #f7a600; }+.sv-clock { font-size: 15px; color: #9fb0c3; }+.sv-count { margin-left: auto; font-size: 15px; color: #9fb0c3; }+.sv-main { display: flex; gap: 22px; padding: 0 22px 22px; align-items: flex-start; }+.sv-frame {+ position: relative;+ overflow: hidden;+ background: #000;+ border-radius: 8px;+ box-shadow: 0 8px 28px rgb(0 0 0 / 0.5);+ flex: none;+}+.sv-frame.end {+ display: flex;+ align-items: center;+ justify-content: center;+ color: #5b6472;+ font-size: 14px;+ background: #1a2029;+}+.sv-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }+.sv-label {+ font-size: 10.5px;+ font-weight: 700;+ text-transform: uppercase;+ letter-spacing: 0.08em;+ color: #9fb0c3;+ margin-bottom: 6px;+}+.sv-notes-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }+.sv-notes {+ flex: 1;+ overflow-y: auto;+ white-space: pre-wrap;+ font-size: 16px;+ line-height: 1.65;+ color: #e9edf3;+ user-select: text;+ max-height: 320px;+}