Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
v0.9.8: auto-save + version history, live table→chart binding, dual-screen speaker, i18n complete
nyblnetef3ad911e7e2
diff --git a/CLAUDE.md b/CLAUDE.mdindex b390393d..6c15c23a 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -18,6 +18,19 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.- `src/save.ts` — the self-save trick: clone the document at boot (`capturePristine`),swap the `#bento-doc` data block, re-serialize. JSON is `<`-escaped (`<`) so it cannever contain `</script>`. File System Access API first, download fallback.+- `src/autosave.ts` (v0.9.8) — auto-save + local version history, IndexedDB+ (`bento-autosave`, two stores: `recovery` single-latest-per-docId, `versions`+ capped timeline). Editor debounces (2.5s) on `doc` events: writes a recovery+ snapshot (plain doc JSON, NOT the shell) + a throttled version, and — when a+ FSA handle exists — silently rewrites the real file (`writeUpdatedFile`, shows+ a "Saved" tag). On boot `checkRecovery` compares the latest snapshot's+ `docContentKey` (content minus volatile modified/collab fields) to the loaded+ doc; a mismatch shows a Restore/Discard banner. Encrypted decks are NEVER+ snapshotted to IndexedDB (plaintext-to-disk) — their file write-back stays+ encrypted. readonly players skip autosave. Version history UI in the About+ dialog; restore = `store.replaceDoc` (undoable). Keyed by docId, so recovery+ needs a stable docId (saved files) — the fresh-each-load anonymous demo won't+ cross-reload-recover, by design.- `src/render.ts` — single model→DOM renderer shared by editor canvas, thumbnails, andReveal sections. Elements carry `data-el-id` (editing) and `data-flip-id` (morph).- `src/anim.ts` — in-house animation engine (no GSAP): to/fromTo tweens with@@ -116,7 +129,13 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.axis · colour · remove), per-axis min/max, and an editable categories×seriesdata grid (add/remove rows keep xAxis.data + every series.data in lockstep);pie gets a slices grid. The raw-JSON textarea stays as the 'Advanced (JSON)'- escape hatch. Shapes:+ escape hatch. **Live table binding (v0.9.8)**: `chart.source={tableId}` links+ a chart to a table — table→chart sets it by default. `model.syncLinkedChart`+ pushes the table's labels+numeric columns into the chart's option IN PLACE+ (data only; styling/axes preserved), and editor `syncLinkedCharts` re-derives+ on the current slide whenever a table changes (signature-guarded against+ loops; each collab replica derives identically from the synced table so no+ extra ops needed). Panel shows a link banner + Unlink. Shapes:`strokeStyle` solid/dashed/dotted (legacy `strokeDash` still honoured);line shapes have `lineStart`/`lineEnd` tips (arrow/dot/bar) rendered asper-instance svg markers (sized in strokeWidth units, endpoints inset);@@ -183,7 +202,13 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.real fullscreen makes the browser leave fullscreen, whose `fullscreenchange`would call `exit()` and END the show — `openingSpeaker` guards onFsChange andre-enters fullscreen. Escape stays a separate exit path, so the guard can't- strand the presenter.+ strand the presenter. **Dual-screen (v0.9.8)**: `placeSpeaker` opens the popup+ synchronously (keeps the click gesture, avoids a popup-block), then async+ `getScreenDetails()` (Window Management permission) moves it to a second+ display and fullscreens the slides on the presenter's screen via+ `requestFullscreen({screen})`. Single-screen / denied / unsupported all+ degrade to the same-screen re-fullscreen path. Needs a real two-monitor rig+ for final QA.- **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/package.json b/slides/package.jsonindex c23ab71d..80a08c8b 100644--- a/slides/package.json+++ b/slides/package.json@@ -1,7 +1,7 @@{"name": "bento-slides","private": true,- "version": "0.9.7",+ "version": "0.9.8","type": "module","scripts": {"dev": "vite",diff --git a/slides/src/autosave.ts b/slides/src/autosave.tsnew file mode 100644index 00000000..fa8f8db0--- /dev/null+++ b/slides/src/autosave.ts@@ -0,0 +1,133 @@+// Local auto-save + lightweight version history, backed by IndexedDB.+//+// Two concerns, one store:+// · recovery — a single latest snapshot per docId, overwritten each cycle.+// On reopen, if it differs from the file we loaded, we offer to restore+// (the safety net for a crash / tab-close before a save, and the ONLY net+// on browsers without the File System Access API).+// · versions — a capped, throttled timeline of snapshots per docId, for the+// "Version history" restore UI.+//+// Snapshots hold the plain document JSON (a few KB–tens of KB), NOT the ~430KB+// HTML shell — restore re-injects via store.replaceDoc. Encrypted decks are+// never snapshotted here (that would write plaintext to disk); their file+// write-back stays encrypted.++import type { BentoDoc } from './model'++const DB_NAME = 'bento-autosave'+const DB_VERSION = 1+const RECOVERY = 'recovery'+const VERSIONS = 'versions'+const MAX_VERSIONS = 20 // per doc+const PRUNE_DAYS = 30++export interface Snapshot {+ id?: number+ docId: string+ at: number+ title: string+ json: string+}++let dbPromise: Promise<IDBDatabase | null> | null = null++function openDb(): Promise<IDBDatabase | null> {+ if (dbPromise) return dbPromise+ dbPromise = new Promise((resolve) => {+ if (typeof indexedDB === 'undefined') { resolve(null); return }+ let req: IDBOpenDBRequest+ try { req = indexedDB.open(DB_NAME, DB_VERSION) } catch { resolve(null); return }+ req.onupgradeneeded = () => {+ const db = req.result+ if (!db.objectStoreNames.contains(RECOVERY)) db.createObjectStore(RECOVERY, { keyPath: 'docId' })+ if (!db.objectStoreNames.contains(VERSIONS)) {+ const s = db.createObjectStore(VERSIONS, { keyPath: 'id', autoIncrement: true })+ s.createIndex('docId', 'docId', { unique: false })+ }+ }+ req.onsuccess = () => resolve(req.result)+ req.onerror = () => resolve(null)+ })+ return dbPromise+}++function tx<T>(store: string, mode: IDBTransactionMode, fn: (s: IDBObjectStore) => IDBRequest<T>): Promise<T | null> {+ return openDb().then((db) => {+ if (!db) return null+ return new Promise<T | null>((resolve) => {+ let t: IDBTransaction+ try { t = db.transaction(store, mode) } catch { resolve(null); return }+ const req = fn(t.objectStore(store))+ req.onsuccess = () => resolve(req.result as T)+ req.onerror = () => resolve(null)+ })+ })+}++/** The content that actually matters for "did this change" — excludes volatile+ * fields (modified timestamp, collab sync state) that churn without a real edit. */+export function docContentKey(doc: BentoDoc): string {+ return JSON.stringify([doc.title, doc.size, doc.theme, doc.slides, doc.layouts ?? null, doc.fonts ?? null, doc.assets ?? null])+}++export async function putRecovery(doc: BentoDoc): Promise<void> {+ await tx(RECOVERY, 'readwrite', (s) =>+ s.put({ docId: doc.docId, at: Date.now(), title: doc.title, json: JSON.stringify(doc) } as Snapshot))+}++export async function getRecovery(docId: string): Promise<Snapshot | null> {+ return (await tx<Snapshot>(RECOVERY, 'readonly', (s) => s.get(docId))) ?? null+}++export async function clearRecovery(docId: string): Promise<void> {+ await tx(RECOVERY, 'readwrite', (s) => s.delete(docId))+}++export async function addVersion(doc: BentoDoc): Promise<void> {+ await tx(VERSIONS, 'readwrite', (s) =>+ s.add({ docId: doc.docId, at: Date.now(), title: doc.title, json: JSON.stringify(doc) } as Snapshot))+ // prune to the newest MAX_VERSIONS for this doc+ const all = await listVersions(doc.docId)+ if (all.length > MAX_VERSIONS) {+ const doomed = all.slice(MAX_VERSIONS)+ await Promise.all(doomed.map((v) => tx(VERSIONS, 'readwrite', (s) => s.delete(v.id!))))+ }+}++export async function listVersions(docId: string): Promise<Snapshot[]> {+ const db = await openDb()+ if (!db) return []+ return new Promise((resolve) => {+ let t: IDBTransaction+ try { t = db.transaction(VERSIONS, 'readonly') } catch { resolve([]); return }+ const idx = t.objectStore(VERSIONS).index('docId')+ const out: Snapshot[] = []+ const req = idx.openCursor(IDBKeyRange.only(docId))+ req.onsuccess = () => {+ const cur = req.result+ if (cur) { out.push(cur.value as Snapshot); cur.continue() }+ else resolve(out.sort((a, b) => b.at - a.at)) // newest first+ }+ req.onerror = () => resolve([])+ })+}++/** Drop snapshots older than PRUNE_DAYS across all docs (housekeeping). */+export async function pruneOld(): Promise<void> {+ const cutoff = Date.now() - PRUNE_DAYS * 24 * 60 * 60 * 1000+ const db = await openDb()+ if (!db) return+ for (const store of [VERSIONS, RECOVERY]) {+ try {+ const t = db.transaction(store, 'readwrite')+ const req = t.objectStore(store).openCursor()+ req.onsuccess = () => {+ const cur = req.result+ if (!cur) return+ if ((cur.value as Snapshot).at < cutoff) cur.delete()+ cur.continue()+ }+ } catch { /* best effort */ }+ }+}diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 1be3fd06..f3993397 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -5,8 +5,8 @@ import type { Store } from '../store'import {FORMAT_VERSION,applyChartPalette, applyLayout, builtinLayouts, defaultChart, defaultImage, defaultShape, defaultTable, defaultText,- instantiateLayout, layoutElementIds, newDocId, uid,- type ShapeKind, type Slide, type SlideElement,+ instantiateLayout, layoutElementIds, newDocId, syncLinkedChart, uid,+ type ChartElement, type ShapeKind, type Slide, type SlideElement, type TableElement,} from '../model'import { APP_VERSION, applyUpdate, applyUpdateInPlace, autoCheckEnabled, canUpdateInPlace, checkForUpdates, offlineEnabled, setAutoCheck, setOffline } from '../update'import { CHART_PRESETS } from '../charts'@@ -14,7 +14,8 @@ import { renderSlide, renderThumbnail } from '../render'import { SlideCanvas } from './canvas'import { PropsPanel } from './panels'import { startPresentation } from '../present'-import { isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFileAs } from '../save'+import { hasFileHandle, isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'+import { addVersion, clearRecovery, docContentKey, getRecovery, listVersions, pruneOld, putRecovery, type Snapshot } from '../autosave'import { ICONS } from '../icons'import { t, setLocale, locale, LOCALE_CHOICES } from '../i18n'import { disconnectOnline, joinFromDoc, mintCollab, onlineTransport, rotateKeys, sharingOn, startSharing, stopSharing } from '../sync/online'@@ -63,6 +64,8 @@ export class Editor {window.addEventListener('beforeunload', (ev) => {if (store.dirty) ev.preventDefault()})+ this.wireAutosave()+ store.on('doc', () => this.syncLinkedCharts())document.addEventListener('bento:apply-layout', ((ev: CustomEvent) => {this.openLayoutPicker(ev.detail.anchor as HTMLElement, { kind: 'apply' })}) as EventListener)@@ -990,6 +993,157 @@ export class Editor {}, { fullscreen })}+ // --- live table→chart binding -------------------------------------------------++ private tableSig = ''+ /** Re-derive any chart linked to a table on the current slide when that+ * table's content changes. Guarded by a content signature so it can't loop,+ * and skipped when nothing is linked. */+ private syncLinkedCharts() {+ const slide = this.store.slide+ const linked = slide.elements.filter((e): e is ChartElement => e.type === 'chart' && !!(e as ChartElement).source)+ if (!linked.length) { this.tableSig = ''; return }+ const tables = slide.elements.filter((e): e is TableElement => e.type === 'table')+ const sig = slide.id + '|' + tables.map((tb) => `${tb.id}:${tb.columns.length}:${JSON.stringify(tb.rows)}`).join('|')+ if (sig === this.tableSig) return+ this.tableSig = sig+ let changed = false+ for (const chart of linked) {+ const table = tables.find((tb) => tb.id === chart.source!.tableId)+ if (table && syncLinkedChart(chart, table)) changed = true+ }+ // the triggering table edit already dirtied the doc + drives collab/autosave;+ // each replica derives identically from the synced table, so just re-render.+ if (changed) this.canvas.render()+ }++ // --- auto-save + crash recovery -----------------------------------------------++ private autosaveTimer = 0+ private lastVersionAt = 0++ private wireAutosave() {+ if (this.store.doc.readonly) return // player file — nothing to autosave+ void pruneOld()+ void this.checkRecovery()+ this.store.on('doc', () => this.scheduleAutosave())+ }++ private scheduleAutosave() {+ if (this.store.doc.readonly) return+ clearTimeout(this.autosaveTimer)+ this.autosaveTimer = window.setTimeout(() => { void this.runAutosave() }, 2500)+ }++ private async runAutosave() {+ const doc = this.store.doc+ if (doc.readonly) return+ // Never write an encrypted deck's plaintext to IndexedDB; its file+ // write-back below stays encrypted via serializeAuto.+ if (!isEncryptionActive()) {+ await putRecovery(doc)+ if (Date.now() - this.lastVersionAt > 120_000) { this.lastVersionAt = Date.now(); await addVersion(doc) }+ }+ // Silent file write-back once we hold a writable handle (Chrome/Edge).+ if (hasFileHandle()) {+ try {+ this.session?.stampInto(doc)+ await writeUpdatedFile(await serializeAuto(doc))+ this.store.setDirty(false)+ this.flashSaved()+ } catch { /* keep dirty; the IndexedDB snapshot is the backstop */ }+ }+ }++ private async checkRecovery() {+ const doc = this.store.doc+ const snap = await getRecovery(doc.docId)+ if (!snap) return+ let recovered: import('../model').BentoDoc+ try { recovered = JSON.parse(snap.json) } catch { return }+ if (docContentKey(recovered) === docContentKey(doc)) return // the file already has these edits+ this.showRecoveryBanner(snap, recovered)+ }++ private showRecoveryBanner(snap: Snapshot, recovered: import('../model').BentoDoc) {+ document.querySelector('.ed-recover')?.remove()+ const bar = div('ed-recover')+ const when = new Date(snap.at).toLocaleString([], { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' })+ const msg = document.createElement('span')+ msg.textContent = t('Unsaved changes from {when} were found.', { when })+ const restore = document.createElement('button')+ restore.className = 'ed-btn ed-btn-primary'+ restore.textContent = t('Restore')+ restore.addEventListener('click', () => {+ this.store.replaceDoc(recovered)+ this.canvas.render()+ bar.remove()+ this.toast(t('Restored your unsaved changes'))+ })+ const dismiss = document.createElement('button')+ dismiss.className = 'ed-btn'+ dismiss.textContent = t('Discard')+ dismiss.addEventListener('click', () => { void clearRecovery(this.store.doc.docId); bar.remove() })+ bar.append(msg, restore, dismiss)+ document.body.appendChild(bar)+ }++ /** Browse and restore the locally-kept auto-save timeline for this deck. */+ private async openVersionHistory() {+ const versions = await listVersions(this.store.doc.docId)+ document.querySelector('.ed-about-overlay')?.remove()+ const overlay = div('ed-about-overlay')+ const box = div('ed-about ed-version-box')+ const h = document.createElement('h2')+ h.textContent = t('Version history')+ box.appendChild(h)+ if (!versions.length) {+ const empty = document.createElement('p')+ empty.className = 'ed-about-fine'+ empty.textContent = t('No saved versions yet — they accumulate as you edit and save.')+ box.appendChild(empty)+ } else {+ const list = div('ed-version-list')+ versions.forEach((v, i) => {+ const rowEl = document.createElement('button')+ rowEl.className = 'ed-version-row'+ const when = new Date(v.at).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })+ rowEl.innerHTML = `<span class="vh-when">${when}</span>` ++ `<span class="vh-tag">${i === 0 ? t('most recent') : ''}</span>` ++ `<span class="vh-do">${t('Restore')}</span>`+ rowEl.addEventListener('click', () => {+ try {+ this.store.replaceDoc(JSON.parse(v.json))+ this.canvas.render()+ overlay.remove()+ this.toast(t('Restored the version from {when} — ⌘Z undoes', { when }))+ } catch { this.toast(t('That version could not be read')) }+ })+ list.appendChild(rowEl)+ })+ box.appendChild(list)+ }+ const fine = div('ed-about-fine')+ fine.textContent = t('Versions are stored only in this browser, never in the file or online. Restoring is undoable.')+ box.appendChild(fine)+ overlay.appendChild(box)+ const close = () => { overlay.remove(); document.removeEventListener('keydown', onKey, true) }+ const onKey = (ev: KeyboardEvent) => { if (ev.key === 'Escape') { ev.stopPropagation(); close() } }+ overlay.addEventListener('click', (ev) => { if (ev.target === overlay) close() })+ document.addEventListener('keydown', onKey, true)+ document.body.appendChild(overlay)+ }++ private savedTimer = 0+ private flashSaved() {+ let tag = document.querySelector<HTMLElement>('.ed-autosaved')+ if (!tag) { tag = div('ed-autosaved'); this.dirtyDot.after(tag) }+ tag.textContent = t('Saved')+ tag.classList.add('show')+ clearTimeout(this.savedTimer)+ this.savedTimer = window.setTimeout(() => tag!.classList.remove('show'), 1400)+ }+async save(forcePicker: boolean) {this.canvas.commitTextEdit()// shared docs persist their CRDT state so the saved copy can rejoin@@ -999,6 +1153,8 @@ export class Editor {const result = await saveFile(this.store.doc, forcePicker)if (result === 'cancelled') returnthis.store.setDirty(false)+ // record a recovery baseline + a version checkpoint at each manual save+ if (!isEncryptionActive()) { void putRecovery(this.store.doc); void addVersion(this.store.doc); this.lastVersionAt = Date.now() }// Saving is the opt-in: a named, saved deck is "live by default" from// now on (the recipient of a copy already joins on open). Connect this// session too so author and recipient meet without another click.@@ -1358,7 +1514,12 @@ export class Editor {box.insertBefore(applyB, fine)ta.focus()})- aiRow.append(copyB, replB)+ const verB = document.createElement('button')+ verB.className = 'ed-btn'+ verB.textContent = t('Version history…')+ verB.title = t('Restore an earlier auto-saved version of this deck (kept locally in this browser).')+ verB.addEventListener('click', () => { close(); void this.openVersionHistory() })+ aiRow.append(copyB, replB, verB)box.appendChild(aiRow)diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.tsindex 18380ff6..7d2d99c4 100644--- a/slides/src/editor/panels.ts+++ b/slides/src/editor/panels.ts@@ -811,6 +811,21 @@ export class PropsPanel {const isScatter = series.some((s) => s?.type === 'scatter')this.section(t('Chart'))+ // live table binding banner (if this chart tracks a table)+ if (el.source?.tableId) {+ const linkRow = document.createElement('div')+ linkRow.className = 'ed-chart-link'+ const label = document.createElement('span')+ const stillThere = this.store.slide.elements.some((e) => e.id === el.source!.tableId && e.type === 'table')+ label.textContent = stillThere ? t('🔗 Live-linked to a table') : t('🔗 Linked table not on this slide')+ const unlink = document.createElement('button')+ unlink.className = 'ed-btn'+ unlink.textContent = t('Unlink')+ unlink.title = t('Stop tracking the table; the chart keeps its current data')+ unlink.addEventListener('click', () => this.mutate(el.id, (e) => { delete (e as ChartElement).source }, true))+ linkRow.append(label, unlink)+ this.host.appendChild(linkRow)+ }this.row(t('Type'), this.select(Object.keys(CHART_PRESETS), el.preset ?? 'bar', (v) =>this.mutate(el.id, (e) => {const c = e as ChartElement@@ -1206,10 +1221,12 @@ export class PropsPanel {applyChartPalette(option, this.store.doc.theme)const chart = defaultChart(option, {x: el.x, y: Math.min(el.y + el.h + 24, 480), w: Math.max(el.w, 640), h: 300, preset: 'bar',+ // live binding: edits to the table flow into this chart+ source: { tableId: el.id },})this.store.commit(() => this.store.slide.elements.push(chart))this.store.select([chart.id])- this.toast(t('Chart created from table'))+ this.toast(t('Chart created — it updates live with the table'))}private buildImageProps(el: SlideElement) {diff --git a/slides/src/editor/patheditor.ts b/slides/src/editor/patheditor.tsindex 9193ba91..6ed39e16 100644--- a/slides/src/editor/patheditor.ts+++ b/slides/src/editor/patheditor.ts@@ -9,6 +9,7 @@// element itself.import { anim } from '../anim'+import { t } from '../i18n'import type { Store } from '../store'const SVG_NS = 'http://www.w3.org/2000/svg'@@ -176,10 +177,10 @@ export class PathEditor {this.hint = document.createElement('div')this.hint.className = 'ed-setbar ed-pathbar'this.hint.innerHTML =- '<span class="ed-setbar-label">Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed</span>'+ `<span class="ed-setbar-label">${t('Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed')}</span>`const done = document.createElement('button')done.className = 'ed-setchip active'- done.textContent = 'Done'+ done.textContent = t('Done')done.addEventListener('click', () => this.commit())this.hint.appendChild(done)this.scaleHost.closest('.ed-canvas-wrap')?.appendChild(this.hint)diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.tsindex d4bb5e6f..4e8a50b3 100644--- a/slides/src/i18n/de.ts+++ b/slides/src/i18n/de.ts@@ -367,4 +367,23 @@ export const de: Catalog = {"Ease out": "Weich enden","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Tipp: Scrolle auf der Fläche über einen Punkt, damit das Element dort verweilt oder vorbeieilt.","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Punkte ziehen zum Umformen · Doppelklick zum Hinzufügen/Entfernen · Punkt scrollen für Geschwindigkeit",+ "🔗 Live-linked to a table": "🔗 Live mit einer Tabelle verknüpft",+ "🔗 Linked table not on this slide": "🔗 Verknüpfte Tabelle nicht auf dieser Folie",+ "Unlink": "Trennen",+ "Stop tracking the table; the chart keeps its current data": "Die Tabelle nicht mehr verfolgen; das Diagramm behält seine aktuellen Daten",+ "Chart created — it updates live with the table": "Diagramm erstellt — es aktualisiert sich live mit der Tabelle",+ "Unsaved changes from {when} were found.": "Nicht gespeicherte Änderungen von {when} gefunden.",+ "Restore": "Wiederherstellen",+ "Restored your unsaved changes": "Nicht gespeicherte Änderungen wiederhergestellt",+ "Discard": "Verwerfen",+ "Version history": "Versionsverlauf",+ "No saved versions yet — they accumulate as you edit and save.": "Noch keine gespeicherten Versionen — sie sammeln sich beim Bearbeiten und Speichern an.",+ "most recent": "aktuellste",+ "Restored the version from {when} — ⌘Z undoes": "Version von {when} wiederhergestellt — ⌘Z macht es rückgängig",+ "That version could not be read": "Diese Version konnte nicht gelesen werden",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "Versionen werden nur in diesem Browser gespeichert, nie in der Datei oder online. Wiederherstellen ist rückgängig zu machen.",+ "Version history…": "Versionsverlauf…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "Eine frühere automatisch gespeicherte Version dieses Decks wiederherstellen (lokal in diesem Browser).",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "Bewegungspfad — Punkte ziehen · Doppelklick auf den Pfad zum Einfügen · Doppelklick auf einen Punkt zum Entfernen · Punkt scrollen für die Geschwindigkeit",+ "Done": "Fertig",}diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.tsindex 90a5682f..f307a837 100644--- a/slides/src/i18n/es.ts+++ b/slides/src/i18n/es.ts@@ -367,4 +367,23 @@ export const es: Catalog = {"Ease out": "Salida suave","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Consejo: en el lienzo, desplázate sobre un punto para que el elemento se detenga o pase rápido por ahí.","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Arrastra puntos para remodelar · doble clic para añadir/quitar · desplaza un punto para su velocidad",+ "🔗 Live-linked to a table": "🔗 Vinculado en vivo a una tabla",+ "🔗 Linked table not on this slide": "🔗 La tabla vinculada no está en esta diapositiva",+ "Unlink": "Desvincular",+ "Stop tracking the table; the chart keeps its current data": "Deja de seguir la tabla; el gráfico conserva sus datos actuales",+ "Chart created — it updates live with the table": "Gráfico creado — se actualiza en vivo con la tabla",+ "Unsaved changes from {when} were found.": "Se encontraron cambios sin guardar de {when}.",+ "Restore": "Restaurar",+ "Restored your unsaved changes": "Cambios sin guardar restaurados",+ "Discard": "Descartar",+ "Version history": "Historial de versiones",+ "No saved versions yet — they accumulate as you edit and save.": "Aún no hay versiones guardadas — se acumulan a medida que editas y guardas.",+ "most recent": "más reciente",+ "Restored the version from {when} — ⌘Z undoes": "Restaurada la versión de {when} — ⌘Z lo deshace",+ "That version could not be read": "No se pudo leer esa versión",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "Las versiones se guardan solo en este navegador, nunca en el archivo ni en línea. Restaurar se puede deshacer.",+ "Version history…": "Historial de versiones…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "Restaura una versión anterior autoguardada de esta presentación (guardada localmente en este navegador).",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "Trayectoria — arrastra puntos · doble clic en la trayectoria para insertar · doble clic en un punto para quitar · desplaza un punto para su velocidad",+ "Done": "Listo",}diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.tsindex eb4f9b91..23407f9c 100644--- a/slides/src/i18n/fr.ts+++ b/slides/src/i18n/fr.ts@@ -367,4 +367,23 @@ export const fr: Catalog = {"Ease out": "Sortie douce","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Astuce : sur le canevas, faites défiler sur un point pour que l’élément s’y attarde ou passe vite.","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Glissez les points pour remodeler · double-clic pour ajouter/retirer · faites défiler un point pour sa vitesse",+ "🔗 Live-linked to a table": "🔗 Lié en direct à un tableau",+ "🔗 Linked table not on this slide": "🔗 Tableau lié absent de cette diapositive",+ "Unlink": "Dissocier",+ "Stop tracking the table; the chart keeps its current data": "Ne plus suivre le tableau ; le graphique conserve ses données actuelles",+ "Chart created — it updates live with the table": "Graphique créé — il se met à jour en direct avec le tableau",+ "Unsaved changes from {when} were found.": "Modifications non enregistrées du {when} trouvées.",+ "Restore": "Restaurer",+ "Restored your unsaved changes": "Modifications non enregistrées restaurées",+ "Discard": "Ignorer",+ "Version history": "Historique des versions",+ "No saved versions yet — they accumulate as you edit and save.": "Aucune version enregistrée pour l’instant — elles s’accumulent à mesure que vous modifiez et enregistrez.",+ "most recent": "la plus récente",+ "Restored the version from {when} — ⌘Z undoes": "Version du {when} restaurée — ⌘Z annule",+ "That version could not be read": "Cette version n’a pas pu être lue",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "Les versions sont stockées uniquement dans ce navigateur, jamais dans le fichier ni en ligne. La restauration est annulable.",+ "Version history…": "Historique des versions…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "Restaurer une version antérieure enregistrée automatiquement de ce deck (conservée localement dans ce navigateur).",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "Trajectoire — glissez les points · double-clic sur la trajectoire pour insérer · double-clic sur un point pour retirer · faites défiler un point pour sa vitesse",+ "Done": "Terminé",}diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.tsindex 589c1ded..0adf198f 100644--- a/slides/src/i18n/it.ts+++ b/slides/src/i18n/it.ts@@ -367,4 +367,23 @@ export const it: Catalog = {"Ease out": "Uscita morbida","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "Suggerimento: sulla tela, scorri su un punto per far sostare l’elemento o passare veloce.","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "Trascina i punti per rimodellare · doppio clic per aggiungere/rimuovere · scorri un punto per la velocità",+ "🔗 Live-linked to a table": "🔗 Collegato in tempo reale a una tabella",+ "🔗 Linked table not on this slide": "🔗 Tabella collegata non presente in questa diapositiva",+ "Unlink": "Scollega",+ "Stop tracking the table; the chart keeps its current data": "Smetti di seguire la tabella; il grafico mantiene i suoi dati attuali",+ "Chart created — it updates live with the table": "Grafico creato — si aggiorna in tempo reale con la tabella",+ "Unsaved changes from {when} were found.": "Trovate modifiche non salvate del {when}.",+ "Restore": "Ripristina",+ "Restored your unsaved changes": "Modifiche non salvate ripristinate",+ "Discard": "Ignora",+ "Version history": "Cronologia versioni",+ "No saved versions yet — they accumulate as you edit and save.": "Ancora nessuna versione salvata — si accumulano mentre modifichi e salvi.",+ "most recent": "più recente",+ "Restored the version from {when} — ⌘Z undoes": "Ripristinata la versione del {when} — ⌘Z annulla",+ "That version could not be read": "Impossibile leggere quella versione",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "Le versioni sono memorizzate solo in questo browser, mai nel file o online. Il ripristino è annullabile.",+ "Version history…": "Cronologia versioni…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "Ripristina una versione precedente salvata automaticamente di questo deck (conservata localmente in questo browser).",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "Traiettoria — trascina i punti · doppio clic sulla traiettoria per inserire · doppio clic su un punto per rimuovere · scorri un punto per la velocità",+ "Done": "Fatto",}diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.tsindex 76ee70c4..dfc61cb4 100644--- a/slides/src/i18n/ja.ts+++ b/slides/src/i18n/ja.ts@@ -367,4 +367,23 @@ export const ja: Catalog = {"Ease out": "イーズアウト","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "ヒント:キャンバス上で点をスクロールすると、その位置で留まったり速く通過したりします。","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "ドラッグで形を変更・ダブルクリックで追加/削除・点をスクロールで速度変更",+ "🔗 Live-linked to a table": "🔗 表とライブ連携中",+ "🔗 Linked table not on this slide": "🔗 連携先の表がこのスライドにありません",+ "Unlink": "連携解除",+ "Stop tracking the table; the chart keeps its current data": "表の追跡を停止します。グラフは現在のデータを保持します",+ "Chart created — it updates live with the table": "グラフを作成しました — 表と連動して更新されます",+ "Unsaved changes from {when} were found.": "{when} の未保存の変更が見つかりました。",+ "Restore": "復元",+ "Restored your unsaved changes": "未保存の変更を復元しました",+ "Discard": "破棄",+ "Version history": "バージョン履歴",+ "No saved versions yet — they accumulate as you edit and save.": "保存されたバージョンはまだありません — 編集・保存するにつれて蓄積されます。",+ "most recent": "最新",+ "Restored the version from {when} — ⌘Z undoes": "{when} のバージョンを復元しました — ⌘Z で元に戻せます",+ "That version could not be read": "そのバージョンを読み込めませんでした",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "バージョンはこのブラウザーにのみ保存され、ファイルやオンラインには保存されません。復元は元に戻せます。",+ "Version history…": "バージョン履歴…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "このデッキの以前の自動保存バージョンを復元します(このブラウザーにローカル保存)。",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "モーションパス — 点をドラッグ・パスをダブルクリックで挿入・点をダブルクリックで削除・点をスクロールで速度変更",+ "Done": "完了",}diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.tsindex b584b3fd..9a4cb2ae 100644--- a/slides/src/i18n/zh-Hans.ts+++ b/slides/src/i18n/zh-Hans.ts@@ -367,4 +367,23 @@ export const zhHans: Catalog = {"Ease out": "缓出","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "提示:在画布上滚动某个点,可让元素在此停留或快速掠过。","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "拖动点以调整形状 · 双击添加/删除 · 滚动某点以改变其速度",+ "🔗 Live-linked to a table": "🔗 已与表格实时关联",+ "🔗 Linked table not on this slide": "🔗 关联的表格不在此幻灯片上",+ "Unlink": "取消关联",+ "Stop tracking the table; the chart keeps its current data": "停止跟踪该表格;图表保留其当前数据",+ "Chart created — it updates live with the table": "已创建图表 — 它会随表格实时更新",+ "Unsaved changes from {when} were found.": "发现来自 {when} 的未保存更改。",+ "Restore": "恢复",+ "Restored your unsaved changes": "已恢复未保存的更改",+ "Discard": "放弃",+ "Version history": "版本历史",+ "No saved versions yet — they accumulate as you edit and save.": "暂无已保存的版本 — 它们会随着你的编辑和保存而积累。",+ "most recent": "最新",+ "Restored the version from {when} — ⌘Z undoes": "已恢复 {when} 的版本 — ⌘Z 可撤销",+ "That version could not be read": "无法读取该版本",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "版本仅存储在此浏览器中,绝不写入文件或上传。恢复可撤销。",+ "Version history…": "版本历史…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "恢复此演示文稿较早的自动保存版本(本地保存在此浏览器中)。",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "运动路径 — 拖动点 · 双击路径以插入 · 双击点以删除 · 滚动某点以改变其速度",+ "Done": "完成",}diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.tsindex dc2b7599..2ce101ef 100644--- a/slides/src/i18n/zh-Hant.ts+++ b/slides/src/i18n/zh-Hant.ts@@ -367,4 +367,23 @@ export const zhHant: Catalog = {"Ease out": "緩出","Tip: on the canvas, scroll a point to make the element dwell there or rush past it.": "提示:在畫布上捲動某個點,可讓元素在此停留或快速掠過。","Drag points to reshape · double-click to add/remove · scroll a point to change its speed": "拖曳點以調整形狀 · 雙擊新增/刪除 · 捲動某點以改變其速度",+ "🔗 Live-linked to a table": "🔗 已與表格即時連結",+ "🔗 Linked table not on this slide": "🔗 連結的表格不在此投影片上",+ "Unlink": "取消連結",+ "Stop tracking the table; the chart keeps its current data": "停止追蹤該表格;圖表保留其目前資料",+ "Chart created — it updates live with the table": "已建立圖表 — 它會隨表格即時更新",+ "Unsaved changes from {when} were found.": "發現來自 {when} 的未儲存變更。",+ "Restore": "還原",+ "Restored your unsaved changes": "已還原未儲存的變更",+ "Discard": "捨棄",+ "Version history": "版本歷程",+ "No saved versions yet — they accumulate as you edit and save.": "尚無已儲存的版本 — 它們會隨著你的編輯與儲存而累積。",+ "most recent": "最新",+ "Restored the version from {when} — ⌘Z undoes": "已還原 {when} 的版本 — ⌘Z 可復原",+ "That version could not be read": "無法讀取該版本",+ "Versions are stored only in this browser, never in the file or online. Restoring is undoable.": "版本僅儲存在此瀏覽器中,絕不寫入檔案或上傳。還原可復原。",+ "Version history…": "版本歷程…",+ "Restore an earlier auto-saved version of this deck (kept locally in this browser).": "還原此簡報較早的自動儲存版本(本機儲存在此瀏覽器中)。",+ "Motion path — drag points · double-click path to insert · double-click point to remove · scroll a point to change its speed": "運動路徑 — 拖曳點 · 雙擊路徑以插入 · 雙擊點以刪除 · 捲動某點以改變其速度",+ "Done": "完成",}diff --git a/slides/src/model.ts b/slides/src/model.tsindex 087763db..8c6d7f15 100644--- a/slides/src/model.ts+++ b/slides/src/model.ts@@ -177,6 +177,8 @@ export interface ChartElement extends ElementBase {/** preset key the panel offers to re-seed from (bar/line/pie/scatter) */preset?: stringoption: Record<string, unknown>+ /** live data binding: xAxis labels + series values track this table element */+ source?: { tableId: string }}/** One cell of a table. `html` is the same sanitized inline subset as text. */@@ -430,6 +432,51 @@ export function deriveChartPalette(accent: string): string[] {]}+// --- table → chart data extraction (shared by creation + live binding) -------++const stripCell = (html: string) =>+ html.replace(/<[^>]*>/g, '').replace(/&[a-z]+;/gi, '').replace(/,/g, '').trim()++/** First column = x labels; each mostly-numeric column after = a data series. */+export function tableChartColumns(table: TableElement): { labels: string[]; cols: Array<{ name: string; data: number[]; isPct: boolean }> } {+ const bodyRows = table.header ? table.rows.slice(1) : table.rows+ const headerRow = table.header ? table.rows[0] : null+ const labels = bodyRows.map((r) => stripCell(r.cells[0]?.html ?? ''))+ const cols: Array<{ name: string; data: number[]; isPct: boolean }> = []+ for (let c = 1; c < table.columns.length; c++) {+ const raw = bodyRows.map((r) => r.cells[c]?.html ?? '')+ const parsed = raw.map((h) => parseFloat(stripCell(h)))+ if (parsed.filter((n) => !Number.isNaN(n)).length < Math.ceil(bodyRows.length / 2)) continue+ cols.push({+ name: headerRow ? stripCell(headerRow.cells[c]?.html ?? '') : '',+ data: parsed.map((n) => (Number.isNaN(n) ? 0 : n)),+ isPct: /%/.test(headerRow ? stripCell(headerRow.cells[c]?.html ?? '') : '') ||+ raw.filter((h) => /%/.test(h)).length >= Math.ceil(bodyRows.length / 2),+ })+ }+ return { labels, cols }+}++/**+ * Push a linked table's current values into a chart's option IN PLACE,+ * preserving the chart's styling/axis config (only xAxis labels + each series'+ * data change). Returns true if anything changed. Series map to numeric columns+ * by position; extra series/columns are left untouched.+ */+export function syncLinkedChart(chart: ChartElement, table: TableElement): boolean {+ const before = JSON.stringify(chart.option)+ const { labels, cols } = tableChartColumns(table)+ const opt = chart.option as { xAxis?: any; series?: any }+ if (opt.xAxis && !Array.isArray(opt.xAxis) && typeof opt.xAxis === 'object') opt.xAxis.data = labels+ const series: any[] = Array.isArray(opt.series) ? opt.series : opt.series ? [opt.series] : []+ series.forEach((s, i) => {+ if (!s || !cols[i]) return+ if (s.type === 'pie') s.data = labels.map((name, j) => ({ name, value: cols[i].data[j] ?? 0 }))+ else s.data = cols[i].data+ })+ return JSON.stringify(chart.option) !== before+}+export function chartColorsFor(theme: BentoDoc['theme']): string[] {return theme.chartPalette?.length ? theme.chartPalette.slice() : deriveChartPalette(theme.accent)}diff --git a/slides/src/present.ts b/slides/src/present.tsindex eecd880e..506a4eeb 100644--- a/slides/src/present.ts+++ b/slides/src/present.ts@@ -218,18 +218,44 @@ export function startPresentation(if (clock) clock.textContent = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}, 1000)updateSpeaker()- // If we were fullscreen, the popup just knocked us out of it. Put the slides- // back into fullscreen (best effort — may need re-activation) and keep the- // bounce from ending the show. Escape still exits via its own handler.- if (wasFullscreen) {- window.setTimeout(() => {- window.focus()- enterFullscreen()- window.setTimeout(() => { openingSpeaker = false }, 400)- }, 120)- } else {- openingSpeaker = false+ // Try TRUE dual-screen: notes window on a second display, slides fullscreen+ // on the primary. The popup was opened synchronously above (keeps the click+ // gesture, avoids a popup-block); we now query screens async and reposition.+ void placeSpeaker(wasFullscreen)+ }++ /**+ * With the Window Management permission and ≥2 displays, move the speaker+ * popup to a second screen and fullscreen the slides on the presenter's+ * screen. Everything degrades gracefully: single screen / denied permission /+ * unsupported API → the popup stays put and the slides re-enter fullscreen on+ * the current screen (so the show never ends — Escape is the only exit).+ */+ const placeSpeaker = async (wasFullscreen: boolean) => {+ let targetScreen: unknown = null+ try {+ const getScreenDetails = (window as unknown as { getScreenDetails?: () => Promise<any> }).getScreenDetails+ if (getScreenDetails && speaker) {+ const details = await getScreenDetails.call(window)+ const screens: any[] = details.screens ?? []+ if (screens.length > 1) {+ const other = screens.find((s) => s !== details.currentScreen)+ ?? screens.find((s) => !s.isPrimary) ?? screens[1]+ try { speaker.moveTo(other.availLeft, other.availTop); speaker.resizeTo(other.availWidth, other.availHeight) } catch { /* clamped without permission */ }+ targetScreen = details.currentScreen // fullscreen the slides here+ }+ }+ } catch { /* permission denied / unsupported — fall back below */ }++ if (wasFullscreen || targetScreen) {+ window.focus()+ try {+ const opts: FullscreenOptions & { screen?: unknown } = { navigationUI: 'hide' }+ if (targetScreen) opts.screen = targetScreen+ await overlay.requestFullscreen?.(opts as FullscreenOptions)+ } catch { enterFullscreen() }}+ window.setTimeout(() => { openingSpeaker = false }, 400)}// Real fullscreen (F toggles; Present enters it by default). The overlaydiff --git a/slides/src/styles.css b/slides/src/styles.cssindex 75e81955..3c640351 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -582,7 +582,71 @@ html, body {}.ed-chart-json.ed-invalid { border-color: #c9302c; outline: 1px solid #c9302c; }+/* --- auto-save: recovery banner, saved tag, version history --------------- */+.ed-recover {+ position: fixed;+ top: 64px;+ left: 50%;+ transform: translateX(-50%);+ z-index: 4000;+ display: flex;+ align-items: center;+ gap: 12px;+ background: #16273e;+ color: #f2f0ea;+ padding: 10px 14px;+ border-radius: 10px;+ box-shadow: 0 8px 30px rgb(0 0 0 / 0.28);+ font-size: 13px;+ max-width: min(92vw, 560px);+}+.ed-recover .ed-btn { padding: 5px 12px; }+.ed-autosaved {+ font-size: 11px;+ color: #6f8; /* set by theme below */+ color: var(--muted, #6b7a90);+ opacity: 0;+ transition: opacity 0.25s;+ align-self: center;+ white-space: nowrap;+ pointer-events: none;+}+.ed-autosaved.show { opacity: 0.85; }+.ed-version-box { max-width: 460px; }+.ed-version-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; max-height: 320px; overflow-y: auto; }+.ed-version-row {+ display: grid;+ grid-template-columns: 1fr auto auto;+ align-items: center;+ gap: 10px;+ text-align: left;+ padding: 9px 12px;+ border: 1px solid var(--line, #e7e1d2);+ border-radius: 8px;+ background: #fff;+ cursor: pointer;+ font-size: 13px;+ color: var(--ink, #1e2a3a);+}+.ed-version-row:hover { background: var(--chrome-2, #f4f1ea); border-color: #c9d2df; }+.ed-version-row .vh-tag { font-size: 11px; color: var(--muted, #8a94a4); }+.ed-version-row .vh-do { font-size: 12px; font-weight: 600; color: #c25a43; }+/* --- visual chart editor -------------------------------------------------- */+.ed-chart-link {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 7px 10px;+ margin-bottom: 6px;+ background: rgba(94, 118, 153, 0.1);+ border: 1px solid rgba(94, 118, 153, 0.25);+ border-radius: 8px;+ font-size: 12px;+ color: var(--ink, #1e2a3a);+}+.ed-chart-link span { flex: 1; min-width: 0; }+.ed-chart-link .ed-btn { padding: 3px 9px; font-size: 12px; }.ed-series-row {display: flex;align-items: center;