Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
PowerPoint export includes interactive states by default (#678)
nyblnet3d6f7f1fcdf2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2933d59f..d1549031 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -30,14 +30,15 @@ pre-1.0.tables, charts, pictures and hidden slides come across, and now codeblocks too (as editable text in Consolas, indentation kept) and embeddeddocuments (as a picture of what they show). WebP pictures are converted to- PNG on bento.page/convert. Interactive states can come along as hidden- slides that their links lead to. After each conversion you get a list of+ PNG on bento.page/convert. Interactive states come along as hidden slides+ that their links lead to (untick the box on the page, or pass `--no-states`,+ to leave them out). After each conversion you get a list ofwhat was approximated or left out, and on which slides: animations showtheir final frame, Morph becomes a plain cut, formulas stay as their LaTeXsource, and code loses its syntax colours. Page numbers stay right afterhidden slides. Every export is checked before it is written, so you neverget a file PowerPoint wants to repair. From a terminal:- `node convert/cli.mjs deck.bento.html --to pptx` (with `--states` and+ `node convert/cli.mjs deck.bento.html --to pptx` (with `--no-states` and`--report r.json`). Export is a page, a library and a command-line toolrather than a button in the app, so every shared file stays small and theapp stays focused.diff --git a/convert/CONTRIBUTING.md b/convert/CONTRIBUTING.mdindex ed260b70..f0f2f5d2 100644--- a/convert/CONTRIBUTING.md+++ b/convert/CONTRIBUTING.md@@ -70,7 +70,11 @@ starter deck uses nearly every element type.report** that comes back with the bytes, with the slides it happened on.Two options change what is exported. `includeStates` adds interactive-states as hidden slides that links lead to (the CLI's `--states`).+states as hidden slides that links lead to. It is ON by default in+`bentoToPptx`, the CLI and the page; `includeStates: false`, the CLI's+`--no-states` or unticking the page's box leaves them out, with links to a+state going to its parent instead. (The low-level `exportPptx` takes it+explicitly.)`rasterise` lets a host with a browser turn pictures PowerPoint cannot take(WebP, AVIF, BMP) into PNG; bento.page/convert passes one, and the CLIreports such pictures dropped.diff --git a/convert/cli.mjs b/convert/cli.mjsindex 265a44ad..0d32d89a 100755--- a/convert/cli.mjs+++ b/convert/cli.mjs@@ -23,8 +23,9 @@// refuses the network entirely and requires `--shell`.//// EXPORT (--to pptx) reads a saved deck's #bento-doc block and writes a .pptx.-// It needs no network. --states adds interactive states as hidden slides that-// links lead to (default: left out, links go to the parent). It refuses an encrypted deck, a raw compact document and+// It needs no network. Interactive states come along as hidden slides that+// links lead to; --no-states leaves them out (links then go to the parent).+// It refuses an encrypted deck, a raw compact document and// non-slides files, each with what to do instead. Export is a library and this// command, never a button in the app: the writer stays out of every shell.//@@ -55,7 +56,7 @@ process.on('warning', (w) => {const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')const USAGE = `usage:bento convert <deck.pptx> [-o out.bento.html] [--shell path | --offline] [--report r.json]- bento convert <deck.bento.html|doc.json> --to pptx [-o out.pptx] [--states] [--report r.json]`+ bento convert <deck.bento.html|doc.json> --to pptx [-o out.pptx] [--no-states] [--report r.json]`function die(msg, code = 1) {process.stderr.write(`bento convert: ${msg}\n`)@@ -65,13 +66,16 @@ function die(msg, code = 1) {// --- arguments ---------------------------------------------------------------const argv = process.argv.slice(2)if (argv[0] === 'convert') argv.shift()-const opts = { out: null, to: null, shell: null, offline: false, input: null, report: null, states: false }+const opts = { out: null, to: null, shell: null, offline: false, input: null, report: null, states: true }for (let i = 0; i < argv.length; i++) {const a = argv[i]const val = () => (i + 1 < argv.length ? argv[++i] : die(`${a} needs a value\n${USAGE}`, 2))if (a === '-o' || a === '--out') opts.out = val()else if (a === '--to') opts.to = val()else if (a === '--report') opts.report = val()+ else if (a === '--no-states') opts.states = false+ // --states was the opt-in before states became the default; kept so+ // existing scripts still run, and does nothing nowelse if (a === '--states') opts.states = trueelse if (a === '--shell') opts.shell = val()else if (a === '--offline') opts.offline = truediff --git a/convert/page/convert-page.ts b/convert/page/convert-page.tsindex d535bf22..bd8346f4 100644--- a/convert/page/convert-page.ts+++ b/convert/page/convert-page.ts@@ -102,7 +102,7 @@ async function take(name: string, bytes: Uint8Array) {<label class="option${o.ok ? '' : ' off'}"><input type="radio" name="to" value="${esc(o.conversion.id)}"${o.ok ? '' : ' disabled'}${o.ok && i === opts.findIndex((x) => x.ok) ? ' checked' : ''}><span><b>${esc(o.conversion.label)}</b>${esc(o.ok ? o.conversion.hint : o.why)}${o.ok ? (o.conversion.flags ?? []).filter((f) => f.applies(d)).map((f) => `- <span class="flag"><input type="checkbox" data-flag="${esc(o.conversion.id)}:${esc(f.id)}"> ${esc(f.label)}</span>`).join('') : ''}</span>+ <span class="flag"><input type="checkbox" data-flag="${esc(o.conversion.id)}:${esc(f.id)}"${f.default ? ' checked' : ''}> ${esc(f.label)}</span>`).join('') : ''}</span></label>`).join('')choose.hidden = falseconvertBtn.disabled = !opts.some((o) => o.ok)diff --git a/convert/src/export.ts b/convert/src/export.tsindex 2ab45932..8bb5c02f 100644--- a/convert/src/export.ts+++ b/convert/src/export.ts@@ -31,7 +31,10 @@ export interface ExportOptions {/** a picture PowerPoint cannot take (WebP, …) → PNG data: URI, or null.* Needs a browser; see ExportOpts.rasterise in pptx-write/index.ts. */rasterise?: (dataUri: string) => Promise<string | null>- /** export interactive states as hidden slides (ExportOpts.includeStates) */+ /** export interactive states as hidden slides (ExportOpts.includeStates).+ * DEFAULT TRUE (maintainer's ruling, 2026-10-10): a deck's states come+ * along unless this is set false; then they are left out and links into+ * one go to its parent. */includeStates?: boolean}@@ -61,7 +64,7 @@ export async function docToPptx(json: string, options: ExportOptions = {}): PromchartPalette: deriveChartPalette(doc.theme.accent),formulasIn: countFormulas,...(options.rasterise ? { rasterise: options.rasterise } : {}),- ...(options.includeStates ? { includeStates: true } : {}),+ includeStates: options.includeStates ?? true,})return { bytes, title: doc.title, report, stats }}diff --git a/convert/src/pairs.ts b/convert/src/pairs.tsindex 00e504ed..1e33c9b1 100644--- a/convert/src/pairs.ts+++ b/convert/src/pairs.ts@@ -144,7 +144,7 @@ export interface Conversion {/** does it fetch the signed shell? (the only network the page ever uses) */network: boolean/** yes/no choices this conversion takes, shown only where they apply */- flags?: Array<{ id: string; label: string; applies(d: Detected): boolean }>+ flags?: Array<{ id: string; label: string; applies(d: Detected): boolean; /** ticked unless the person unticks it */ default: boolean }>run(d: Detected, env: Env, flags?: Record<string, boolean>): Promise<Converted>}@@ -185,12 +185,13 @@ export const CONVERSIONS: Conversion[] = [id: 'states',label: 'Include interactive states, as hidden slides that links lead to',applies: (d) => d.kind === 'bento' && Array.isArray(d.doc.slides) && d.doc.slides.some((s) => !!(s as { stateOf?: unknown })?.stateOf),+ default: true,}],async run(d, env, flags = {}) {if (d.kind !== 'bento') throw new Error('not a Bento document')const r = await bentoToPptx(d.text, {...(env.rasterise ? { rasterise: (u: string) => env.rasterise!(u) } : {}),- ...(flags.states ? { includeStates: true } : {}),+ includeStates: flags.states ?? true,})return {bytes: r.bytes, fileName: `${base(d.name)}.pptx`,diff --git a/convert/src/pptx-write/index.ts b/convert/src/pptx-write/index.tsindex f56f7834..552f70df 100644--- a/convert/src/pptx-write/index.ts+++ b/convert/src/pptx-write/index.ts@@ -148,8 +148,10 @@ export interface ExportOpts {/** Export interactive states too, as HIDDEN slides placed right after the* slide they belong to, with links into a state landing on it. In a* PowerPoint show, hidden slides are reached only by those links, and- * Next/Previous skip them, much as bento's ←/→ skip states. Default off:- * states are left out and links into one go to its parent. */+ * Next/Previous skip them, much as bento's ←/→ skip states. Off here (the+ * writer takes it explicitly); bentoToPptx, the CLI and the page turn it+ * ON by default. Off: states are left out and links into one go to its+ * parent. */includeStates?: boolean}diff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex e3a89bbf..60c90c5e 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -10258,3 +10258,21 @@ The rule, owned by `slides/src/saving.ts`:Guards: `scripts/test-slides-save-revisions.ts` (the rule, through`saveRevision`, plus the editor wiring) and `scripts/test-slides-save-browser.mjs`(the packaged editor through the shared `scripts/lib/savequeue-browser.mjs`).++## 2026-10-10 — PowerPoint export includes interactive states by default++Maintainer's ruling: a deck's interactive states come along by default, as+hidden slides right after the slide they belong to, with links into a state+landing on it. The default lives in `bentoToPptx` (`includeStates ?? true`),+the conversion table (the page's checkbox starts ticked), and the CLI. The+CLI's opt-out is `--no-states`; the old opt-in `--states` is still accepted+as a no-op so existing scripts keep running. Leaving states out is the old+behaviour: links into a state go to its parent. Either way, the report says+which way it went (`states-as-hidden-slides` or `state-slides-omitted`).++The low-level writer, `exportPptx`, still takes the option explicitly (off+when absent), so its rig keeps covering both paths. Rows pin the default at+each level: the library, the table, the CLI and the page's rendering. A+first mutation run showed the library's own default was untested, because+every caller passed the option, so a library-level row was added.+diff --git a/scripts/test-convert/cli.ts b/scripts/test-convert/cli.tsindex 00c01af7..28cdd27d 100644--- a/scripts/test-convert/cli.ts+++ b/scripts/test-convert/cli.ts@@ -131,17 +131,22 @@ console.log('the report, and document JSON in')ok(/morph-not-exported \(slide 1\)/.test(j.err), 'each report line names the slides it happened on')}-console.log('--states')+console.log('interactive states: on by default, --no-states leaves them out'){const base = docOf(fs.readFileSync(imported, 'utf8'))base.slides.push({ ...base.slides[0], id: 'st', stateOf: base.slides[0].id, notes: 'state' })const f = path.join(tmp, 'states.bento.html')fs.writeFileSync(f, deckWith(base))const count = async (p: string) => [...(await readZip(new Uint8Array(fs.readFileSync(p)))).keys()].filter((k) => /^ppt\/slides\/slide\d+\.xml$/.test(k)).length- run([f, '--to', 'pptx', '-o', path.join(tmp, 'no-states.pptx')])- const r = run([f, '--to', 'pptx', '--states', '-o', path.join(tmp, 'states.pptx')])- const a = await count(path.join(tmp, 'no-states.pptx')), b = await count(path.join(tmp, 'states.pptx'))- ok(r.code === 0 && b === a + 1 && /states-as-hidden-slides/.test(r.err), `--states adds the state as a hidden slide (${a} → ${b} slides)`)+ const def = run([f, '--to', 'pptx', '-o', path.join(tmp, 'default.pptx')])+ const off = run([f, '--to', 'pptx', '--no-states', '-o', path.join(tmp, 'no-states.pptx')])+ const alias = run([f, '--to', 'pptx', '--states', '-o', path.join(tmp, 'alias.pptx')])+ const a = await count(path.join(tmp, 'no-states.pptx')), b = await count(path.join(tmp, 'default.pptx'))+ ok(def.code === 0 && b === a + 1 && /states-as-hidden-slides/.test(def.err) && !/state-slides-omitted/.test(def.err),+ `by default the state comes along as a hidden slide, and the report says so (${b} slides)`)+ ok(off.code === 0 && /state-slides-omitted/.test(off.err) && !/states-as-hidden-slides/.test(off.err),+ `--no-states leaves it out, and the report says so (${a} slides)`)+ ok(alias.code === 0 && await count(path.join(tmp, 'alias.pptx')) === b, '--states is still accepted (a no-op now), so existing scripts keep working')}console.log('export refusals, each saying what to do')diff --git a/scripts/test-convert/convert-page.ts b/scripts/test-convert/convert-page.tsindex 8365377b..7c9ab726 100644--- a/scripts/test-convert/convert-page.ts+++ b/scripts/test-convert/convert-page.ts@@ -93,6 +93,8 @@ console.log('bento.page/import still works')ok(/<meta http-equiv="refresh" content="0; url=\/convert\?from=pptx">/.test(redirect), 'it sends the browser to /convert?from=pptx at once')ok(/<a href="\/convert\?from=pptx">/.test(redirect), 'and links there for a browser that ignores refresh')ok(/content="default-src 'none'; base-uri 'none'; form-action 'none'"/.test(redirect), "its CSP allows nothing to load (default-src 'none')")+ ok(/data-flag="\$\{esc\(o\.conversion\.id\)\}:\$\{esc\(f\.id\)\}"\$\{f\.default \? ' checked' : ''\}/.test(fs.readFileSync(path.join(root, 'convert/page/convert-page.ts'), 'utf8')),+ 'a choice that defaults on (interactive states) renders ticked')ok(/from'\) === 'pptx'/.test(fs.readFileSync(path.join(root, 'convert/page/convert-page.ts'), 'utf8')),'/convert reads ?from=pptx and greets an /import visitor with the import wording')}diff --git a/scripts/test-convert/pairs.ts b/scripts/test-convert/pairs.tsindex 0c0c642c..2aa7cd56 100644--- a/scripts/test-convert/pairs.ts+++ b/scripts/test-convert/pairs.ts@@ -74,10 +74,13 @@ console.log('choices a pair takes')ok(JSON.stringify(flagFor(sample)) === '[]' && JSON.stringify(flagFor(withState)) === '["states"]','the states choice is offered only for a deck that has states')const c = CONVERSIONS.find((x) => x.id === 'slides-to-pptx')!+ ok(c.flags!.find((f) => f.id === 'states')!.default === true, 'the states choice starts ticked (maintainer\'s ruling)')const d = detect('d.json', enc.encode(JSON.stringify(withState)))- const off = await c.run(d, env), on = await c.run(d, env, { states: true })+ const plain = await c.run(d, env), off = await c.run(d, env, { states: false })const n = (r: typeof off) => r.stats.find((s) => s.label === 'slides')!.value- ok(n(off) === 3 && n(on) === 4, `ticking it adds the state as a slide (${n(off)} → ${n(on)})`)+ ok(n(plain) === 4 && n(off) === 3, `states come along unless unticked (${n(plain)} with, ${n(off)} unticked)`)+ ok(plain.report.entries.some((e) => e.code === 'states-as-hidden-slides') && off.report.entries.some((e) => e.code === 'state-slides-omitted'),+ 'the report says which way it went')}console.log('running each pair')diff --git a/scripts/test-convert/pptx-report.ts b/scripts/test-convert/pptx-report.tsindex d6badd2c..9e4cf6a9 100644--- a/scripts/test-convert/pptx-report.ts+++ b/scripts/test-convert/pptx-report.ts@@ -98,6 +98,17 @@ const text = (id: string, html: string) => ({const none = await bentoToPptx(docWith([]))ok(!none.report.entries.some((x) => x.code === 'fonts-not-embedded'), 'no own fonts, no entry')}+{+ // the library's own default (maintainer's ruling): states come along+ const withState = JSON.parse(docWith([text('t1', 'Hello')]))+ withState.slides.push({ id: 's2-detail', stateOf: 's2', background: '#ffffff', elements: [] })+ const json = JSON.stringify(withState)+ const def = await bentoToPptx(json), off = await bentoToPptx(json, { includeStates: false })+ ok(def.stats.slides === 3 && def.report.entries.some((e) => e.code === 'states-as-hidden-slides'),+ `bentoToPptx includes states by default (${def.stats.slides} slides)`)+ ok(off.stats.slides === 2 && off.report.entries.some((e) => e.code === 'state-slides-omitted'),+ `includeStates: false leaves them out (${off.stats.slides} slides)`)+}{let msg = ''try { await bentoToPptx('{"format": "bento/slides", ') } catch (e) { msg = (e as Error).message }diff --git a/scripts/test-convert/pptx-states.ts b/scripts/test-convert/pptx-states.tsindex b169c9c3..afba60e0 100644--- a/scripts/test-convert/pptx-states.ts+++ b/scripts/test-convert/pptx-states.ts@@ -38,7 +38,7 @@ const hidden = (r: Exported, n: number) => /<p:sld\b[^>]*\bshow="0"/.test(partTeconst textOf = (r: Exported, n: number) => [...partText(r.parts, `ppt/slides/slide${n}.xml`).matchAll(/<a:t>([^<]*)<\/a:t>/g)].map((m) => m[1]).join('')const slideCount = (r: Exported) => [...r.parts.keys()].filter((k) => /^ppt\/slides\/slide\d+\.xml$/.test(k)).length-console.log('default: states left out')+console.log('the writer with the option off (bentoToPptx, the CLI and the page default it on): states left out'){const r = await exportDeck(doc())ok(r.problems.length === 0 && slideCount(r) === 2, `2 slides (${slideCount(r)})`)