Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Merge remote-tracking branch 'origin/main' into claude/rtl-chrome

nyblnet4b5d9c04452a
diff --cc docs/PLATFORM.md
index 442b6581,12a94950..202b57d9
--- a/docs/PLATFORM.md
+++ b/docs/PLATFORM.md
@@@ -123,34 -128,26 +128,54 @@@ see `i18n-packs.md`. Packs are additiv
exactly as before — and both tiers fall back per string to the English key,
which is what lets a stale or partial pack degrade instead of break.
+ Four pack rules are platform-level, not app choices:
+
+ - **A pack lives in the FILE and nowhere else.** No browser-local copy: the
+ download comes from an https origin and the file is then opened from
+ `file://`, so anything stored per-origin vanishes on the journey the product
+ encourages. A pack rides in an `application/bento+lang` block written by
+ `registerShellBlocks` (kernel `save.ts`), under the same `\u003c`-escaping
+ and the same §2 splice contract as `#bento-doc` — `scripts/shell-gate.mjs`
+ proves a pack-carrying shell conformant, with an adversarial pack, on every
+ build.
+ - **Adding is staged, and written on the next save.** Writing on click means a
+ silent second download of the user's deck on every browser without File
+ System Access.
+ - **Self-update carries packs forward** and refreshes them for the incoming
+ version (`registerUpdatePrepare` in kernel `update.ts`), best effort — a pack
+ that cannot be re-fetched is kept, never dropped.
+ - **Fetched packs are verified against the signed release channel; embedded
+ packs are not re-verified** — they carry the same trust as the document
- around them, and opening a file must never require the network. (Design
- settled; the client-side check lands on `claude/i18n-pack-verify`.)
++ around them, and opening a file must never require the network.
++
+### Direction (RTL) — two halves, never confuse them
+
+**Content direction belongs to the DOCUMENT and is per element.** Text
+resolves its own base direction from what the author typed (`dir="auto"` in
+the renderer), so an Arabic paragraph reads RTL beside an English one in the
+same file. This is data: it renders identically for every viewer, and it is
+the half that fixes real bugs (misplaced sentence-final punctuation).
+
+**Chrome direction belongs to the VIEWER and never enters the format.** The
+editor flips to RTL when the viewer's locale is RTL — the same viewer-scoped
+pattern as `bento-lang` and reduce-motion. `applyDirection()` runs AFTER
+`capturePristine()`, so a saved file can never carry a `dir` attribute. Lay
+chrome out with logical properties (`inset-inline-start`, `margin-inline-end`,
+`text-align: start`) and it mirrors itself; only glyphs that encode a
+direction in their SHAPE need flipping by hand.
+
+> **INVARIANT — the document never mirrors.** Elements carry absolute x/y
+> model coordinates, so a document MUST render identically regardless of who
+> opens it. A document whose appearance depends on the viewer's locale is a
+> format-level bug, and a worse outcome than an unmirrored UI. Every surface
+> that renders document content is therefore pinned `direction: ltr`: the
+> document root, thumbnails, the scroller, the present overlay, print, and any
+> body-mounted overlay that reads coordinates (e.g. Moveable's control box,
+> which mounts outside the document subtree and needs its own pin).
+>
+> An app adding a new document-rendering surface MUST pin it. The pin is also
+> what keeps direction away from `scrollLeft` — the one layout API whose
+> meaning genuinely changes under RTL — so coordinate math stays untouched.
## 9. What is kernel vs what is app
diff --cc slides/src/editor/editor.ts
index bc3be1b5,96ace65e..1feb7657
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@@ -23,7 -23,8 +23,8 @@@ import { insertElements, insertSlides,
import { openSpeakerWindow, speakerIdleBody } from '../screens'
import { borderPoint, boxCenter, lineEndpoints, setLineEndpoints, sideMidpoint } from './lineedit'
import { ICONS } from '../icons'
- import { t, setLocale, locale, LOCALE_CHOICES, applyDirection, isRtl } from '../i18n'
-import { t, setLocale, locale, localeChoices, LOCALE_CHOICES } from '../i18n'
++import { t, setLocale, locale, localeChoices, LOCALE_CHOICES, applyDirection, isRtl } from '../i18n'
+ import { availablePacks, fetchPack, markFileSaved, packCoverage, packsInFile, stageForFile, unstageFromFile } from '../packs'
import { appConfig } from '../../../kernel/src/app.ts'
import { disconnectOnline, joinFromDoc, mintCollab, mintInvite, onlineTransport, rotateKeys, sharingOn, startSharing, stopSharing } from '../sync/online'
@@@ -1001,9 -1173,14 +1181,14 @@@ export class Editor
if (c.code === locale()) b.classList.add('ed-lang-on')
menu.appendChild(b)
}
+ menu.appendChild(div('ed-menu-sep'))
+ menu.appendChild(btn('', t('Manage languages…'), () => {
+ wrap.classList.remove('open')
+ void this.openLanguages()
+ }))
- // right-anchor so the menu never overflows the window edge
- menu.style.left = 'auto'
- menu.style.right = '0'
+ // end-anchored so the menu never overflows the window edge — as a class,
+ // not inline left/right, so it follows the chrome's direction (.ed-lang-menu
+ // in styles.css, alongside the Save menu's identical rule)
wrap.append(trigger, menu)
document.addEventListener('pointerdown', (ev) => {
if (!wrap.contains(ev.target as Node)) wrap.classList.remove('open')
diff --cc slides/src/i18n.ts
index 8a90cf20,42ab6088..cfbff59d
--- a/slides/src/i18n.ts
+++ b/slides/src/i18n.ts
@@@ -18,7 -18,10 +18,10 @@@
// node scripts/build-i18n.mjs
//
import { PACKED, PACKED_LOCALES } from './i18n/packed'
+ import { PACK_BLOCK_TYPE, readPacksFromShell, refreshPacksForVersion, shellBlocksForPacks } from './packs'
+ import { registerShellBlocks } from '../../kernel/src/save.ts'
+ import { registerUpdatePrepare } from '../../kernel/src/update.ts'
-import { registerI18n } from '../../kernel/src/i18n.ts'
+import { registerI18n, locale as localeCode } from '../../kernel/src/i18n.ts'
import type { LocaleChoice } from '../../kernel/src/i18n.ts'
export type { Catalog } from '../../kernel/src/i18n.ts'
diff --cc slides/src/styles.css
index 793d6c71,ee1a83b2..1d8b1054
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@@ -2001,33 -1950,36 +2001,65 @@@ dialog.ed-pwdialog .ed-pwerr { color: #
.ed-stepper-val { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
input.ed-toggle { width: 16px; height: 16px; accent-color: #5E7699; cursor: pointer; }
+ /* Languages dialog: built-in vs installed packs vs available to add. */
+ .ed-lang-manage { margin: 10px 0 4px; display: flex; flex-direction: column; gap: 2px; }
+ .ed-lang-sec {
+ font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
+ color: var(--muted); margin: 12px 0 4px;
+ }
+ .ed-lang-row {
+ display: flex; align-items: center; gap: 10px; justify-content: space-between;
+ padding: 7px 0; border-bottom: 1px solid var(--line);
+ }
+ .ed-lang-row:last-child { border-bottom: 0; }
+ .ed-lang-txt { display: flex; flex-direction: column; min-width: 0; }
+ .ed-lang-txt b { font-size: 13px; font-weight: 600; }
+ .ed-lang-txt span { font-size: 11.5px; color: var(--muted); }
+ .ed-lang-blurb { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: -2px 0 6px; }
+ .ed-lang-search {
+ width: 100%; margin: 4px 0 6px; padding: 7px 10px; font-size: 13px;
+ border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
+ }
+ .ed-lang-scroll {
+ max-height: 240px; overflow-y: auto;
+ /* Keep the row's action button clear of the scrollbar — without this the
+ Add button sits flush against it. The stable gutter stops the list
+ shifting sideways when the bar appears or goes. */
+ padding-right: 12px; scrollbar-gutter: stable;
+ }
+ .ed-lang-acts { display: flex; gap: 6px; flex: 0 0 auto; }
+ .ed-lang-acts .ed-btn { white-space: nowrap; }
+ .ed-lang-warn {
+ font-size: 11.5px; line-height: 1.5; color: var(--muted);
+ background: var(--bg); border-left: 2px solid var(--line);
+ padding: 5px 8px; margin: 0 0 6px; border-radius: 0 5px 5px 0;
+/* ————— RTL chrome: the marks that don't flip themselves ————————————————————
+ Logical properties turn the LAYOUT around on their own. These are the few
+ glyphs that encode a direction in their SHAPE, so they have to be flipped by
+ hand. Every selector here is chrome — none of it can reach a slide, which
+ stays LTR-pinned (see the top of this file).
+
+ The speaker view (.sv-*) is deliberately absent: it is a separate window
+ sitting beside the projected show, and it never carries a dir attribute. */
+
+/* Accordion disclosure: a CSS triangle drawn with border-left, pointing "right"
+ at rest. Open (rotated 90°) points down either way; closed must point the way
+ the panel reads. */
+[dir="rtl"] .ed-sec-toggle.closed::before { transform: translateY(-50%) rotate(180deg); }
+
+/* Undo/redo arrows curl back toward where the text came from. */
+[dir="rtl"] .ed-group-history .ed-btn svg { transform: scaleX(-1); }
+
+/* The comment thread's "you are <name>" link rides the far edge of the head. */
+[dir="rtl"] .ed-comment-me { float: left; }
+
+/* Coordinates, sizes and JSON are LTR content whatever the interface language:
+ a base-RTL context renders "-5" as "5-" and reorders a JSON line's brackets.
+ Panel prose and every text field the user writes words into are untouched. */
+[dir="rtl"] .ed-row input[type='number'],
+[dir="rtl"] .ed-mini input,
+[dir="rtl"] .ed-axis-range input,
+[dir="rtl"] .ed-about-json,
+[dir="rtl"] .ed-chart-json {
+ direction: ltr;
}