Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Editor: show which file the deck is open as, and open one by dropping it (#162)

nyblnet939381b64525
diff --git a/kernel/src/save.ts b/kernel/src/save.ts
index 06c09b2b..c9b96c12 100644
--- a/kernel/src/save.ts
+++ b/kernel/src/save.ts
@@ -528,6 +528,24 @@ export async function saveFile(doc: KernelDoc, forcePicker = false): Promise<Sav
export const currentFileName = () => fileHandle?.name ?? null
+/**
+ * Adopt a handle obtained outside the save picker — today, a file dropped onto
+ * the editor via `DataTransferItem.getAsFileSystemHandle()`.
+ *
+ * Why this exists: a deck double-clicked from disk opens on `file://` with NO
+ * handle, so every ⌘S re-runs the picker and the user re-navigates to a file
+ * they are already looking at. A drop yields a real handle, so adopting it
+ * turns that document into one Bento can rewrite in place.
+ *
+ * The caller MUST have obtained readwrite permission first — this only records
+ * the handle. It is deliberately not exported through `window.bento`: adopting
+ * a handle silently redirects where ⌘S writes, which is a user gesture, never
+ * something a script should do behind their back.
+ */
+export function adoptFileHandle(handle: FsFileHandle): void {
+ fileHandle = handle
+}
+
/**
* The name of the file this document is actually open AS, when knowable.
*
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 4822d6ae..a9f01ed1 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -8,7 +8,7 @@ import {
FORMAT_VERSION,
MEDIA_EMBED_BUDGET,
applyChartPalette, applyLayout, builtinLayouts, defaultChart, defaultImage, defaultMedia, defaultShape, defaultTable, defaultText,
- instantiateLayout, isLightBg, layoutElementIds, newDocId, readableInk, syncLinkedChart, uid,
+ instantiateLayout, isLightBg, layoutElementIds, newDocId, parseDoc, readableInk, 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'
@@ -17,7 +17,7 @@ import { renderSlide, renderThumbnail } from '../render'
import { SlideCanvas } from './canvas'
import { PropsPanel } from './panels'
import { startPresentation } from '../present'
-import { canWriteInPlace, hasFileHandle, isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'
+import { adoptFileHandle, canWriteInPlace, currentFileName, fileBase, hasFileHandle, isEncryptionActive, openedFileName, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'
import { addVersion, clearRecovery, clearVersions, docContentKey, getRecovery, listVersions, pruneOld, putRecovery, type Snapshot } from '../autosave'
import { insertElements, insertSlides, parseClip, serializeElements, serializeSlides } from './clipboard'
import { openSpeakerWindow, speakerIdleBody } from '../screens'
@@ -60,6 +60,9 @@ export class Editor {
private sidebar!: HTMLElement
private props!: HTMLElement
private dirtyDot!: HTMLElement
+ private fileChip?: HTMLElement
+ /** Name of a deck opened by DROP when no writable handle came with it. */
+ private openedAs?: string
private thumbTimer = 0
private presenting = false
private updatesB!: HTMLElement
@@ -224,15 +227,23 @@ export class Editor {
title.spellcheck = false
title.addEventListener('change', () => {
this.store.commit(() => { this.store.doc.title = title.value || 'Untitled' })
- document.title = `${this.store.doc.title} — ${appConfig().appName}`
+ this.syncWindowTitle()
})
// remote/programmatic title changes reflect live (unless being typed in)
this.store.on('doc', () => {
if (document.activeElement !== title && title.value !== this.store.doc.title) {
title.value = this.store.doc.title
- document.title = `${this.store.doc.title} — ${appConfig().appName}`
+ this.syncWindowTitle()
}
})
+
+ // The FILE this deck is open as — deliberately separate from the deck
+ // title above, because the two 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?". Absent until the answer is knowable: a never-saved
+ // deck has no file, and saying so would be noise.
+ this.fileChip = div('ed-filechip')
+ this.fileChip.hidden = true
this.dirtyDot = div('ed-dirty')
// Capability-aware: on Safari/Firefox (and every iOS browser) there is no
// File System Access API, so ⌘S CANNOT rewrite this file — it hands back a
@@ -324,13 +335,15 @@ export class Editor {
const formatB = btn(ICONS.panelRight, t('Format'), () => this.togglePanel('right'), t('Format — show or hide the properties panel'))
formatB.classList.add('ed-phone-only')
+ this.syncWindowTitle()
+
this.phoneChrome = {
insertD, insertMenu, moreD, moreMenu, slidesB, formatB, insert, actions, history,
// order matters: this is the order they appear in the ⋯ menu
demote: [redoB, commentB, pdfB, shareD, langD, helpB],
}
- bar.append(logo, this.updatesB, title, slidesB, insertD, history, insert, actions, moreD)
+ bar.append(logo, this.updatesB, title, this.fileChip, slidesB, insertD, history, insert, actions, moreD)
// main area
const main = div('ed-main')
@@ -1852,6 +1865,13 @@ export class Editor {
// --- paste: external objects + cross-deck elements/slides ---------------------
private wirePaste() {
+ // A dropped .bento.html OPENS as a deck (and adopts a writable handle);
+ // anything else falls through to the existing image/media drop behaviour.
+ document.addEventListener('dragover', (ev: DragEvent) => {
+ if ([...(ev.dataTransfer?.items ?? [])].some((i) => i.kind === 'file')) ev.preventDefault()
+ })
+ document.addEventListener('drop', (ev: DragEvent) => { void this.openDroppedDeck(ev) })
+
document.addEventListener('paste', (ev: ClipboardEvent) => {
if (this.presenting) return
const a = document.activeElement as HTMLElement | null
@@ -2116,6 +2136,101 @@ export class Editor {
document.body.appendChild(bar)
}
+ /**
+ * Tab title = deck title, plus the FILE name once one is known.
+ *
+ * `openedFileName()` answers this from the handle, or from the URL when a
+ * `.bento.html` was opened directly — so it is right for a dropped file, a
+ * saved file, and a double-clicked one alike, and null for the hosted demo.
+ */
+ private syncWindowTitle() {
+ // Order matters. A handle is the truth. Failing that, a deck opened by drop
+ // is named by the file it came from — the URL is stale the moment a drop
+ // replaces the document, and would otherwise label this deck with the name
+ // of the file still sitting in the address bar.
+ const file = currentFileName() ?? this.openedAs ?? openedFileName()
+ const named = file && fileBase(file) !== this.store.doc.title
+ // Two segments, never three: a tab is narrow, and once a file name is
+ // shown the app name is the least informative thing competing for it.
+ document.title = named
+ ? `${this.store.doc.title} — ${file}`
+ : `${this.store.doc.title} — ${appConfig().appName}`
+ if (!this.fileChip) return
+ this.fileChip.hidden = !named
+ if (!file) return
+ this.fileChip.textContent = fileBase(file)
+ // Three states, because two would lie: with the API but no handle yet, ⌘S
+ // asks first and only then owns a file.
+ this.fileChip.title = !canWriteInPlace()
+ ? t('⌘S saves a copy — this browser can’t rewrite the file in place')
+ : hasFileHandle()
+ ? t('⌘S rewrites this file in place')
+ : t('⌘S asks where to save, then rewrites that file in place')
+ }
+
+ /**
+ * Open a `.bento.html` dropped onto the editor, adopting a WRITABLE handle
+ * where the browser offers one.
+ *
+ * This is the only route to in-place saving for a deck that arrived from
+ * disk. A file double-clicked in Finder opens on `file://` with no handle, so
+ * every ⌘S re-runs the save picker and asks the user to navigate to the file
+ * they already have open. `getAsFileSystemHandle()` returns a real handle for
+ * a dropped file (Chromium only), so one permission prompt converts that deck
+ * into one Bento can rewrite.
+ *
+ * Guards, in order: images and everything else keep their existing paste/drop
+ * behaviour; an encrypted deck is refused rather than half-opened, because the
+ * password gate lives in boot and there is nothing here to prompt with; and
+ * unsaved work is confirmed before being replaced, since this is destructive
+ * in a way dropping a picture is not.
+ */
+ private async openDroppedDeck(ev: DragEvent): Promise<boolean> {
+ const item = [...(ev.dataTransfer?.items ?? [])].find((i) => i.kind === 'file')
+ const named = ev.dataTransfer?.files?.[0]?.name ?? ''
+ if (!item || !/\.bento\.html$/i.test(named)) return false
+ ev.preventDefault()
+
+ 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.
+ const anyItem = item as unknown as { getAsFileSystemHandle?: () => Promise<any> }
+ let handle: any = null
+ try { handle = await anyItem.getAsFileSystemHandle?.() } catch { /* not supported — read-only open */ }
+
+ const file: File | null = handle ? await handle.getFile() : (ev.dataTransfer?.files?.[0] ?? null)
+ if (!file) return true
+
+ const html = await file.text()
+ const el = new DOMParser().parseFromString(html, 'text/html').querySelector('#bento-doc')
+ const block = el?.textContent?.trim() ?? ''
+ // A pristine, never-saved shell ships an EMPTY block — the starter deck is
+ // 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 }
+ 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') {
+ alert(t('{name} is password-protected. Open it directly to unlock it.', { name: named }))
+ return true
+ }
+ 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 */ }
+ }
+ this.openedAs = named
+ this.store.replaceDoc(next)
+ this.canvas.render()
+ this.syncWindowTitle()
+ this.flashSaved(hasFileHandle() ? t('Opened {name}', { name: named }) : t('Opened {name} — ⌘S will save a copy', { name: named }))
+ return true
+ }
+
private noticeIfCannotWriteInPlace() {
if (canWriteInPlace()) return
if (localStorage.getItem(SAVE_NOTICE_KEY) === 'seen') return
@@ -2304,6 +2419,8 @@ export class Editor {
const result = await saveFile(this.store.doc, forcePicker)
if (result === 'cancelled') return
this.store.setDirty(false)
+ // the file name is knowable from here on — put it in the tab and the chip
+ this.syncWindowTitle()
// staged language packs are in the bytes now — stop calling them pending
markFileSaved()
// record a recovery baseline + a version checkpoint at each manual save
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index 3267e0c0..f56cbc1c 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -715,4 +715,13 @@ export const de: Catalog = {
"audio": "Audio",
"Loop animation": "Animationsschleife",
"solid colour": "Volltonfarbe",
+ "⌘S rewrites this file in place": "⌘S überschreibt diese Datei direkt",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S speichert eine Kopie — dieser Browser kann die Datei nicht direkt überschreiben",
+ "Open {name}? Unsaved changes in this deck will be lost.": "{name} öffnen? Nicht gespeicherte Änderungen in dieser Präsentation gehen verloren.",
+ "{name} isn’t a Bento document.": "{name} ist kein Bento-Dokument.",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} ist passwortgeschützt. Öffnen Sie die Datei direkt, um sie zu entsperren.",
+ "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.",
}
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index 76026f30..6fecc1e9 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -715,4 +715,13 @@ export const es: Catalog = {
"audio": "audio",
"Loop animation": "Animación en bucle",
"solid colour": "color sólido",
+ "⌘S rewrites this file in place": "⌘S reescribe este archivo en el sitio",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S guarda una copia: este navegador no puede reescribir el archivo en el sitio",
+ "Open {name}? Unsaved changes in this deck will be lost.": "¿Abrir {name}? Se perderán los cambios sin guardar de esta presentación.",
+ "{name} isn’t a Bento document.": "{name} no es un documento de Bento.",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} está protegido con contraseña. Ábrelo directamente para desbloquearlo.",
+ "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.",
}
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 264a5758..6f473421 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -715,4 +715,13 @@ export const fr: Catalog = {
"audio": "audio",
"Loop animation": "Animation en boucle",
"solid colour": "couleur unie",
+ "⌘S rewrites this file in place": "⌘S réécrit ce fichier sur place",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S enregistre une copie — ce navigateur ne peut pas réécrire le fichier sur place",
+ "Open {name}? Unsaved changes in this deck will be lost.": "Ouvrir {name} ? Les modifications non enregistrées de cette présentation seront perdues.",
+ "{name} isn’t a Bento document.": "{name} n’est pas un document Bento.",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} est protégé par mot de passe. Ouvrez-le directement pour le déverrouiller.",
+ "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.",
}
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index 1c68f6f2..e39c434a 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -715,4 +715,13 @@ export const it: Catalog = {
"audio": "audio",
"Loop animation": "Animazione in loop",
"solid colour": "tinta unita",
+ "⌘S rewrites this file in place": "⌘S riscrive questo file sul posto",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S salva una copia — questo browser non può riscrivere il file sul posto",
+ "Open {name}? Unsaved changes in this deck will be lost.": "Aprire {name}? Le modifiche non salvate di questa presentazione andranno perse.",
+ "{name} isn’t a Bento document.": "{name} non è un documento Bento.",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} è protetto da password. Aprilo direttamente per sbloccarlo.",
+ "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.",
}
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index d1808e62..7a75b58c 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -715,4 +715,13 @@ export const ja: Catalog = {
"audio": "音声",
"Loop animation": "ループアニメーション",
"solid colour": "単色",
+ "⌘S rewrites this file in place": "⌘S はこのファイルを上書き保存します",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S はコピーを保存します — このブラウザはファイルを直接上書きできません",
+ "Open {name}? Unsaved changes in this deck will be lost.": "{name} を開きますか?このデッキの未保存の変更は失われます。",
+ "{name} isn’t a Bento document.": "{name} は Bento ドキュメントではありません。",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} はパスワードで保護されています。直接開いてロックを解除してください。",
+ "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} にはまだ保存された書類がありません。直接開いて作成してください。",
}
diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.ts
index 8447b29b..b5f14e72 100644
--- a/slides/src/i18n/packed.ts
+++ b/slides/src/i18n/packed.ts
@@ -721,4 +721,13 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"audio": ["音声","音频","音訊","audio","audio","Audio","audio","áudio"],
"Loop animation": ["ループアニメーション","循环动画","循環動畫","Animación en bucle","Animation en boucle","Animationsschleife","Animazione in loop","Animação em loop"],
"solid colour": ["単色","纯色","純色","color sólido","couleur unie","Volltonfarbe","tinta unita","cor sólida"],
+ "⌘S rewrites this file in place": ["⌘S はこのファイルを上書き保存します","⌘S 直接覆写此文件","⌘S 直接覆寫此檔案","⌘S reescribe este archivo en el sitio","⌘S réécrit ce fichier sur place","⌘S überschreibt diese Datei direkt","⌘S riscrive questo file sul posto","⌘S reescreve este ficheiro no local"],
+ "⌘S saves a copy — this browser can’t rewrite the file in place": ["⌘S はコピーを保存します — このブラウザはファイルを直接上書きできません","⌘S 保存副本 — 此浏览器无法直接覆写文件","⌘S 儲存副本 — 此瀏覽器無法直接覆寫檔案","⌘S guarda una copia: este navegador no puede reescribir el archivo en el sitio","⌘S enregistre une copie — ce navigateur ne peut pas réécrire le fichier sur place","⌘S speichert eine Kopie — dieser Browser kann die Datei nicht direkt überschreiben","⌘S salva una copia — questo browser non può riscrivere il file sul posto","⌘S guarda uma cópia — este navegador não consegue reescrever o ficheiro no local"],
+ "Open {name}? Unsaved changes in this deck will be lost.": ["{name} を開きますか?このデッキの未保存の変更は失われます。","打开 {name}?此演示文稿中未保存的更改将丢失。","開啟 {name}?此簡報中未儲存的變更將遺失。","¿Abrir {name}? Se perderán los cambios sin guardar de esta presentación.","Ouvrir {name} ? Les modifications non enregistrées de cette présentation seront perdues.","{name} öffnen? Nicht gespeicherte Änderungen in dieser Präsentation gehen verloren.","Aprire {name}? Le modifiche non salvate di questa presentazione andranno perse.","Abrir {name}? As alterações não guardadas desta apresentação serão perdidas."],
+ "{name} isn’t a Bento document.": ["{name} は Bento ドキュメントではありません。","{name} 不是 Bento 文档。","{name} 不是 Bento 文件。","{name} no es un documento de Bento.","{name} n’est pas un document Bento.","{name} ist kein Bento-Dokument.","{name} non è un documento Bento.","{name} não é um documento Bento."],
+ "{name} is password-protected. Open it directly to unlock it.": ["{name} はパスワードで保護されています。直接開いてロックを解除してください。","{name} 受密码保护。请直接打开以解锁。","{name} 受密碼保護。請直接開啟以解鎖。","{name} está protegido con contraseña. Ábrelo directamente para desbloquearlo.","{name} est protégé par mot de passe. Ouvrez-le directement pour le déverrouiller.","{name} ist passwortgeschützt. Öffnen Sie die Datei direkt, um sie zu entsperren.","{name} è protetto da password. Aprilo direttamente per sbloccarlo.","{name} está protegido por palavra-passe. Abra-o diretamente para o desbloquear."],
+ "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."],
}
diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.ts
index 36fe9c19..bf301427 100644
--- a/slides/src/i18n/pt.ts
+++ b/slides/src/i18n/pt.ts
@@ -710,4 +710,13 @@ export const pt: Catalog = {
"audio": "áudio",
"Loop animation": "Animação em loop",
"solid colour": "cor sólida",
+ "⌘S rewrites this file in place": "⌘S reescreve este ficheiro no local",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S guarda uma cópia — este navegador não consegue reescrever o ficheiro no local",
+ "Open {name}? Unsaved changes in this deck will be lost.": "Abrir {name}? As alterações não guardadas desta apresentação serão perdidas.",
+ "{name} isn’t a Bento document.": "{name} não é um documento Bento.",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} está protegido por palavra-passe. Abra-o diretamente para o desbloquear.",
+ "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.",
}
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 7a2ddd99..c27d3182 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -715,4 +715,13 @@ export const zhHans: Catalog = {
"audio": "音频",
"Loop animation": "循环动画",
"solid colour": "纯色",
+ "⌘S rewrites this file in place": "⌘S 直接覆写此文件",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S 保存副本 — 此浏览器无法直接覆写文件",
+ "Open {name}? Unsaved changes in this deck will be lost.": "打开 {name}?此演示文稿中未保存的更改将丢失。",
+ "{name} isn’t a Bento document.": "{name} 不是 Bento 文档。",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} 受密码保护。请直接打开以解锁。",
+ "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} 中还没有已保存的文稿 — 请直接打开以创建。",
}
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index c295acd7..f4d6d125 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -715,4 +715,13 @@ export const zhHant: Catalog = {
"audio": "音訊",
"Loop animation": "循環動畫",
"solid colour": "純色",
+ "⌘S rewrites this file in place": "⌘S 直接覆寫此檔案",
+ "⌘S saves a copy — this browser can’t rewrite the file in place": "⌘S 儲存副本 — 此瀏覽器無法直接覆寫檔案",
+ "Open {name}? Unsaved changes in this deck will be lost.": "開啟 {name}?此簡報中未儲存的變更將遺失。",
+ "{name} isn’t a Bento document.": "{name} 不是 Bento 文件。",
+ "{name} is password-protected. Open it directly to unlock it.": "{name} 受密碼保護。請直接開啟以解鎖。",
+ "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} 中還沒有已儲存的文件 — 請直接開啟以建立。",
}
diff --git a/slides/src/styles.css b/slides/src/styles.css
index 4b884826..2df1960c 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -131,6 +131,28 @@ option { background: #fff; color: #1e2a3a; }
.ed-title:hover { border-color: var(--line); }
.ed-title:focus { border-color: var(--blue); outline: none; background: #fff; }
+/* The file this deck is open AS — quieter than the deck title beside it.
+ Shows the BASE name only: every Bento file ends in ".bento.html", so the
+ extension is the one part that identifies nothing (a first attempt truncated
+ from the right and rendered "…tml", which is worse than showing nothing).
+ Never shrinks — it competed with the title input and squeezed it to "Bento S"
+ — and it leaves the bar entirely at the same width the button labels do. */
+.ed-filechip {
+ font-size: 12px;
+ color: var(--muted);
+ padding: 4px 8px;
+ border-radius: 6px;
+ background: var(--sunk, rgba(127, 127, 127, .08));
+ max-width: 160px;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ flex-shrink: 0;
+ cursor: default;
+}
+.ed-filechip[hidden] { display: none; }
+@media (max-width: 1200px) { .ed-filechip { display: none; } }
+
/* unsaved-changes dot — badges the SAVE button's corner (amber when dirty) */
.ed-dirty {
position: absolute;