Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Release 1.0.12 (#181)

nyblnet62ad664316b4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e66a0bcd..f7fb6c8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,46 @@ pre-1.0.
## [Unreleased]
+## [1.0.12] — 2026-08-01
+
+- **A laser pointer while you present.** Press **L** in the slideshow and the
+ cursor becomes a red dot trailing a short comet tail, for pointing at the
+ thing you are talking about. Press L again to put it away. It is presenter
+ equipment, not deck content: nothing about it is written into the file, so a
+ deck you point at is byte-identical to one you did not.
+
+- **Decks thumbnail properly on iPhone and iPad.** 1.0.11 taught files to draw
+ a picture of page one in Finder, and it worked everywhere except the platform
+ most likely to need it — iOS renders neither a page's JavaScript nor its
+ `<noscript>`, so a deck in Files stayed the same dark box. The preview is now
+ ordinary markup followed by a script that removes it before the browser paints
+ a frame, which the thumbnailer keeps and every reader never sees. Existing
+ decks pick this up the next time you save.
+
+- **Count-up numbers keep their thousands separators.** A number written
+ `1,234` counted up to `1.234` and stayed wrong once the animation finished;
+ `1,234,567` became `1.2340000`. Numbers now settle exactly as you typed them,
+ in your own convention — `1,234.5` and `1.234,5` both survive, and a sentence
+ ending in a number keeps its full stop.
+
+- **The tab tells you which file you are editing.** A deck's title and its file
+ name drift apart constantly — rename the deck and the file on disk keeps its
+ old name — and only one of them answers *what does ⌘S overwrite?* The tab and
+ a small chip beside the title now show the file, whenever the two differ.
+
+- **Save offers the file you are looking at.** Opening `Q3-board.bento.html`
+ and pressing ⌘S used to propose saving `Bento_Slides_Showcase.bento.html` —
+ the name was built from the deck's title, so an ordinary save quietly
+ suggested a *second* file beside the real one. It now offers the file you
+ actually opened. (Exports — share copies, templates — still name themselves;
+ those are deliberately new files.)
+
+- **Drop a deck onto an open editor to switch to it.** With a deck already open,
+ dragging another `.bento.html` in from Finder opens it in place of the current
+ one. On Chrome and Edge it arrives with permission to write back, so ⌘S saves
+ it without a dialog — which a deck opened by double-clicking cannot do, since
+ the browser gives such a page no way to write to its own file.
+
- **Release notes in the About dialog get room to be read.** An available
update is now one card — version, what changed, and the two ways to take it —
and the notes are a real list inside their own scroll region rather than a
@@ -19,6 +59,23 @@ pre-1.0.
gutters), which is enough that the five bullets a release carries fit whole
at any normal window height.
+- **Turkmen, taking the language packs to 22.** Contributed and reviewed by a
+ native speaker (Mekan Soltanov), and the only pack currently complete against
+ the whole interface. Install it from the globe menu → Manage languages.
+
+- **Save a copy, set a password or reach version history from a phone.** The
+ Save button's caret does not fit beside a 44px target, which left every file
+ operation behind it unreachable on a phone — save a copy, duplicate as a new
+ deck, the password actions, version history and the JSON round-trip. They now
+ sit at the bottom of the ⋯ menu.
+
+- **Fix: the current slide's thumbnail stays visible.** Walking a long deck with
+ the arrow keys scrolled the canvas but not the sidebar, so the highlighted
+ thumbnail wandered off-screen. Contributed by Yishen Tu.
+
+- **Fix: the auto-save tip pointed at the wrong menu.** It said version history
+ lived in About; it moved to the Save menu several releases ago.
+
## [1.0.11] — 2026-07-27
- **LaTeX maths in any text box, rendered as MathML.** Type `$E=mc^2$` and it
diff --git a/kernel/src/save.ts b/kernel/src/save.ts
index c9b96c12..c7a9c658 100644
--- a/kernel/src/save.ts
+++ b/kernel/src/save.ts
@@ -473,8 +473,16 @@ async function pickHandle(
doc: KernelDoc, suffix = '', suggestedName?: string,
): Promise<FsFileHandle | null> {
try {
+ // The name to offer is the file the user is ALREADY looking at, when we know
+ // it. suggestedFileName() derives from doc.title, and the two drift apart
+ // constantly — a deck called "Bento Slides Showcase" living in
+ // Q3-board.bento.html offered to save as Bento_Slides_Showcase.bento.html,
+ // so an ordinary ⌘S silently proposed a SECOND file beside the real one.
+ // A suffixed export (share copies) still names itself, hence the suffix
+ // check: those are deliberately new files.
+ const openedName = suffix ? null : openedFileName()
return await (window as any).showSaveFilePicker({
- suggestedName: suggestedName ?? suggestedFileName(doc, suffix),
+ suggestedName: suggestedName ?? openedName ?? suggestedFileName(doc, suffix),
// startIn takes a HANDLE, never a path — the API gives no way to point a
// picker at an arbitrary directory, by design. With a handle we land in
// the open file's own folder; without one, `id` is the fallback: the
diff --git a/slides/package.json b/slides/package.json
index 639e902f..e47428e1 100644
--- a/slides/package.json
+++ b/slides/package.json
@@ -1,7 +1,7 @@
{
"name": "bento-slides",
"private": true,
- "version": "1.0.11",
+ "version": "1.0.12",
"license": "MIT",
"type": "module",
"scripts": {
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 2954ec57..48ba2127 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -2198,10 +2198,22 @@ export class Editor {
if (this.store.dirty && !confirm(t('Open {name}? Unsaved changes in this deck will be lost.', { name: named }))) return true
// The handle is the prize; a plain File still opens, just without write-back.
+ //
+ // ORDER MATTERS: requestPermission() needs a live user gesture, and the drop
+ // is it. Reading the file first (600KB+ of text(), then DOMParser and
+ // JSON.parse) spends the activation, so the request throws SecurityError and
+ // the deck opens read-only — ⌘S then re-runs the save picker, which is the
+ // whole thing this feature exists to avoid. So: handle, permission, THEN read.
const anyItem = item as unknown as { getAsFileSystemHandle?: () => Promise<any> }
let handle: any = null
try { handle = await anyItem.getAsFileSystemHandle?.() } catch { /* not supported — read-only open */ }
+ let writable = false
+ if (handle?.requestPermission) {
+ try { writable = await handle.requestPermission({ mode: 'readwrite' }) === 'granted' }
+ catch { /* denied, or activation already spent — opens read-only */ }
+ }
+
const file: File | null = handle ? await handle.getFile() : (ev.dataTransfer?.files?.[0] ?? null)
if (!file) return true
@@ -2212,7 +2224,7 @@ export class Editor {
// generated at runtime, not stored. That file is a perfectly good Bento
// document; it just has nothing in it yet, so say that rather than call it
// a foreign file.
- if (el && !block) { alert(t('{name} has no saved document yet — open it directly to start one.', { name: named })); return true }
+ if (el && !block) { alert(t('{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.', { name: named })); return true }
let parsed: unknown
try { parsed = JSON.parse(block) } catch { alert(t('{name} isn’t a Bento document.', { name: named })); return true }
if ((parsed as { format?: string })?.format === 'bento/enc') {
@@ -2222,11 +2234,7 @@ export class Editor {
const next = parseDoc(JSON.stringify(parsed))
if (!next) { alert(t('{name} isn’t a Bento document.', { name: named })); return true }
- if (handle?.requestPermission) {
- try {
- if (await handle.requestPermission({ mode: 'readwrite' }) === 'granted') adoptFileHandle(handle)
- } catch { /* denied or unsupported — opens read-only, ⌘S still offers Save as */ }
- }
+ if (writable) adoptFileHandle(handle)
this.openedAs = named
this.store.replaceDoc(next)
this.canvas.render()
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index b1d8f1ad..843a90c1 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -727,5 +727,5 @@ export const de: Catalog = {
"Opened {name}": "{name} geöffnet",
"Opened {name} — ⌘S will save a copy": "{name} geöffnet — ⌘S speichert eine Kopie",
"⌘S asks where to save, then rewrites that file in place": "⌘S fragt nach dem Speicherort und überschreibt diese Datei dann direkt",
- "{name} has no saved document yet — open it directly to start one.": "{name} enthält noch kein gespeichertes Dokument — öffnen Sie die Datei direkt, um eines zu beginnen.",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} ist eine leere Kopie von Bento, keine gespeicherte Präsentation. Öffnen Sie die Datei einzeln, um eine zu beginnen.",
}
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index 042e8417..2067dea3 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -727,5 +727,5 @@ export const es: Catalog = {
"Opened {name}": "{name} abierto",
"Opened {name} — ⌘S will save a copy": "{name} abierto: ⌘S guardará una copia",
"⌘S asks where to save, then rewrites that file in place": "⌘S pregunta dónde guardar y luego reescribe ese archivo en el sitio",
- "{name} has no saved document yet — open it directly to start one.": "{name} aún no contiene ningún documento guardado: ábrelo directamente para empezar uno.",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} es una copia vacía de Bento, no una presentación guardada. Ábrela por su cuenta para empezar una.",
}
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 4b704d05..60736cd0 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -727,5 +727,5 @@ export const fr: Catalog = {
"Opened {name}": "{name} ouvert",
"Opened {name} — ⌘S will save a copy": "{name} ouvert — ⌘S enregistrera une copie",
"⌘S asks where to save, then rewrites that file in place": "⌘S demande où enregistrer, puis réécrit ce fichier sur place",
- "{name} has no saved document yet — open it directly to start one.": "{name} ne contient pas encore de document enregistré — ouvrez-le directement pour en commencer un.",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} est une copie vierge de Bento, pas une présentation enregistrée. Ouvrez-la seule pour en commencer une.",
}
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index cd45cdd9..2a7ee2ba 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -727,5 +727,5 @@ export const it: Catalog = {
"Opened {name}": "{name} aperto",
"Opened {name} — ⌘S will save a copy": "{name} aperto — ⌘S salverà una copia",
"⌘S asks where to save, then rewrites that file in place": "⌘S chiede dove salvare, poi riscrive quel file sul posto",
- "{name} has no saved document yet — open it directly to start one.": "{name} non contiene ancora un documento salvato — aprilo direttamente per iniziarne uno.",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} è una copia vuota di Bento, non una presentazione salvata. Aprila da sola per iniziarne una.",
}
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index 5a7193cf..b2198f06 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -727,5 +727,5 @@ export const ja: Catalog = {
"Opened {name}": "{name} を開きました",
"Opened {name} — ⌘S will save a copy": "{name} を開きました — ⌘S はコピーを保存します",
"⌘S asks where to save, then rewrites that file in place": "⌘S は保存先を尋ねてから、そのファイルを上書き保存します",
- "{name} has no saved document yet — open it directly to start one.": "{name} にはまだ保存された書類がありません。直接開いて作成してください。",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} は保存済みのデッキではなく、空の Bento です。単独で開いて作成してください。",
}
diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.ts
index a136e54f..892bd81a 100644
--- a/slides/src/i18n/packed.ts
+++ b/slides/src/i18n/packed.ts
@@ -733,5 +733,5 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Opened {name}": ["{name} を開きました","已打开 {name}","已開啟 {name}","{name} abierto","{name} ouvert","{name} geöffnet","{name} aperto","{name} aberto"],
"Opened {name} — ⌘S will save a copy": ["{name} を開きました — ⌘S はコピーを保存します","已打开 {name} — ⌘S 将保存副本","已開啟 {name} — ⌘S 將儲存副本","{name} abierto: ⌘S guardará una copia","{name} ouvert — ⌘S enregistrera une copie","{name} geöffnet — ⌘S speichert eine Kopie","{name} aperto — ⌘S salverà una copia","{name} aberto — ⌘S guardará uma cópia"],
"⌘S asks where to save, then rewrites that file in place": ["⌘S は保存先を尋ねてから、そのファイルを上書き保存します","⌘S 会先询问保存位置,然后直接覆写该文件","⌘S 會先詢問儲存位置,然後直接覆寫該檔案","⌘S pregunta dónde guardar y luego reescribe ese archivo en el sitio","⌘S demande où enregistrer, puis réécrit ce fichier sur place","⌘S fragt nach dem Speicherort und überschreibt diese Datei dann direkt","⌘S chiede dove salvare, poi riscrive quel file sul posto","⌘S pergunta onde guardar e depois reescreve esse ficheiro no local"],
- "{name} has no saved document yet — open it directly to start one.": ["{name} にはまだ保存された書類がありません。直接開いて作成してください。","{name} 中还没有已保存的文稿 — 请直接打开以创建。","{name} 中還沒有已儲存的文件 — 請直接開啟以建立。","{name} aún no contiene ningún documento guardado: ábrelo directamente para empezar uno.","{name} ne contient pas encore de document enregistré — ouvrez-le directement pour en commencer un.","{name} enthält noch kein gespeichertes Dokument — öffnen Sie die Datei direkt, um eines zu beginnen.","{name} non contiene ancora un documento salvato — aprilo direttamente per iniziarne uno.","{name} ainda não tem um documento guardado — abra-o diretamente para começar um."],
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": ["{name} は保存済みのデッキではなく、空の Bento です。単独で開いて作成してください。","{name} 是一个空的 Bento 副本,不是已保存的演示文稿。请单独打开它以创建。","{name} 是一個空的 Bento 副本,不是已儲存的簡報。請單獨開啟它以建立。","{name} es una copia vacía de Bento, no una presentación guardada. Ábrela por su cuenta para empezar una.","{name} est une copie vierge de Bento, pas une présentation enregistrée. Ouvrez-la seule pour en commencer une.","{name} ist eine leere Kopie von Bento, keine gespeicherte Präsentation. Öffnen Sie die Datei einzeln, um eine zu beginnen.","{name} è una copia vuota di Bento, non una presentazione salvata. Aprila da sola per iniziarne una.","{name} é uma cópia vazia do Bento, não uma apresentação guardada. Abra-a sozinha para começar uma."],
}
diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.ts
index 90d168ac..48d897f7 100644
--- a/slides/src/i18n/pt.ts
+++ b/slides/src/i18n/pt.ts
@@ -722,5 +722,5 @@ export const pt: Catalog = {
"Opened {name}": "{name} aberto",
"Opened {name} — ⌘S will save a copy": "{name} aberto — ⌘S guardará uma cópia",
"⌘S asks where to save, then rewrites that file in place": "⌘S pergunta onde guardar e depois reescreve esse ficheiro no local",
- "{name} has no saved document yet — open it directly to start one.": "{name} ainda não tem um documento guardado — abra-o diretamente para começar um.",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} é uma cópia vazia do Bento, não uma apresentação guardada. Abra-a sozinha para começar uma.",
}
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 6ddb2d86..0c95c138 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -727,5 +727,5 @@ export const zhHans: Catalog = {
"Opened {name}": "已打开 {name}",
"Opened {name} — ⌘S will save a copy": "已打开 {name} — ⌘S 将保存副本",
"⌘S asks where to save, then rewrites that file in place": "⌘S 会先询问保存位置,然后直接覆写该文件",
- "{name} has no saved document yet — open it directly to start one.": "{name} 中还没有已保存的文稿 — 请直接打开以创建。",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} 是一个空的 Bento 副本,不是已保存的演示文稿。请单独打开它以创建。",
}
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index 226e7b0b..e4f839b5 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -727,5 +727,5 @@ export const zhHant: Catalog = {
"Opened {name}": "已開啟 {name}",
"Opened {name} — ⌘S will save a copy": "已開啟 {name} — ⌘S 將儲存副本",
"⌘S asks where to save, then rewrites that file in place": "⌘S 會先詢問儲存位置,然後直接覆寫該檔案",
- "{name} has no saved document yet — open it directly to start one.": "{name} 中還沒有已儲存的文件 — 請直接開啟以建立。",
+ "{name} is an empty copy of Bento, not a saved deck. Open it on its own to start one.": "{name} 是一個空的 Bento 副本,不是已儲存的簡報。請單獨開啟它以建立。",
}
diff --git a/slides/src/present.ts b/slides/src/present.ts
index 9dd432da..5886dcf4 100644
--- a/slides/src/present.ts
+++ b/slides/src/present.ts
@@ -1140,11 +1140,70 @@ function settleGuarantee(pairs: Array<[HTMLElement, SlideElement]>) {
}
/** Animate every number in the element's text from 0 to its final value. */
+/**
+ * How a number was WRITTEN, so the count-up can put it back the same way.
+ *
+ * The number must settle exactly as the author typed it. Routing through
+ * `Intl.NumberFormat(navigator.language)` is the tempting fix and the wrong
+ * one: slide content is authored, so the same deck would read `1,234.5` for
+ * one viewer and `1.234,5` for another. Locale follows the viewer for CHROME
+ * only (`PLATFORM.md` §3).
+ */
+interface NumberShape {
+ value: number
+ decimals: number
+ group: string // separator between thousands, '' if the author used none
+ point: string // decimal separator, '' if the number is an integer
+}
+
+/**
+ * Read an authored number. Separators are genuinely ambiguous, so the rules
+ * are stated rather than guessed:
+ *
+ * - BOTH `.` and `,` present → the LAST one is the decimal point, the other
+ * groups. `1,234.5` → 1234.5, `1.234,5` → 1234.5.
+ * - Only `,` → grouping if there are several (`1,234,567`), or if a single one
+ * is followed by exactly three digits (`1,234`). Otherwise a decimal comma
+ * (`1,23`, `1,2345`).
+ * - Only `.` → a decimal point, always. A deck writing `1.234` means
+ * one-point-two-three-four; reading it as grouping would break every
+ * three-decimal number to fix a rarer case.
+ */
+function readNumber(raw: string): NumberShape {
+ const dots = (raw.match(/\./g) ?? []).length
+ const commas = (raw.match(/,/g) ?? []).length
+ let point = ''
+ if (dots && commas) point = raw.lastIndexOf('.') > raw.lastIndexOf(',') ? '.' : ','
+ else if (commas) point = commas > 1 || /,\d{3}$/.test(raw) ? '' : ','
+ else if (dots) point = '.'
+ const group = point === '.' ? (commas ? ',' : '')
+ : point === ',' ? (dots ? '.' : '')
+ : (commas ? ',' : dots ? '.' : '')
+ const cut = point ? raw.lastIndexOf(point) : -1
+ const whole = (cut >= 0 ? raw.slice(0, cut) : raw).replace(/[.,]/g, '')
+ const frac = cut >= 0 ? raw.slice(cut + 1) : ''
+ return { value: Number(frac ? `${whole}.${frac}` : whole), decimals: frac.length, group, point }
+}
+
+/** Put a number back in the author's own convention. */
+function writeNumber(value: number, shape: NumberShape): string {
+ const fixed = value.toFixed(shape.decimals)
+ const dot = fixed.indexOf('.')
+ let whole = dot >= 0 ? fixed.slice(0, dot) : fixed
+ const frac = dot >= 0 ? fixed.slice(dot + 1) : ''
+ if (shape.group) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, shape.group)
+ return frac ? whole + shape.point + frac : whole
+}
+
function runCountUp(node: HTMLElement) {
const inner = node.querySelector<HTMLElement>('.bento-text-inner') ?? node
const final = inner.textContent ?? ''
- const tokens = [...final.matchAll(/\d+(?:[.,]\d+)?/g)]
+ // Separators only count BETWEEN digits, so a sentence ending in a number
+ // ("grew 25.") keeps its full stop instead of having it swallowed and
+ // re-emitted as part of the value.
+ const tokens = [...final.matchAll(/\d+(?:[.,]\d+)*/g)]
if (!tokens.length) return
+ const shapes = tokens.map((m) => readNumber(m[0]))
const state = { p: 0 }
anim.to(state, {
p: 1,
@@ -1154,13 +1213,11 @@ function runCountUp(node: HTMLElement) {
onUpdate() {
let out = ''
let last = 0
- for (const m of tokens) {
+ tokens.forEach((m, i) => {
out += final.slice(last, m.index)
- const raw = m[0].replace(',', '.')
- const decimals = raw.includes('.') ? raw.split('.')[1].length : 0
- out += (parseFloat(raw) * state.p).toFixed(decimals)
+ out += writeNumber(shapes[i].value * state.p, shapes[i])
last = m.index! + m[0].length
- }
+ })
inner.textContent = out + final.slice(last)
},
})