Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

spaces: every dialog and both side panels are the kernel's (replaces #564) (#645)

nyblnetee390d17a2a5
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 17351099..a8a1c3ce 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -8257,3 +8257,47 @@ Both ends, because an embed can reach the live document by a path neither end
sees alone (a peer's sync op, a document stored before intake was scrubbed).
A document's OWN `collab` is untouched by any of this; that is the file's.
`test-type-embed.ts`, `test-type-share.ts` and `test-export-secrets.ts` pin it.
+
+## 2026-09-26 — Spaces adopts the kernel dialog and panel; spaces keeps panel persistence
+
+**Every modal in bento/spaces is `createDialog`** (kernel/src/ui/dialog.ts):
+About, the shortcut sheet, Search, Link to page, Link card, Import and its
+reports, Export page as a space, Print, and the graph. The graph's module now
+returns its content, and the editor wraps it. Spaces' `.sp-overlay`/`.sp-card`
+shell, its per-dialog Escape and Tab handlers, and About's hand-written focus
+trap are deleted. `scripts/test-spaces-chrome.ts` asserts that no spaces file
+builds a modal by hand.
+
+What this fixed, measured on the built shell:
+- Tab left the Import dialog 23 times in 25.
+- Escape worked only while focus was inside the card.
+- The shortcut sheet focused its own card and ringed the whole dialog.
+
+The dialog heading is the primitive's `.bkd-title` at 17px/650 (D4). Section
+captions keep the 11px uppercase style. About has no visible title: the suite's
+lockup heads it, as in slides, and the dialog is named by `aria-label`.
+
+**Both side panels are `createPanel`** (kernel/src/ui/panel.ts), with
+`drawerBelow: 820`. That is the per-app parameter D6 rules for; slides uses
+700. Spaces' two hand-copied resizers, chevrons and phone drawer rules are
+deleted.
+
+**Persistence stays in spaces.** The panels get no `storageKey`. The primitive
+persists `collapsed` in drawer mode too. A phone drawer shut by following a
+link would then become the desktop preference, and the page list would stay
+shut on every later desktop open. That is the bug `closeDrawer()` was written
+to prevent. Instead, the editor writes the keys readers already have
+(`bento-sp-pane`, `bento-sp-pane-closed`, `bento-sp-insp`,
+`bento-sp-insp-closed`), and only while a panel is a column. Nothing migrates,
+and no reader's layout resets. The primitive has no scrim, so spaces adds one
+behind an open drawer. A drawer you can shut only from the button that opened
+it gets left open over the page.
+
+**Kernel gaps, written down rather than forked:**
+- `createPanel` should not persist while it is a drawer.
+- `createPanel` needs an optional scrim.
+- The panel's chevron needs a localizable label. Spaces sets `title` and
+ `aria-label` after creation.
+
+**Cost:** +1,234 B of shell (284,627 → 285,861, `ZOPFLI=0`). The deleted
+dialog and panel code is smaller than the kernel sheets that replace it.
diff --git a/scripts/test-spaces-chrome.ts b/scripts/test-spaces-chrome.ts
index 42d76e69..7049038f 100644
--- a/scripts/test-spaces-chrome.ts
+++ b/scripts/test-spaces-chrome.ts
@@ -76,6 +76,10 @@ const guardAt = onKey.indexOf(`if (document.querySelector('[aria-modal="true"]')
const firstShortcut = onKey.indexOf("e.key.toLowerCase() === 'k'")
ok(guardAt > 0 && guardAt < firstShortcut,
'the editor\'s keymap stands down under a modal BEFORE any global shortcut is read')
+const handDialogs = files.filter((f) => /'sp-overlay|setAttribute\('aria-modal'/.test(read(f)))
+ok(handDialogs.length === 0, `no file hand-builds a modal overlay any more — every one is createDialog (found in: ${handDialogs.join(', ') || 'none'})`)
+ok(/createPanel\(/.test(editor) && !/private makeResizer\(/.test(editor) && !/sp-pane-tab/.test(css),
+ 'both side panels are the kernel panel; spaces\' own resizer and chevron are gone')
// ————— browser half ————————————————————————————————————————————————————————
console.log('\nthe built shell, driven with trusted input\n')
@@ -246,7 +250,67 @@ async function browser(chrome: string, html: string): Promise<void> {
const underModal = await js<any>(`({ side: document.querySelector('.sp-side').className, modals: document.querySelectorAll('[aria-modal="true"]').length })`)
ok(underModal.side === side0 && underModal.modals === 1,
`under About, \`[\` and \`?\` do nothing behind it (page list ${underModal.side === side0 ? 'unchanged' : 'TOGGLED'}, ${underModal.modals} modal open)`)
+ // focus is on <body> here (blurred above): Escape must still reach the dialog
await key('Escape', 0, 'Escape')
+ const aboutGone = await js<boolean>(`!document.querySelector('[aria-modal="true"]')`)
+ ok(aboutGone, 'Escape closes About with the focus nowhere in it')
+ if (!aboutGone) throw new Error('About did not close; the steps after this need the page')
+
+ // ——— dialogs: the kernel's ———
+ const MODAL = `[...document.querySelectorAll('[aria-modal="true"]')].find(d => d.getBoundingClientRect().height > 0)`
+ await tap(TRIG('More'))
+ await tap(`[...document.querySelectorAll('.bkm-open .bkm-item')].find(b => b.textContent.startsWith('Import Markdown'))`)
+ const title = await js<any>(`(() => { const d = ${MODAL}; const h = d && d.querySelector('.bkd-title'); if (!h) return null; const c = getComputedStyle(h); return { text: h.textContent, size: c.fontSize, weight: c.fontWeight, labelled: document.getElementById(d.getAttribute('aria-labelledby') || '') === h } })()`)
+ ok(title && title.size === '17px' && title.weight === '650' && title.labelled,
+ `a dialog opens on a real title, 17px/650, wired to aria-labelledby (D4) (${JSON.stringify(title)})`)
+ let outside = 0
+ for (let i = 0; i < 20; i++) {
+ await key('Tab', 0, 'Tab', 9)
+ if (!(await js<boolean>(`(${MODAL})?.contains(document.activeElement) ?? false`))) outside++
+ }
+ ok(outside === 0, `Tab never leaves an open dialog (${outside} of 20 presses landed outside; 23 of 25 did before)`)
+ const blank = await js<any>(`(() => { const r = (${MODAL}).getBoundingClientRect(); return { x: r.right - 12, y: r.bottom - 8 } })()`)
+ await click(blank.x, blank.y)
+ // …and with focus nowhere at all: the old handler hung off the backdrop, so
+ // Escape worked only while focus was inside the card
+ await js(`document.activeElement?.blur?.(); 1`)
+ await key('Escape', 0, 'Escape')
+ ok(!(await js<boolean>(`!!(${MODAL})`)), 'Escape closes a dialog wherever the focus is (it only worked with focus in the card)')
+
+ await js(`document.activeElement?.blur?.(); 1`)
+ await key('?', 8, 'Slash', 191)
+ const ring = await js<any>(`(() => { const d = ${MODAL}; const c = getComputedStyle(d); return { outline: c.outlineStyle, focusIn: d.contains(document.activeElement) } })()`)
+ ok(ring.outline === 'none', `the shortcut sheet does not ring the whole card when it opens (outline ${ring.outline})`)
+ await key('Escape', 0, 'Escape')
+
+ await key('k', await MOD(), 'KeyK', 75)
+ await send('Input.insertText', { text: 'page' })
+ await sleep(250)
+ await key('ArrowDown', 0, 'ArrowDown')
+ const srch = await js<any>(`({ sel: [...document.querySelectorAll('.sp-result')].findIndex(r => r.getAttribute('aria-selected') === 'true'), focusInInput: document.activeElement?.tagName === 'INPUT' })`)
+ ok(srch.sel === 1 && srch.focusInInput, `ArrowDown walks the search results while the query keeps focus (${JSON.stringify(srch)})`)
+ await key('Escape', 0, 'Escape')
+
+ // ——— panels: the kernel's ———
+ await js(`document.activeElement?.blur?.(); 1`)
+ const side = `document.querySelector('.sp-side').closest('.bkp')`
+ const w0 = await js<number>(`(${side}).getBoundingClientRect().width`)
+ await key('[', 0, 'BracketLeft', 219)
+ await sleep(350) // the width animates (.14s); measure where it lands
+ const shut = await js<any>(`(() => { const t = (${side}).querySelector('.bkp-toggle').getBoundingClientRect(); return { w: (${side}).getBoundingClientRect().width, chev: Math.round(t.x), exp: (${side}).querySelector('.bkp-toggle').getAttribute('aria-expanded') } })()`)
+ ok(w0 > 200 && shut.w === 0 && shut.chev === 0 && shut.exp === 'false',
+ `\`[\` collapses the page list to nothing, its chevron docked at the edge (${w0} → ${shut.w}px, chevron at x=${shut.chev})`)
+ await key('[', 0, 'BracketLeft', 219)
+ await sleep(350)
+ const strip = await js<any>(`(() => { const r = (${side}).querySelector('.bkp-resizer').getBoundingClientRect(); return { x: r.x + r.width / 2, y: r.y + 150 } })()`)
+ await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: strip.x, y: strip.y })
+ await send('Input.dispatchMouseEvent', { type: 'mousePressed', x: strip.x, y: strip.y, button: 'left', clickCount: 1 })
+ for (let i = 1; i <= 6; i++) { await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: strip.x + i * 10, y: strip.y, button: 'left', buttons: 1 }); await sleep(20) }
+ await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: strip.x + 60, y: strip.y, button: 'left', clickCount: 1 })
+ await sleep(200)
+ const dragged = await js<any>(`({ w: Math.round((${side}).getBoundingClientRect().width), stored: localStorage.getItem('bento-sp-pane') })`)
+ ok(Math.abs(dragged.w - (w0 + 60)) <= 2 && dragged.stored === String(dragged.w),
+ `dragging the strip widens the page list and remembers it for this reader (${w0} → ${dragged.w}, stored ${dragged.stored})`)
// ——— phone ———
await open(true)
@@ -262,6 +326,18 @@ async function browser(chrome: string, html: string): Promise<void> {
const sheet = await js<any>(`(() => { const m = ${OPEN}; if (!m) return null; const r = m.getBoundingClientRect(); return { bottom: r.bottom, vh: innerHeight, w: r.width, vw: innerWidth, minH: Math.min(...[...m.querySelectorAll('.bkm-item')].map(x => x.getBoundingClientRect().height)) } })()`)
ok(sheet && sheet.vh - sheet.bottom <= 12 && sheet.w >= sheet.vw - 20 && sheet.minH >= 44,
`on a phone the block menu is a bottom sheet of 44px rows (${JSON.stringify(sheet)})`)
+ await key('Escape', 0, 'Escape')
+
+ // the page list is a DRAWER here: opened from the bar, dimmed behind, shut
+ // by following a page — and none of that is the reader's desktop preference
+ await tap(`[...document.querySelectorAll('.sp-bar button')].find(b => (b.getAttribute('aria-label') || '').startsWith('Pages'))`)
+ const drawer = await js<any>(`(() => { const p = document.querySelector('.sp-side').closest('.bkp'); const r = p.getBoundingClientRect(); const row = document.querySelectorAll('.sp-treelink')[1].getBoundingClientRect(); return { drawer: p.classList.contains('bkp-drawer'), w: r.width, scrim: !!document.querySelector('.sp-scrim'), reach: !!document.elementFromPoint(row.x + 20, row.y + row.height / 2)?.closest('.sp-treelink') } })()`)
+ ok(drawer.drawer && drawer.w > 200 && drawer.scrim && drawer.reach,
+ `on a phone the page list opens as a drawer over a scrim, its rows reachable (${JSON.stringify(drawer)})`)
+ await tap(`document.querySelectorAll('.sp-treelink')[1]`)
+ const afterNav = await js<any>(`({ w: document.querySelector('.sp-side').closest('.bkp').getBoundingClientRect().width, scrim: !!document.querySelector('.sp-scrim'), stored: localStorage.getItem('bento-sp-pane-closed') })`)
+ ok(afterNav.w === 0 && !afterNav.scrim && afterNav.stored === null,
+ `following a page shuts the drawer and its scrim, and writes nothing to the desktop preference (${JSON.stringify(afterNav)})`)
ws.close()
} finally {
try { child.kill('SIGKILL') } catch { /* gone */ }
diff --git a/scripts/test-spaces-model.ts b/scripts/test-spaces-model.ts
index 8d747873..aafd0a0e 100644
--- a/scripts/test-spaces-model.ts
+++ b/scripts/test-spaces-model.ts
@@ -484,7 +484,9 @@ for (const [label, input, err] of [
const from = ed.indexOf('const groups: Array<[string, Array<[string, string]>]>')
const table = ed.slice(from, ed.indexOf("const grid = el('div', 'sp-keys-grid')", from))
const letters = new Set<string>()
- for (const m of table.matchAll(/'[⌘⇧⌥]*⌘([A-Z])'/g)) letters.add(m[1].toLowerCase())
+ // the sheet spells every chord through keys() (D8's one formatter), so a
+ // chord is `M(…'mod'…, 'X')`
+ for (const m of table.matchAll(/M\([^)]*'mod', '([A-Z])'\)/g)) letters.add(m[1].toLowerCase())
ok(letters.size >= 8, `the list actually names shortcuts (${letters.size} found)`)
for (const c of [...letters].sort()) {
// Both spellings the file uses: the long `e.key.toLowerCase() === 'x'` of
@@ -1693,23 +1695,32 @@ function fsTable(f: string): string {
const css = fsp.readFileSync(new URL('../spaces/src/styles.css', import.meta.url), 'utf8')
const ic = fsp.readFileSync(new URL('../spaces/src/icons.ts', import.meta.url), 'utf8')
- ok(/makeResizer\(\)/.test(ed), 'the page list has a resizer strip')
- ok(/col-resize/.test(css), '…that resizes')
- ok(/dblclick[\s\S]{0,200}PANE_DEFAULT/.test(ed), '…double-click resets it to the default width')
- ok(/PANE_MIN[\s\S]{0,400}PANE_MAX/.test(ed) || /Math\.min\(Editor\.PANE_MAX/.test(ed),
- '…and the width is clamped')
- ok(/localStorage\.setItem\('bento-sp-pane'/.test(ed),
- 'the width is the READER\'s — localStorage, never the document')
-
- ok(/sp-pane-tab/.test(css) && /sp-pane-closed/.test(css), 'the panel collapses from a tab on the strip')
- const tabRule = css.slice(css.indexOf('.sp-pane-tab {'), css.indexOf('}', css.indexOf('.sp-pane-tab {')))
- ok(!/opacity:\s*0\b/.test(tabRule), 'the collapse chevron is visible without hovering')
- ok(/\.sp-side\.sp-pane-closed \+ \.sp-resizer \.sp-pane-tab/.test(css),
+ // THE PANELS ARE THE KERNEL'S (kernel/src/ui/panel.ts): its strip resizes,
+ // double-click resets to `defaultWidth`, it clamps to min/max, and its
+ // chevron rides the strip. What spaces still owns is asserted here.
+ const kpanel = fsp.readFileSync(new URL('../kernel/src/ui/panel.ts', import.meta.url), 'utf8')
+ const kcss = fsp.readFileSync(new URL('../kernel/src/ui/panel.css', import.meta.url), 'utf8')
+ ok(/createPanel\(\{[\s\S]{0,240}defaultWidth: o\.def, minWidth: o\.min, maxWidth: o\.max/.test(ed),
+ 'the page list is a kernel panel with a default and a clamped width')
+ ok(/addEventListener\('dblclick'[\s\S]{0,120}resetWidth\(\)/.test(kpanel) && /col-resize/.test(kcss),
+ '…whose strip resizes, and double-click resets it to the default width')
+ ok(/localStorage\.setItem\(o\.widthKey/.test(ed) && /widthKey: 'bento-sp-pane'/.test(ed),
+ 'the width is the READER\'s — localStorage under the key readers already have, never the document')
+ ok(!/storageKey:/.test(ed.slice(ed.indexOf('private makePanel('), ed.indexOf('private syncScrim('))),
+ '…written by the editor, not the primitive, so a phone drawer never persists a desktop preference')
+ ok(/if \(!this\.isDrawer\(\)\) \{\s*\n\s*try \{\s*\n\s*localStorage\.setItem\(o\.widthKey/.test(ed),
+ '…and only while the panel is a column')
+
+ const tabRule = kcss.slice(kcss.indexOf('.bkp-toggle {'), kcss.indexOf('}', kcss.indexOf('.bkp-toggle {')))
+ ok(tabRule.length > 20 && !/opacity:\s*0\b/.test(tabRule), 'the collapse chevron is visible without hovering')
+ ok(/\.bkp-start\.bkp-collapsed \.bkp-toggle \{ left: 0;/.test(css),
'…and stays reachable when the panel is closed, docked to the edge')
// the drawer breakpoint keeps its overlay behaviour: a 0px column on a phone
- // would leave nothing to reopen from
- ok(/isDrawer\(\)[\s\S]{0,120}max-width: 820px/.test(ed), 'below 820px the panel is a drawer, not a column')
+ // would leave nothing to reopen from. ONE number, handed to the kernel (D6).
+ ok(/const DRAWER_BELOW = 820/.test(ed) && /drawerBelow: DRAWER_BELOW/.test(ed) &&
+ /isDrawer\(\)[\s\S]{0,120}max-width: \$\{DRAWER_BELOW\}px/.test(ed),
+ 'below 820px the panel is a drawer, not a column — one breakpoint, the kernel\'s parameter')
// the suite's undo/redo, not a circular arrow that reads as "reload"
ok(/M9 14 4 9l5-5/.test(ic) && /m15 14 5-5-5-5/.test(ic),
@@ -2864,18 +2875,19 @@ function fsTable(f: string): string {
'the properties panel is CLOSED by default')
ok(/localStorage\.getItem\('bento-sp-insp-closed'\) !== '0'/.test(editor),
"…and only an explicit '0' opens it, so an absent preference is still closed")
- ok(/localStorage\.setItem\('bento-sp-insp-closed'/.test(editor),
+ ok(/closedKey: 'bento-sp-insp-closed'/.test(editor) && /localStorage\.setItem\(o\.closedKey/.test(editor),
'the open/closed state PERSISTS, so it is chosen once and not every session')
// 2. WHILE CLOSED IT TAKES NO WIDTH. `.sp-main` is `flex: 1 1 auto`, so a
// closed panel that zeroes its basis, its inline padding and its border is
// a panel the reading column cannot feel. Any one of the three left in
// place is width off the page on every screen.
- const shut = css.slice(css.indexOf('.sp-insp.sp-pane-closed'))
- const rule = shut.slice(0, shut.indexOf('}') + 1)
- ok(/flex-basis:\s*0/.test(rule), 'a closed properties panel has flex-basis 0')
- ok(/padding-inline:\s*0/.test(rule), '…no inline padding')
- ok(/border-inline-start-width:\s*0/.test(rule), '…and no border')
+ // (The panel is the kernel's now: a collapsed panel is `--bkp-collapsed-w`
+ // wide, its content is display:none, and spaces sets the width to 0.)
+ ok(/--bkp-collapsed-w:\s*0px/.test(css), 'a closed properties panel is 0px wide')
+ const kc = fsTable('../../kernel/src/ui/panel.css')
+ ok(/\.bkp-collapsed > \.bkp-content \{ display: none; \}/.test(kc), '…its content takes no room')
+ ok(/\.bkp\.bkp-collapsed \{ border-inline-width: 0; \}/.test(css), '…and no border')
ok(/\.sp-main \{\s*\n?\s*flex: 1 1 auto/.test(css),
'the reading column is flex:1 1 auto, so the width a closed panel gives up goes back to it')
@@ -2887,11 +2899,12 @@ function fsTable(f: string): string {
// 4. BELOW THE DRAWER BREAKPOINT IT IS AN OVERLAY, not a third column — the
// bargain the page list already makes at the same 820px.
- const phone = css.slice(css.indexOf('@media (max-width: 820px) {\n .sp-insp-rz'))
- ok(/\.sp-insp \{ display: none; \}/.test(phone.slice(0, 400)),
- 'below 820px the panel is absent until asked for')
- ok(/\.sp-insp\.sp-open \{[^}]*position: fixed/.test(phone.slice(0, 800)),
- '…and then it is a fixed overlay, never a column')
+ ok(/if \(mql\?\.matches\) collapsed = true/.test(fsTable('../../kernel/src/ui/panel.ts')) &&
+ /drawerBelow: DRAWER_BELOW/.test(editor),
+ 'below 820px the panel is absent until asked for (a drawer boots shut)')
+ ok(/\.bkp-drawer \{[^}]*position: absolute/.test(fsTable('../../kernel/src/ui/panel.css')) &&
+ /\.sp-body \{[^}]*position: relative/.test(css),
+ '…and then it is an overlay of the page, never a column')
// 5. THE ACCORDION IS SLIDES', including the persisted-per-title open state,
// so a section added below is collapsible without anyone remembering.
diff --git a/spaces/CHANGELOG.md b/spaces/CHANGELOG.md
index 8bf46d18..2c2cf5bf 100644
--- a/spaces/CHANGELOG.md
+++ b/spaces/CHANGELOG.md
@@ -563,6 +563,25 @@ Versions follow `0.MINOR.PATCH` while pre-1.0.
closes with Escape wherever the focus is, not only while it is inside the
card. The graph view puts focus in its card, not on the dimmed page behind it.
+- **Every dialog and both side panels are the suite's.** About, the keyboard
+ shortcuts, Search, Link to page, Link card, Import, the import reports,
+ Export page as a space, Print and the graph now use the kernel's dialog. Each
+ one keeps the keyboard inside it: Tab used to leave the import dialog on 23
+ presses out of 25. Escape closes any of them wherever the focus is. Each opens
+ on a real title (17px, D4) rather than a small grey caption, with the
+ corner, shadow and scrim slides uses.
+ - The shortcut sheet no longer draws a blue ring around itself when it opens.
+ Its shortcuts are written in one order, ⌃⌥⇧⌘.
+ - In Search and in Link to page, the arrow keys move through the results while
+ you keep typing, and Enter opens the highlighted one. Before, a result could
+ only be reached with Tab.
+
+ The page list and the properties panel are the kernel's side panel. You drag
+ the edge to resize, double-click it to reset, and use the chevron to close or
+ open. Below 820px each panel is a drawer over the page. Your widths and
+ open/closed choices are kept exactly as before, under the same keys. Opening
+ and closing the drawer on a phone never changes what a desktop remembers.
+
## [0.1.0] — 2026-08-03
First release.
diff --git a/spaces/src/about.ts b/spaces/src/about.ts
index 8749727d..0bceaee5 100644
--- a/spaces/src/about.ts
+++ b/spaces/src/about.ts
@@ -22,9 +22,10 @@
// panel, every confirmation) opens IN FLOW as a block of the list, and the
// card scrolls to it. A 250px popover anchored inside a scrolling menu is
// the bug that cost this project a day in slides' phone chrome.
-// · `.sp-overlay` carries z-index 60, which is a CEILING on every descendant
-// rather than merely an order. Nothing in this dialog tries to escape it,
-// and nothing added later can be made to by raising its own z-index.
+// · The kernel dialog's scrim carries a z-index (1000, above every menu),
+// and that is a CEILING on every descendant rather than merely an order.
+// Nothing in this dialog tries to escape it, and nothing added later can
+// be made to by raising its own z-index.
import {
checkForUpdates, applyUpdate, canUpdateInPlace,
@@ -36,6 +37,8 @@ import {
canWriteInPlace, openedFileName,
} from '../../kernel/src/save.ts'
import { clearVersions, clearRecovery, listVersions, type Snapshot } from '../../kernel/src/autosave.ts'
+import { createDialog, type Dialog } from '../../kernel/src/ui/dialog.ts'
+import '../../kernel/src/ui/dialog.css'
import { t, localeChoices, locale, setLocale } from './i18n'
import { appearanceSection } from './appearance'
import { esc, textOf } from './sanitize'
@@ -118,27 +121,18 @@ export async function launchUpdateCheck(): Promise<void> {
export function openAbout(hooks: AboutHooks): void {
const { store, onRepaint, onSaveCopy, onImport, onExportSpace, onWriteCopy, onStatus, onUpdateInPlace, onBeforeWrite } = hooks
const doc = store.doc
- const returnFocus = document.activeElement as HTMLElement | null
- const back = document.createElement('div')
- back.className = 'sp-overlay sp-overlay-about'
+ // THE KERNEL'S DIALOG (kernel/src/ui/dialog.ts) is the shell; `card` is its
+ // content. The primitive took the three things this file used to hand-roll —
+ // a capture-phase document Escape (a <select> steals focus, so an Escape on
+ // the card itself stopped working), the Tab trap, focus returned to the
+ // opener — and adds the scrim above every menu. No visible title, as in
+ // slides: the suite's lockup below IS the heading, and the dialog is named
+ // for a screen reader instead.
const card = document.createElement('div')
- card.className = 'sp-card sp-about'
- card.setAttribute('role', 'dialog')
- card.setAttribute('aria-modal', 'true')
- card.setAttribute('aria-label', t('About this space'))
-
- const close = () => {
- back.remove()
- document.removeEventListener('keydown', onKey, true)
- returnFocus?.focus?.()
- }
- // Capture-phase and on the DOCUMENT, as slides does: a dialog whose Escape
- // handler hangs off its own element stops working the moment focus leaves it
- // — which a <select> dropdown does on every platform.
- const onKey = (e: KeyboardEvent) => {
- if (e.key === 'Escape') { e.stopPropagation(); close() }
- }
+ card.className = 'sp-about'
+ let dlg: Dialog | null = null
+ const close = () => dlg?.close()
// ---- small builders ----------------------------------------------------
const h = (text: string) => {
@@ -745,25 +739,10 @@ export function openAbout(hooks: AboutHooks): void {
foot.append(button(t('Close'), close, true))
card.append(foot)
- // ---- focus ---------------------------------------------------------------
- // Trapped, because this is a modal: Tab off either end wraps rather than
- // walking into an editor the reader cannot see.
- card.addEventListener('keydown', (e) => {
- if (e.key !== 'Tab') return
- const f = [...card.querySelectorAll<HTMLElement>(
- 'a[href], button:not([disabled]), input:not([disabled]), select, textarea')]
- .filter((el) => el.offsetParent !== null)
- if (!f.length) return
- const first = f[0]
- const last = f[f.length - 1]
- if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus() }
- else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus() }
- })
-
- back.append(card)
- back.addEventListener('mousedown', (e) => { if (e.target === back) close() })
- document.addEventListener('keydown', onKey, true)
- document.body.append(back)
+ dlg = createDialog({ label: t('About this space'), content: card })
+ dlg.card.classList.add('sp-dlg', 'sp-dlg-about')
+ dlg.open()
+ // the one control the dialog opens FOR, not the logo link the trap would pick
checkBtn.focus()
}
diff --git a/spaces/src/editor.ts b/spaces/src/editor.ts
index 39b3d050..c507e8cf 100644
--- a/spaces/src/editor.ts
+++ b/spaces/src/editor.ts
@@ -46,6 +46,10 @@ import { startSharing } from '../../kernel/src/sync/online.ts'
import * as shareModule from './share.ts'
import { ICONS, type IconName } from './icons'
import { barMenu, anchoredMenu, row, caption, extra, keys, type Menu } from './menus.ts'
+import { createDialog, type Dialog } from '../../kernel/src/ui/dialog.ts'
+import '../../kernel/src/ui/dialog.css'
+import { createPanel, type Panel } from '../../kernel/src/ui/panel.ts'
+import '../../kernel/src/ui/panel.css'
import { PropsPanel } from './props'
import {
internAsset, prepareImage, humanBytes, IMAGE_EMBED_BUDGET, MEDIA_EMBED_BUDGET, blobToDataUri,
@@ -59,6 +63,14 @@ const CTRL = navigator.platform.toLowerCase().includes('mac') ? 'metaKey' : 'ctr
const AUTOFORMAT = MD_SPECS
const SLASH_ITEMS = MENU_SPECS
+/**
+ * Below this width both side panels are DRAWERS over the page, not columns.
+ * One number, handed to the kernel panel as `drawerBelow` (D6: the breakpoint
+ * is a per-app parameter of the shared primitive). Spaces' is 820, not slides'
+ * 700: a reading column needs more room beside a panel than a canvas does
+ * (DECISIONS 2026-08-10, "the drawer breakpoint, not 720").
+ */
+const DRAWER_BELOW = 820
/**
* A block's markdown trigger, when its hint IS one ("#", "1.", "```") — the
* shortcut an Insert row prints right-aligned. A hint that is a description
@@ -143,7 +155,8 @@ export class Editor {
private readB: HTMLButtonElement | null = null
private redoB!: HTMLButtonElement
private dirtyDot!: HTMLElement
- private paneTab: HTMLButtonElement | null = null
+ private pagesPanel: Panel | null = null
+ private inspPanel: Panel | null = null
private static readonly PANE_MIN = 150
private static readonly PANE_MAX = 420
private static readonly PANE_DEFAULT = 244
@@ -154,8 +167,6 @@ export class Editor {
// this reader has opened it. See props.ts on why the default is that way
// round.
private inspector!: HTMLElement
- private inspTab: HTMLButtonElement | null = null
- private inspRz: HTMLElement | null = null
private props: PropsPanel | null = null
private static readonly INSP_MIN = 200
private static readonly INSP_MAX = 420
@@ -227,7 +238,6 @@ export class Editor {
main: () => this.main,
editable: () => !this.store.readOnly && !this.reading && !this.overlay,
})
- if (this.paneClosed) this.sidebar.classList.add('sp-pane-closed')
this.props = new PropsPanel(this.inspector, {
store: this.store,
target: () => this.inspOn,
@@ -521,15 +531,26 @@ export class Editor {
this.inspector = el('aside', 'sp-insp')
this.inspector.setAttribute('aria-label', t('Properties'))
- if (this.inspClosed) this.inspector.classList.add('sp-pane-closed')
const body = el('div', 'sp-body')
- body.append(this.sidebar, this.makeResizer(), this.main, this.makeInspResizer(), this.inspector)
+ this.pagesPanel = this.makePanel(this.sidebar, {
+ side: 'start', label: t('Pages'),
+ def: Editor.PANE_DEFAULT, min: Editor.PANE_MIN, max: Editor.PANE_MAX,
+ width: this.paneW, collapsed: this.paneClosed,
+ widthKey: 'bento-sp-pane', closedKey: 'bento-sp-pane-closed',
+ show: t('Show the page list ([)'), hide: t('Hide the page list ([)'),
+ })
+ // CLOSED UNLESS THIS READER OPENED IT (see the constructor): `collapsed`
+ // is the stored preference, and absent means shut.
+ this.inspPanel = this.makePanel(this.inspector, {
+ side: 'end', label: t('Properties'),
+ def: Editor.INSP_DEFAULT, min: Editor.INSP_MIN, max: Editor.INSP_MAX,
+ width: this.inspW, collapsed: this.inspClosed,
+ widthKey: 'bento-sp-insp', closedKey: 'bento-sp-insp-closed',
+ show: t('Show properties (])'), hide: t('Hide properties (])'),
+ })
+ body.append(this.pagesPanel.root, this.main, this.inspPanel.root)
this.root.append(bar, body)
- this.applyPaneWidth()
- this.syncPaneChevron()
- this.applyInspWidth()
- this.syncInspChevron()
// WHICH BLOCK THE PANEL MEANS. Capture-phase on the page, because the
// interesting blocks are the ones with no editable host to focus — a table,
@@ -606,184 +627,89 @@ export class Editor {
}
- /** Open/close the page drawer on narrow screens, with a scrim to tap away. */
/**
- * The strip between the page list and the page: drag to resize, chevron to
- * collapse, double-click to reset. Slides' pattern, and its reasoning — the
- * control that hides a panel belongs ON the panel's edge, where you are
- * already looking, not in a toolbar across the room.
+ * A side panel: the kernel's (kernel/src/ui/panel.ts). The strip on its inner
+ * edge resizes it (double-click resets), the chevron on the strip collapses
+ * it, it docks flush when shut, it widens the other way under RTL, and below
+ * the drawer breakpoint it is an overlay rather than a column — every one of
+ * which spaces had hand-built, twice over (one copy per panel).
*
- * The width is the reader's, so it lives in localStorage, never the document.
+ * WHAT STAYS HERE, deliberately:
+ * · PERSISTENCE. The primitive persists its collapsed state in drawer mode
+ * too, and a phone drawer shut by following a link would then leave the
+ * page list shut on the desktop, for good — the bug `closeDrawer` exists
+ * to prevent. So no `storageKey`: the editor writes the reader's own keys
+ * (`bento-sp-pane`, `bento-sp-insp` and their `-closed`) and only when the
+ * panel is a column. The keys are the ones every reader already has, so
+ * nothing is migrated and nobody's layout resets.
+ * · The SCRIM behind a drawer (the primitive has none): a drawer you can
+ * only shut from the button that opened it is one people leave open over
+ * the page they wanted to read.
+ * · The chevron's words — the primitive is language-free.
*/
- private makeResizer(): HTMLElement {
- const handle = el('div', 'sp-resizer')
- handle.title = t('Drag to resize · double-click to reset')
-
- const tab = document.createElement('button')
- tab.className = 'sp-pane-tab'
- tab.type = 'button'
- tab.addEventListener('click', (e) => { e.stopPropagation(); this.togglePane() })
- this.paneTab = tab
- handle.append(tab)
-
- handle.addEventListener('mousedown', (down) => {
- if (down.target === tab) return // the chevron is a click, not a drag
- if (this.paneClosed) return
- down.preventDefault()
- const startX = down.clientX
- const startW = this.paneW
- this.sidebar.classList.add('sp-noanim')
- document.body.classList.add('sp-col-resizing')
- const move = (ev: MouseEvent) => {
- // clientX is physical; which way widens depends on the edge the panel
- // is docked to, and RTL swaps that over.
- const dx = ev.clientX - startX
- const widens = document.dir === 'rtl' ? -dx : dx
- this.paneW = Math.min(Editor.PANE_MAX, Math.max(Editor.PANE_MIN, startW + widens))
- this.applyPaneWidth()
- }
- const up = () => {
- window.removeEventListener('mousemove', move)
- window.removeEventListener('mouseup', up)
- this.sidebar.classList.remove('sp-noanim')
- document.body.classList.remove('sp-col-resizing')
- try { localStorage.setItem('bento-sp-pane', String(this.paneW)) } catch { /* storage can throw */ }
- }
- window.addEventListener('mousemove', move)
- window.addEventListener('mouseup', up)
- })
-
- handle.addEventListener('dblclick', () => {
- this.paneW = Editor.PANE_DEFAULT
- this.applyPaneWidth()
- try { localStorage.setItem('bento-sp-pane', String(this.paneW)) } catch { /* storage can throw */ }
+ private makePanel(content: HTMLElement, o: {
+ side: 'start' | 'end'; label: string; def: number; min: number; max: number
+ width: number; collapsed: boolean; widthKey: string; closedKey: string
+ show: string; hide: string
+ }): Panel {
+ const p = createPanel({
+ content, side: o.side, label: o.label,
+ defaultWidth: o.def, minWidth: o.min, maxWidth: o.max,
+ collapsed: o.collapsed, drawerBelow: DRAWER_BELOW,
})
- return handle
- }
-
- private applyPaneWidth(): void {
- this.sidebar.style.setProperty('--sp-panew', `${this.paneW}px`)
- }
-
- /**
- * The properties panel's edge — the page list's strip, mirrored.
- *
- * Deliberately a second small method rather than a parameterised one: the two
- * differ in which direction widens (the panel is docked to the END edge, so a
- * drag toward the start makes it bigger) and in which way the chevron points,
- * and a `side` flag threaded through both would be harder to read than this.
- */
- private makeInspResizer(): HTMLElement {
- const handle = el('div', 'sp-resizer sp-insp-rz')
- handle.title = t('Drag to resize · double-click to reset')
- if (this.inspClosed) handle.classList.add('sp-shut')
- this.inspRz = handle
-
- const tab = document.createElement('button')
- tab.className = 'sp-pane-tab'
- tab.type = 'button'
- tab.addEventListener('click', (e) => { e.stopPropagation(); this.toggleInsp() })
- this.inspTab = tab
- handle.append(tab)
-
- handle.addEventListener('mousedown', (down) => {
- if (down.target === tab) return
- if (this.inspClosed) return
- down.preventDefault()
- const startX = down.clientX
- const startW = this.inspW
- this.inspector.classList.add('sp-noanim')
- document.body.classList.add('sp-col-resizing')
- const move = (ev: MouseEvent) => {
- // the panel is on the END edge, so dragging toward the START widens it
- const dx = startX - ev.clientX
- const widens = document.dir === 'rtl' ? -dx : dx
- this.inspW = Math.min(Editor.INSP_MAX, Math.max(Editor.INSP_MIN, startW + widens))
- this.applyInspWidth()
- }
- const up = () => {
- window.removeEventListener('mousemove', move)
- window.removeEventListener('mouseup', up)
- this.inspector.classList.remove('sp-noanim')
- document.body.classList.remove('sp-col-resizing')
- try { localStorage.setItem('bento-sp-insp', String(this.inspW)) } catch { /* storage can throw */ }
+ p.setWidth(o.width)
+ p.resizer.title = t('Drag to resize · double-click to reset')
+ const chev = p.resizer.querySelector<HTMLElement>('.bkp-toggle')
+ const sync = () => {
+ const label = p.collapsed ? o.show : o.hide
+ if (chev) { chev.title = label; chev.setAttribute('aria-label', label) }
+ if (!this.isDrawer()) {
+ try {
+ localStorage.setItem(o.widthKey, String(p.width))
+ // '0' is OPEN and '1' is shut, for both panels: the page list reads
+ // '1' as shut and the properties panel reads anything but '0' as shut
+ localStorage.setItem(o.closedKey, p.collapsed ? '1' : '0')
+ } catch { /* storage can throw; the defaults are fine */ }
}
- window.addEventListener('mousemove', move)
- window.addEventListener('mouseup', up)
- })
-
- handle.addEventListener('dblclick', () => {
- this.inspW = Editor.INSP_DEFAULT
- this.applyInspWidth()
- try { localStorage.setItem('bento-sp-insp', String(this.inspW)) } catch { /* storage can throw */ }
- })
- return handle
- }
-
- private applyInspWidth(): void {
- this.inspector.style.setProperty('--sp-inspw', `${this.inspW}px`)
+ this.syncScrim()
+ }
+ p.onChange(sync)
+ sync()
+ return p
}
- private syncInspChevron(): void {
- if (!this.inspTab) return
- const rtl = document.dir === 'rtl'
- // points the way it will MOVE the panel
- const closing = this.inspClosed === rtl
- this.inspTab.innerHTML = closing ? ICONS.chevronRight : ICONS.chevronLeft
- this.inspTab.title = this.inspClosed ? t('Show properties (])') : t('Hide properties (])')
- this.inspTab.setAttribute('aria-label', this.inspTab.title)
- this.inspTab.setAttribute('aria-expanded', String(!this.inspClosed))
+ /** The dim behind an open drawer, and the tap that shuts it. */
+ private syncScrim(): void {
+ const open = this.isDrawer() &&
+ ((this.pagesPanel && !this.pagesPanel.collapsed) || (this.inspPanel && !this.inspPanel.collapsed))
+ let scrim = document.querySelector<HTMLElement>('.sp-scrim')
+ if (!open) { scrim?.remove(); return }
+ if (scrim) return
+ scrim = el('div', 'sp-scrim')
+ scrim.addEventListener('click', () => { this.pagesPanel?.collapse(); this.inspPanel?.collapse() })
+ document.body.append(scrim)
}
- /** Collapse or restore the properties panel. On a phone it is an overlay. */
+ /** Collapse or restore the properties panel — a column, or on a phone a drawer. */
toggleInsp(force?: boolean): void {
- if (this.isDrawer()) {
- const open = force !== undefined ? force : !this.inspector.classList.contains('sp-open')
- this.inspector.classList.toggle('sp-open', open)
- // The same scrim the page list gets, for the same reason: an overlay you
- // can only close from the menu you opened it from is one people leave
- // open over the page they wanted to read.
- document.querySelector('.sp-scrim')?.remove()
- if (open) {
- const scrim = el('div', 'sp-scrim')
- scrim.addEventListener('click', () => this.toggleInsp(false))
- document.body.append(scrim)
- }
- return
- }
- this.inspector.classList.remove('sp-open')
- this.inspClosed = force !== undefined ? !force : !this.inspClosed
- this.inspector.classList.toggle('sp-pane-closed', this.inspClosed)
- this.inspRz?.classList.toggle('sp-shut', this.inspClosed)
- this.syncInspChevron()
- // '0' means OPEN. Absent is closed, which is what a reader who has never
- // touched this gets — see the constructor.
- try { localStorage.setItem('bento-sp-insp-closed', this.inspClosed ? '1' : '0') } catch { /* storage can throw */ }
- }
-
- private syncPaneChevron(): void {
- if (!this.paneTab) return
- // points the way it will MOVE the panel, which is the only thing a chevron
- // can usefully mean
- const rtl = document.dir === 'rtl'
- const closing = this.paneClosed !== rtl
- this.paneTab.innerHTML = closing ? ICONS.chevronRight : ICONS.chevronLeft
- this.paneTab.title = this.paneClosed ? t('Show the page list ([)') : t('Hide the page list ([)')
- this.paneTab.setAttribute('aria-label', this.paneTab.title)
- this.paneTab.setAttribute('aria-expanded', String(!this.paneClosed))
+ const p = this.inspPanel
+ if (!p) return
+ if (force === undefined) p.toggle()
+ else if (force) p.expand()
+ else p.collapse()
}
- /** Collapse or restore the page list. On a phone it is a drawer instead. */
+ /** Collapse or restore the page list — a column, or on a phone a drawer. */
togglePane(force?: boolean): void {
- if (this.isDrawer()) { this.toggleSidebar(force); return }
- this.paneClosed = force !== undefined ? !force : !this.paneClosed
- this.sidebar.classList.toggle('sp-pane-closed', this.paneClosed)
- this.syncPaneChevron()
- try { localStorage.setItem('bento-sp-pane-closed', this.paneClosed ? '1' : '0') } catch { /* storage can throw */ }
+ const p = this.pagesPanel
+ if (!p) return
+ if (force === undefined) p.toggle()
+ else if (force) p.expand()
+ else p.collapse()
}
private isDrawer(): boolean {
- return window.matchMedia('(max-width: 820px)').matches
+ return window.matchMedia(`(max-width: ${DRAWER_BELOW}px)`).matches
}
/**
@@ -859,19 +785,9 @@ export class Editor {
if (this.isDrawer()) this.toggleSidebar(false)
}
+ /** One page-list control for every width: the panel is a column or a drawer by itself. */
private toggleSidebar(force?: boolean): void {
- // Below the drawer breakpoint the panel is an overlay, not a column: the
- // page needs the whole width, so collapsing to a 0px column would leave
- // nothing to reopen it from.
- if (!this.isDrawer()) { this.togglePane(force); return }
- const open = force ?? !this.sidebar.classList.contains('sp-open')
- this.sidebar.classList.toggle('sp-open', open)
- document.querySelector('.sp-scrim')?.remove()
- if (open) {
- const scrim = el('div', 'sp-scrim')
- scrim.addEventListener('click', () => this.toggleSidebar(false))
- document.body.append(scrim)
- }
+ this.togglePane(force)
}
/**
@@ -3213,29 +3129,44 @@ export class Editor {
}
// ---- overlays -----------------------------------------------------------
- private openOverlay(title: string, build: (body: HTMLElement, close: () => void) => void): void {
+ /**
+ * A MODAL, on the kernel's dialog (kernel/src/ui/dialog.ts).
+ *
+ * The primitive brings what spaces' own overlay lacked, each measured on the
+ * built shell before this: a focus TRAP (Tab left the import dialog 23 times
+ * in 25), Escape on the document rather than on the backdrop (one click on
+ * the card's blank space used to leave a dialog the keyboard could not
+ * close), `aria-modal` + `aria-labelledby`, focus returned to the opener, and
+ * a scrim above every menu. The title is the dialog's HEADING — 17px/650,
+ * the D4 ruling — where each dialog used to open on an 11px uppercase
+ * caption; captions are for sections.
+ *
+ * It is still the editor's one overlay: `this.overlay` gates the keymap, and
+ * closeOverlay() takes it down with everything it registered.
+ */
+ private openOverlay(
+ title: string, build: (body: HTMLElement, close: () => void) => void,
+ o: { wide?: boolean; top?: boolean; className?: string } = {},
+ ): Dialog {
this.closeOverlay()
- const back = el('div', 'sp-overlay')
- const card = el('div', 'sp-card')
- card.setAttribute('role', 'dialog')
- card.setAttribute('aria-modal', 'true')
- card.setAttribute('aria-label', title)
- const close = () => this.closeOverlay()
- build(card, close)
- back.append(card)
- back.addEventListener('mousedown', (e) => { if (e.target === back) close() })
- document.body.append(back)
- this.overlay = back
- // On the DOCUMENT, capture-phase: hung off the backdrop, Escape worked only
- // while focus was inside the card, and one click on the card's blank space
- // left a dialog you could not dismiss from the keyboard.
- const onEsc = (e: KeyboardEvent) => {
- if (e.key !== 'Escape' || this.overlay !== back) return
- e.preventDefault(); e.stopPropagation(); close()
- }
- document.addEventListener('keydown', onEsc, true)
- this.overlayOff.push(() => document.removeEventListener('keydown', onEsc, true))
- card.querySelector<HTMLElement>('input,button,[tabindex]')?.focus()
+ const body = el('div', 'sp-dlg-body' + (o.className ? ' ' + o.className : ''))
+ let d: Dialog | null = null
+ const close = () => d?.close()
+ build(body, close)
+ d = createDialog({
+ title, content: body,
+ onClose: () => { if (d && this.overlay === d.root) this.closeOverlay() },
+ })
+ d.card.classList.add('sp-dlg')
+ if (o.wide) d.card.classList.add('sp-dlg-wide')
+ // a palette (search, find a page) sits high and grows downward, so its
+ // results do not re-centre the card under the pointer on every keystroke
+ if (o.top) d.root.classList.add('sp-dlg-top')
+ d.open()
+ this.overlay = d.root
+ const dd = d
+ this.overlayOff.push(() => dd.close())
+ return d
}
/**
@@ -3247,100 +3178,72 @@ export class Editor {
* rather than the page. The starter space describes the same keys in prose,
* but the starter is a document — the first thing many people do is delete
* it, and the reference should not go with it.
- *
- * Built on .sp-overlay/.sp-card, the About dialog's shell, so it inherits
- * the dialog's scrim, escape handling and focus return rather than growing a
- * second set.
+ * (That is the sheet openHelp() builds, below the graph.)
*/
/**
* The space as a picture: pages, and the links between them.
*
- * The DRAWING lives in graph.ts; what is here is only what an overlay is in
- * this editor — one at a time, and it owns the keyboard while it is open
- * (`this.overlay`). Teardown rides on `overlayOff`, which is the list
- * `closeOverlay` already calls before it removes the node: the graph has
- * observers and an animation frame to give back, and there is no second
- * teardown path to forget about.
+ * The DRAWING lives in graph.ts; the modal around it is the kernel dialog,
+ * like every other one here. Teardown rides on `overlayOff`, which
+ * closeOverlay() always runs: the graph has observers and an animation frame
+ * to give back, and there is no second teardown path to forget about.
*/
openGraph(): void {
this.closeOverlay()
- const returnFocus = document.activeElement as HTMLElement | null
+ const close = () => this.closeOverlay()
const view = openGraphView({
doc: this.store.doc,
index: this.store.index,
currentId: this.store.pageId,
open: (id) => { close(); this.store.goToPage(id); this.repaint() },
- close: () => close(),
+ close,
})
- const close = () => {
- this.closeOverlay()
- returnFocus?.focus?.()
- }
- const onKey = (e: KeyboardEvent) => {
- if (e.key === 'Escape') { e.stopPropagation(); close() }
- }
- document.addEventListener('keydown', onKey, true)
- this.overlay = view.el
- // the key handler leaves with the graph however it closes — closed by
- // another overlay opening, it used to stay on the document
- this.overlayOff.push(() => view.destroy(), () => document.removeEventListener('keydown', onKey, true))
- document.body.append(view.el)
- // focus goes INTO the card, not onto the scrim behind it
- const card = view.el.querySelector<HTMLElement>('[role=dialog]') ?? view.el
- card.tabIndex = -1
- card.focus()
+ let d: Dialog | null = null
+ d = createDialog({
+ label: t('Graph'), content: view.el,
+ onClose: () => { if (d && this.overlay === d.root) this.closeOverlay() },
+ })
+ d.card.classList.add('sp-dlg', 'sp-dlg-graph')
+ d.open()
+ this.overlay = d.root
+ const dd = d
+ this.overlayOff.push(() => view.destroy(), () => dd.close())
}
openHelp(): void {
- this.closeOverlay()
- const returnFocus = document.activeElement as HTMLElement | null
- const back = el('div', 'sp-overlay')
- const card = el('div', 'sp-card sp-keys')
- card.setAttribute('role', 'dialog')
- card.setAttribute('aria-modal', 'true')
- card.setAttribute('aria-label', t('Keyboard shortcuts'))
-
- const close = () => {
- back.remove()
- document.removeEventListener('keydown', onKey, true)
- returnFocus?.focus?.()
- }
- const onKey = (e: KeyboardEvent) => {
- if (e.key === 'Escape') { e.stopPropagation(); close() }
- }
-
- const h = el('h2', 'sp-card-h', t('Keyboard shortcuts'))
- card.append(h)
-
+ // Every key below is written by keys(), the one place the suite's order
+ // (⌃⌥⇧⌘, D8) lives. This sheet was typed by hand and disagreed with
+ // itself — ⇧⌘S beside ⌘⇧J — and with the menus.
+ const M = (...k: string[]) => keys(...k)
const groups: Array<[string, Array<[string, string]>]> = [
[t('Writing'), [
['↵', t('A new block')],
- ['Tab / ⇧Tab', t('Indent, or move back out')],
+ [`Tab / ${M('shift')}Tab`, t('Indent, or move back out')],
['/', t('The block menu, on an empty line')],
['[[', t('Link to another page')],
- ['⌘Z / ⇧⌘Z', t('Undo, redo')],
+ [`${M('mod', 'Z')} / ${M('shift', 'mod', 'Z')}`, t('Undo, redo')],
]],
[t('Formatting'), [
- ['⌘B', t('Bold')],
- ['⌘I', t('Italic')],
- ['⌘U', t('Underline')],
- ['⇧⌘S', t('Strikethrough')],
- ['⌘E', t('Code')],
- ['⇧⌘H', t('Highlight')],
- ['⌘K', t('Link the selected words')],
+ [M('mod', 'B'), t('Bold')],
+ [M('mod', 'I'), t('Italic')],
+ [M('mod', 'U'), t('Underline')],
+ [M('shift', 'mod', 'S'), t('Strikethrough')],
+ [M('mod', 'E'), t('Code')],
+ [M('shift', 'mod', 'H'), t('Highlight')],
+ [M('mod', 'K'), t('Link the selected words')],
]],
[t('Getting around'), [
- ['⌘K', t('Search all pages, with nothing selected')],
- ['⌘F', t('Find and replace')],
- ['⌘⌥N', t('New page')],
- ['⌘⇧J', t("Today's journal")],
- ['⌘⇧I', t('New issue')],
+ [M('mod', 'K'), t('Search all pages, with nothing selected')],
+ [M('mod', 'F'), t('Find and replace')],
+ [M('alt', 'mod', 'N'), t('New page')],
+ [M('shift', 'mod', 'J'), t("Today's journal")],
+ [M('shift', 'mod', 'I'), t('New issue')],
]],
[t('The workspace'), [
['[', t('Show or hide the page list')],
[']', t('Show or hide properties')],
- ['⌘S', t('Save')],
- ['⌘P', t('Print or save as PDF')],
+ [M('mod', 'S'), t('Save')],
+ [M('mod', 'P'), t('Print or save as PDF')],
['?', t('This list')],
['Esc', t('Leave the reading view')],
]],
@@ -3348,30 +3251,28 @@ export class Editor {
// Two columns where there is room. In one column the four groups run to
// 23 rows and the last three fall off the bottom of the card — a help
- // screen that hides the help, which is the same defect this pass just took
- // out of the share panel. The grid collapses to one column on a phone,
+ // screen that hides the help. The grid collapses to one column on a phone,
// where scrolling a list is what you expect anyway.
- const grid = el('div', 'sp-keys-grid')
- for (const [title, rows] of groups) {
- const g = el('section', 'sp-keys-g')
- g.append(el('h3', 'sp-keys-h', title))
- const list = el('dl', 'sp-keys-list')
- for (const [key, what] of rows) {
- const dt = el('dt', '', '')
- dt.append(el('kbd', 'sp-kbd', key))
- list.append(dt, el('dd', '', what))
+ //
+ // On the kernel dialog like every other modal: the card no longer takes
+ // the focus itself, which painted a 2px ring round the whole sheet on
+ // open, and `?` pressed again cannot stack a second copy.
+ this.openOverlay(t('Keyboard shortcuts'), (card) => {
+ const grid = el('div', 'sp-keys-grid')
+ for (const [title, rows] of groups) {
+ const g = el('section', 'sp-keys-g')
+ g.append(el('h3', 'sp-keys-h', title))
+ const list = el('dl', 'sp-keys-list')
+ for (const [key, what] of rows) {
+ const dt = el('dt', '', '')
+ dt.append(el('kbd', 'sp-kbd', key))
+ list.append(dt, el('dd', '', what))
+ }
+ g.append(list)
+ grid.append(g)
}
- g.append(list)
- grid.append(g)
- }
- card.append(grid)
-
- back.append(card)
- back.addEventListener('click', (e) => { if (e.target === back) close() })
- document.addEventListener('keydown', onKey, true)
- document.body.append(back)
- card.tabIndex = -1
- card.focus()
+ card.append(grid)
+ }, { wide: true, className: 'sp-keys' })
}
/**
@@ -3536,7 +3437,7 @@ export class Editor {
/** ⌘K — search every page, including collapsed toggles and archived pages. */
openSearch(): void {
const s = this.store
- this.openOverlay(t('Search'), (card, close) => {
+ this.openOverlay(t('Search this space'), (card, close) => {
const input = document.createElement('input')
input.className = 'sp-find'
input.placeholder = t('Search all pages…')
@@ -3569,13 +3470,31 @@ export class Editor {
results.append(li)
}
if (!results.childElementCount) results.append(el('li', 'sp-noresult', t('Nothing found')))
+ at = 0
+ mark()
}
+ // THE ARROWS MOVE THE HIGHLIGHT, the query keeps the focus — the / menu's
+ // pattern. They did nothing here: a result was reachable only by Tab,
+ // which walks past it into the rest of the card.
+ let at = 0
+ const rows = () => [...results.querySelectorAll<HTMLElement>('.sp-result')]
+ const mark = () => {
+ rows().forEach((r, i) => {
+ r.classList.toggle('sp-sel', i === at)
+ r.setAttribute('aria-selected', String(i === at))
+ })
+ rows()[at]?.scrollIntoView({ block: 'nearest' })
+ }
+ input.setAttribute('aria-label', t('Search all pages…'))
input.addEventListener('input', run)
input.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') results.querySelector<HTMLElement>('.sp-result')?.click()
+ const n = rows().length
+ if (e.key === 'ArrowDown' && n) { e.preventDefault(); at = (at + 1) % n; mark() }
+ else if (e.key === 'ArrowUp' && n) { e.preventDefault(); at = (at - 1 + n) % n; mark() }
+ else if (e.key === 'Enter') rows()[at]?.click()
})
- card.append(el('h2', 'sp-card-h', t('Search this space')), input, results)
- })
+ card.append(input, results)
+ }, { top: true })
}
/**
@@ -3700,7 +3619,6 @@ export class Editor {
}
this.openOverlay(t('Link card'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Link card')))
const why = document.createElement('p')
why.className = 'sp-note'
@@ -3835,11 +3753,28 @@ export class Editor {
li.append(b)
list.append(li)
}
+ at = 0
+ mark()
}
+ // the same arrows-move-the-highlight as search and the / menu
+ let at = 0
+ const rows = () => [...list.querySelectorAll<HTMLElement>('.sp-result')]
+ const mark = () => rows().forEach((r, i) => {
+ r.classList.toggle('sp-sel', i === at)
+ r.setAttribute('aria-selected', String(i === at))
+ if (i === at) r.scrollIntoView({ block: 'nearest' })
+ })
+ input.setAttribute('aria-label', t('Find or create a page…'))
input.addEventListener('input', run)
+ input.addEventListener('keydown', (e) => {
+ const n = rows().length
+ if (e.key === 'ArrowDown' && n) { e.preventDefault(); at = (at + 1) % n; mark() }
+ else if (e.key === 'ArrowUp' && n) { e.preventDefault(); at = (at - 1 + n) % n; mark() }
+ else if (e.key === 'Enter' && n) { e.preventDefault(); rows()[at]?.click() }
+ })
card.append(input, list)
run()
- })
+ }, { top: true })
}
/** Pick a page icon from the stylised set. */
@@ -4353,7 +4288,6 @@ export class Editor {
*/
openImport(): void {
this.openOverlay(t('Bring notes in'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Bring notes in')))
const what = document.createElement('p')
what.className = 'sp-note'
@@ -4497,7 +4431,6 @@ export class Editor {
this.repaint()
this.openOverlay(t('Imported a space'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Imported a space')))
const lines = [
t('{pages} page(s) and {blocks} block(s) added from that space.',
{ pages: plan.stats.pages, blocks: plan.stats.blocks }),
@@ -4535,7 +4468,6 @@ export class Editor {
openExportSpace(): void {
const s = this.store
this.openOverlay(t('Export a page as a space'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Export a page as a space')))
const what = document.createElement('p')
what.className = 'sp-note'
@@ -4713,8 +4645,7 @@ export class Editor {
this.repaint()
this.status(t('Imported'))
- this.openOverlay(t('Import Markdown'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Imported')))
+ this.openOverlay(t('Imported'), (card, close) => {
const lines: string[] = [
t('{pages} page(s) and {blocks} block(s) added from {files} file(s).',
{ pages: plan.stats.pages, blocks: plan.stats.blocks, files: plan.stats.files }),
@@ -4932,8 +4863,7 @@ export class Editor {
*/
openPrint(): void {
const s = this.store
- this.openOverlay(t('Print'), (card, close) => {
- card.append(el('h2', 'sp-card-h', t('Print or save as PDF')))
+ this.openOverlay(t('Print or save as PDF'), (card, close) => {
const scope = document.createElement('div')
scope.className = 'sp-choices'
diff --git a/spaces/src/graph.ts b/spaces/src/graph.ts
index 5bbe3349..9a16a07c 100644
--- a/spaces/src/graph.ts
+++ b/spaces/src/graph.ts
@@ -351,7 +351,7 @@ export function prefersReducedMotion(): boolean {
* shell's inflated stylesheet taught (kernel/src/save.ts serializeBody).
*/
const CSS = `
-.sp-overlay-graph { align-items: center; padding: 14px; padding-top: 14px; }
+
.sp-graph {
width: min(1180px, calc(100vw - 28px));
height: min(820px, calc(100vh - 28px));
@@ -463,11 +463,9 @@ export function openGraphView(opts: GraphViewOpts): GraphView {
layoutGraph(g)
const layoutMs = performance.now() - t0
- const back = mk('div', 'sp-overlay sp-overlay-graph')
- const card = mk('div', 'sp-card sp-graph')
- card.setAttribute('role', 'dialog')
- card.setAttribute('aria-modal', 'true')
- card.setAttribute('aria-label', t('Graph'))
+ // The CONTENT only. The modal around it — scrim, trap, Escape, focus return —
+ // is the kernel's dialog, which the editor wraps this in.
+ const card = mk('div', 'sp-graph')
const head = mk('div', 'sp-graph-head')
head.append(mk('h2', 'sp-card-h', t('Graph')))
@@ -493,7 +491,6 @@ export function openGraphView(opts: GraphViewOpts): GraphView {
t('Click a page to open it · drag to move · scroll to zoom'))
card.append(head, stage, foot)
- back.append(card)
// ——— camera ———
let scale = 1
@@ -766,7 +763,6 @@ export function openGraphView(opts: GraphViewOpts): GraphView {
fitBtn.addEventListener('click', () => { fit(); draw() })
closeBtn.addEventListener('click', () => opts.close())
- back.addEventListener('click', (e) => { if (e.target === back) opts.close() })
// ——— theme + size, both of which move under us ———
const ro = new ResizeObserver(() => resize())
@@ -801,11 +797,11 @@ export function openGraphView(opts: GraphViewOpts): GraphView {
// Each was checked through these rather than by looking at the screen:
// `frames: 0` beside `reveal: 1` is the proof that a graph opened in a
// background tab still arrives. Six numbers on a node thrown away at close.
- ;(back as unknown as { __graph: unknown }).__graph = {
+ ;(card as unknown as { __graph: unknown }).__graph = {
nodes: g.nodes.length, edges: g.edges.length, layoutMs, reduced,
get reveal() { return reveal },
get frames() { return frames },
}
- return { el: back, destroy, graph: g }
+ return { el: card, destroy, graph: g }
}
diff --git a/spaces/src/i18n/packed.ts b/spaces/src/i18n/packed.ts
index 339d2688..390b7d61 100644
--- a/spaces/src/i18n/packed.ts
+++ b/spaces/src/i18n/packed.ts
@@ -215,7 +215,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Image added, resized to fit ({from} → {to})": ["画像を追加し、収まるように縮小しました({from} → {to})","已添加图片,已缩放以适配 ({from} → {to})","已新增圖片,已縮小尺寸 ({from} → {to})","Imagen añadida, redimensionada para que quepa ({from} → {to})","Image ajoutée, redimensionnée ({from} → {to})","Bild hinzugefügt, passend verkleinert ({from} → {to})","Immagine aggiunta, ridimensionata ({from} → {to})","Imagem adicionada, redimensionada para caber ({from} → {to})"],
"Image from {host}": ["{host} の画像","来自 {host} 的图片","來自 {host} 的圖片","Imagen de {host}","Image provenant de {host}","Bild von {host}","Immagine da {host}","Imagem de {host}"],
"Image not imported": ["画像は取り込まれていません","图片未导入","圖片未匯入","Imagen no importada","Image non importée","Bild nicht importiert","Immagine non importata","Imagem não importada"],
- "Import Markdown": ["Markdown を読み込む","导入 Markdown","匯入 Markdown","Importar Markdown","Importer du Markdown","Markdown importieren","Importa Markdown","Importar Markdown"],
"Import Markdown…": ["Markdown を読み込む…","导入 Markdown…","匯入 Markdown…","Importar Markdown…","Importer du Markdown…","Markdown importieren…","Importa Markdown…","Importar Markdown…"],
"Important": ["重要","重要","重要","Importante","Important","Wichtig","Importante","Importante"],
"Imported": ["読み込みました","已导入","已匯入","Importado","Importé","Importiert","Importato","Importado"],
@@ -344,7 +343,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Poster": ["ポスター","封面图","封面圖","Póster","Affiche","Poster","Poster","Miniatura"],
"Poster…": ["ポスター…","封面图…","封面圖…","Póster…","Affiche…","Poster…","Poster…","Miniatura…"],
"Previous (⇧⏎)": ["前へ (⇧⏎)","上一个 (⇧⏎)","上一個 (⇧⏎)","Anterior (⇧⏎)","Précédent (⇧⏎)","Zurück (⇧⏎)","Precedente (⇧⏎)","Anterior (⇧⏎)"],
- "Print": ["印刷","打印","列印","Imprimir","Imprimer","Drucken","Stampa","Imprimir"],
"Print or save as PDF": ["印刷または PDF として保存","打印或存为 PDF","列印或另存為 PDF","Imprimir o guardar como PDF","Imprimer ou enregistrer en PDF","Drucken oder als PDF speichern","Stampa o salva come PDF","Imprimir ou guardar como PDF"],
"Print…": ["印刷…","打印…","列印…","Imprimir…","Imprimer…","Drucken…","Stampa…","Imprimir…"],
"Properties": ["プロパティ","属性","屬性","Propiedades","Propriétés","Eigenschaften","Proprietà","Propriedades"],
@@ -406,7 +404,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Saved a new copy": ["新しいコピーを保存しました","已保存新副本","已儲存新副本","Se guardó una copia nueva","Nouvelle copie enregistrée","Neue Kopie gespeichert","Salvata una nuova copia","Nova cópia guardada"],
"Saves a copy to send. Whoever opens it edits this space live with you (end-to-end encrypted); you stay the owner and can remove them from the People list.": ["送るためのコピーを保存します。開いた人はこの Space をあなたと一緒にライブ編集できます(エンドツーエンド暗号化)。あなたはオーナーのままで、メンバーリストからいつでも削除できます。","保存一份用于发送的副本。打开的人可与你实时共同编辑此 Space(端到端加密);你仍是所有者,可随时从成员列表中移除他们。","儲存一份用於傳送的副本。開啟的人可與你即時共同編輯此 Space(端對端加密);你仍是擁有者,可隨時從成員列表中移除他們。","Guarda una copia para enviar. Quien la abra editará este Space en vivo contigo (cifrado de extremo a extremo); tú sigues siendo el propietario y puedes quitarlos de la lista de Personas.","Enregistre une copie à envoyer. Qui l’ouvre édite cet espace en direct avec vous (chiffré de bout en bout) ; vous restez propriétaire et pouvez les retirer de la liste Personnes.","Speichert eine Kopie zum Versenden. Wer sie öffnet, bearbeitet diesen Space live mit dir (Ende-zu-Ende-verschlüsselt); du bleibst Eigentümer und kannst sie aus der Personenliste entfernen.","Salva una copia da inviare. Chi la apre modifica questo Space live con te (crittografia end-to-end); resti il proprietario e puoi rimuoverli dall’elenco Persone.","Salva uma cópia para enviar. Quem a abrir edita este Space ao vivo com você (com criptografia de ponta a ponta); você continua sendo o dono e pode removê-la na lista de Pessoas."],
"Saving…": ["保存中…","保存中…","儲存中…","Guardando…","Enregistrement…","Speichere…","Salvataggio…","A guardar…"],
- "Search": ["検索","搜索","搜尋","Buscar","Rechercher","Suche","Cerca","Pesquisar"],
"Search all pages (⌘K)": ["全ページを検索 (⌘K)","搜索所有页面 (⌘K)","搜尋所有頁面 (⌘K)","Buscar en todas las páginas (⌘K)","Rechercher dans toutes les pages (⌘K)","Alle Seiten durchsuchen (⌘K)","Cerca in tutte le pagine (⌘K)","Pesquisar em todas as páginas (⌘K)"],
"Search all pages, with nothing selected": ["何も選択せずに全ページを検索","未选中内容时,搜索所有页面","未選取內容時,搜尋所有頁面","Buscar en todas las páginas, sin nada seleccionado","Rechercher dans toutes les pages, sans sélection","Alle Seiten durchsuchen, wenn nichts markiert ist","Cerca in tutte le pagine, senza nulla selezionato","Pesquisar todas as páginas, sem nada selecionado"],
"Search all pages…": ["全ページを検索…","搜索所有页面…","搜尋所有頁面…","Buscar en todas las páginas…","Rechercher dans toutes les pages…","Alle Seiten durchsuchen…","Cerca in tutte le pagine…","Pesquisar em todas as páginas…"],
diff --git a/spaces/src/styles.css b/spaces/src/styles.css
index eed2417d..599b397c 100644
--- a/spaces/src/styles.css
+++ b/spaces/src/styles.css
@@ -309,15 +309,37 @@ option { background: var(--field); color: var(--ink); }
.sp-primary { background: var(--ink); color: var(--bg); padding: 6px 14px; }
.sp-primary:hover { background: var(--ink-2); }
-.sp-body { display: flex; flex: 1 1 auto; min-height: 0; }
+/* `relative`: a panel below the drawer breakpoint is an absolute overlay of
+ THIS box (the kernel's `.bkp-drawer`), under the bar and over the page. */
+.sp-body { display: flex; flex: 1 1 auto; min-height: 0; position: relative; }
+
+/* ————— the side panels: the kernel's (kernel/src/ui/panel.css) —————
+ Width, resize strip, collapse chevron, RTL, the drawer: all the primitive's,
+ through `--bkp-*`. A closed panel is 0px — the reading column gets its whole
+ width back, which is the bargain the properties panel was built on — and its
+ chevron docks flush to the screen edge so there is always a way back. */
+.sp-app {
+ --bkp-bg: var(--bg);
+ --bkp-collapsed-w: 0px;
+ --bkp-drawer-z: 50;
+ --bkp-drawer-shadow: 0 0 50px rgb(var(--shade) / .3);
+ --bkp-resizer-hover: color-mix(in srgb, var(--blue) 45%, transparent);
+}
+.bkp.bkp-collapsed { border-inline-width: 0; }
+.bkp-start.bkp-collapsed .bkp-toggle { left: 0; transform: translateY(-50%); }
+.bkp-end.bkp-collapsed .bkp-toggle { left: auto; right: 0; transform: translateY(-50%); }
+[dir='rtl'] .bkp-start.bkp-collapsed .bkp-toggle { left: auto; right: 0; }
+[dir='rtl'] .bkp-end.bkp-collapsed .bkp-toggle { right: auto; left: 0; }
+.bkp-toggle { z-index: 15; box-shadow: 0 1px 4px rgb(var(--shade) / .12); }
+.bkp-toggle:hover { color: var(--ink); border-color: var(--edge); }
+/* On a phone the panels are drawers opened from the bar (Pages, and ⋯ →
+ Properties): no strip, no chevron over the page's edge. */
+.bkp-drawer > .bkp-resizer { display: none; }
+.sp-scrim { position: fixed; inset: 0; background: rgb(var(--shade) / .3); z-index: 45; }
/* ————— sidebar ————— */
.sp-side {
- /* the reader's width, restored from localStorage — never the document's */
- flex: 0 0 var(--sp-panew, 244px); min-width: 0;
- transition: flex-basis .18s ease, padding .18s ease;
- border-inline-end: 1px solid var(--line); background: var(--bg);
- overflow: auto; padding: 10px 8px max(16px, env(safe-area-inset-bottom));
+ padding: 10px 8px max(16px, env(safe-area-inset-bottom));
}
.sp-side-head {
display: flex; align-items: center; justify-content: space-between;
@@ -813,17 +835,27 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
.sp-backlink-list a:hover { text-decoration: underline; }
.sp-snippet { color: var(--muted); margin-inline-start: 8px; }
-/* ————— menus + overlays ————— */
-.sp-overlay {
- position: fixed; inset: 0; background: rgb(var(--shade) / .34);
- display: flex; align-items: flex-start; justify-content: center;
- padding-top: 11vh; z-index: 60;
-}
-.sp-card {
- width: min(560px, 92vw); max-height: 72vh; overflow: auto;
- background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
- box-shadow: 0 18px 48px rgb(var(--shade) / .22); padding: 12px;
-}
+/* ————— dialogs: the kernel's (kernel/src/ui/dialog.css) —————
+ Every modal is `createDialog`. Its look comes through `--bkd-*`, set on the
+ root because the scrim is mounted on <body>, outside `.sp-app`. The heading
+ is the kernel's `.bkd-title`, 17px/650 (D4). */
+:root {
+ --bkd-radius: var(--radius-lg);
+ --bkd-shadow: var(--shadow-dlg);
+ --bkd-scrim: var(--scrim);
+ --bkd-body-ink: var(--ink);
+}
+/* Selectors carry `.bkd-*` twice where they override the kernel sheet, which
+ the bundle places after this file. */
+.bkd-card.sp-dlg { width: 560px; }
+.bkd-card.sp-dlg-wide { width: 720px; max-width: min(720px, 100%); }
+.bkd-card.sp-dlg .bkd-title { letter-spacing: -0.005em; }
+/* a palette (search, "link to page") sits high and grows DOWN, so a result
+ list arriving does not re-centre the card under the pointer */
+.bkd-overlay.sp-dlg-top { align-items: flex-start; padding-top: 11vh; }
+/* the graph is a viewer: the whole card is its canvas */
+.bkd-card.sp-dlg-graph { width: auto; max-width: none; padding: 0; overflow: hidden; }
+.bkd-overlay:has(.sp-dlg-graph) { padding: 14px; }
.sp-card-h {
font-size: 11px; font-weight: 600; text-transform: uppercase;
letter-spacing: 0.07em; color: var(--muted); margin: 2px 4px 8px;
@@ -895,15 +927,9 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
BOTH axes (hard-won #10), so a floating child of it would be cut on the left
and the bottom with nothing to show for it. */
.sp-note { color: var(--muted); font-size: 12.5px; margin: 6px 4px 10px; line-height: 1.55; }
-/* The card is a column with its own scroll, sized off the VIEWPORT rather than
- a breakpoint: 375px wide with a 12px gutter and 1600px wide are the same
- rule. `.sp-card`'s 72vh is for a find palette that wants to sit high; a
- dialog this long wants the height, so it takes 88vh and centres. */
-.sp-overlay-about { align-items: center; padding: 12px; padding-top: 12px; }
+/* The kernel dialog's card is the scroller and sizes itself to the viewport
+ (a bottom sheet on a phone); this is the column inside it. */
.sp-about {
- width: min(560px, calc(100vw - 24px));
- max-height: min(88vh, calc(100vh - 24px));
- padding: 18px;
display: flex; flex-direction: column; gap: 2px;
/* Sections are flex items, and a flex item SHRINKS by default — which is how
slides' update block collapsed to its min-height and spilled its children
@@ -1024,19 +1050,6 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
.sp-menu { display: none; }
@media (max-width: 820px) {
.sp-menu { display: inline-flex; }
- /* The drawer is simply absent until asked for. An animated off-canvas panel
- is nicer, and two attempts at one (a logical inset, then a transform) both
- failed to move under measurement — so this ships the version whose
- behaviour is obvious from the rule. A slide-in can come back with a test
- that proves it. */
- .sp-side { display: none; }
- .sp-side.sp-open {
- display: block; position: fixed; inset: 0 auto 0 0; width: 268px;
- z-index: 50; box-shadow: 0 0 50px rgb(var(--shade) / .3);
- padding-top: max(14px, env(safe-area-inset-top));
- }
- [dir='rtl'] .sp-side.sp-open { inset: 0 0 0 auto; }
- .sp-scrim { position: fixed; inset: 0; background: rgb(var(--shade) / .3); z-index: 45; }
.sp-main { --sp-pad-x: 18px; --sp-pad-y: 26px; padding: var(--sp-pad-y) var(--sp-pad-x) 45vh; }
/* THE MARGIN THE GUTTER LIVES IN — see below — and it hangs off the PAGE, not
off `.sp-main`. `.sp-main` is chrome and follows the interface direction;
@@ -1089,7 +1102,7 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
it a dark reader's UA furniture prints dark over our white. */
color-scheme: only light !important;
}
- .sp-bar, .sp-side, .sp-insp, .sp-insp-rz, .sp-banner, .sp-gutter, .sp-scrim, .sp-langchip { display: none !important; }
+ .sp-bar, .bkp, .sp-side, .sp-insp, .sp-banner, .sp-gutter, .sp-scrim, .sp-langchip { display: none !important; }
.sp-tb-tools, .sp-tb-grip { display: none !important; }
.sp-main { overflow: visible; --sp-pad-x: 0px; --sp-pad-y: 0px; padding: 0; background: #fff; }
.sp-toggle-body[hidden] { display: block !important; } /* toggles print OPEN */
@@ -1133,6 +1146,8 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
--radius-sm: 6px; /* inputs, menu rows */
--radius-lg: 14px; /* dialogs and sheets */
--shadow-pop: 0 12px 32px rgb(var(--shade) / .16); /* menus, popovers */
+ --shadow-dlg: 0 18px 50px rgb(var(--shade) / .28); /* dialogs */
+ --scrim: rgb(var(--shade) / .38); /* the dim behind a dialog */
--ctl-h: 30px;
--tap: 44px; /* D5: a coarse pointer's target */
--fs-hint: 12px;
@@ -1421,10 +1436,8 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
/* The shortcut list. Two columns, keys right-aligned against their meanings,
so the eye runs down one edge instead of hunting across a ragged gap. */
-/* wider than the other cards, because this one is a two-column table and
- .sp-card's 560px leaves 534px of content — four pixels short of two 260px
- columns plus the gap, which silently collapsed the grid back to one */
-.sp-keys { width: min(720px, 92vw); max-width: none; }
+/* The sheet opens WIDE (`sp-dlg-wide`, 720px): a 560px card leaves too little
+ for two 260px columns plus the gap, which silently collapsed the grid to one. */
.sp-keys-grid {
display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 0 30px; align-items: start;
@@ -1616,52 +1629,8 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
.sp-about-logo b + span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.sp-about-logo:hover b { text-decoration: underline; }
-/* ————— the panel edge: resize here, collapse here —————
- Slides' pattern, and its reasoning: the control that hides a panel belongs on
- the panel's own edge, where you are already looking, rather than in a toolbar
- across the room. */
-.sp-resizer {
- flex: none; width: 5px; position: relative;
- cursor: col-resize; background: transparent;
- transition: background .12s ease .08s;
-}
-.sp-resizer:hover,
-body.sp-col-resizing .sp-resizer { background: color-mix(in srgb, var(--blue) 45%, transparent); }
+/* the table's column grip borrows the panels' old resize cursor */
body.sp-col-resizing { cursor: col-resize; user-select: none; }
-.sp-noanim { transition: none !important; }
-
-/* The chevron rides the strip and is ALWAYS visible — same as slides. A
- hover-only affordance is one nobody finds: the first version of this faded in
- on hover, so the way to hide the panel was invisible until you happened to
- pass over a 5px strip. */
-.sp-pane-tab {
- position: absolute; top: 50%; left: 50%;
- transform: translate(-50%, -50%);
- width: 16px; height: 44px; padding: 0;
- display: flex; align-items: center; justify-content: center;
- background: var(--surface); color: var(--muted);
- border: 1px solid var(--line); border-radius: 8px;
- cursor: pointer; z-index: 15;
- box-shadow: 0 1px 4px rgb(var(--shade) / .12);
-}
-.sp-pane-tab:hover { color: var(--ink); border-color: var(--edge); }
-.sp-pane-tab svg { width: 13px; height: 13px; display: block; }
-
-/* Collapsed: the panel takes no width and the strip carries only the chevron,
- docked flush to the screen edge so there is always a way back. */
-.sp-side.sp-pane-closed {
- flex-basis: 0; padding-inline: 0; border-inline-end-width: 0; overflow: hidden;
-}
-.sp-side.sp-pane-closed + .sp-resizer { cursor: default; }
-.sp-side.sp-pane-closed + .sp-resizer:hover { background: transparent; }
-.sp-side.sp-pane-closed + .sp-resizer .sp-pane-tab {
- inset-inline-start: 0; left: auto; transform: translateY(-50%);
-}
-
-/* On a phone the panel is a drawer, not a column: no strip, no resizing. */
-@media (max-width: 820px) {
- .sp-resizer { display: none; }
-}
/* THE PAGES BUTTON ONLY EXISTS WHERE THE PANEL IS A DRAWER.
Above the breakpoint the panel has its own chevron, on its own edge, where
@@ -1676,31 +1645,12 @@ body.sp-col-resizing { cursor: col-resize; user-select: none; }
}
/* ————— the properties panel —————
- The sibling of the page list, on the other edge, with the SAME resizer strip
- and the SAME chevron. Two collapse idioms in one window would be two things
- to learn for one behaviour.
-
- IT COSTS NOTHING WHILE CLOSED, and that is the whole point of the rule
- rather than a nicety: the wide-page work that shipped one commit before this
- gives the column the window's slack, and a panel holding 280px of it open by
- default would take that back on every screen. Closed is `flex-basis: 0`, no
- padding and no border — `.sp-main` is `flex: 1 1 auto`, so the column is the
- width it would be if this file did not exist. */
+ The sibling of the page list, on the other edge — the same kernel panel, so
+ the same strip and the same chevron. IT COSTS NOTHING WHILE CLOSED
+ (`--bkp-collapsed-w: 0px` above): the reading column is the width it would
+ be if this panel did not exist. */
.sp-insp {
- flex: 0 0 var(--sp-inspw, 280px); min-width: 0;
- transition: flex-basis .18s ease, padding .18s ease;
- border-inline-start: 1px solid var(--line); background: var(--bg);
- overflow: auto; padding: 10px 10px max(16px, env(safe-area-inset-bottom));
-}
-.sp-insp.sp-pane-closed {
- flex-basis: 0; padding-inline: 0; border-inline-start-width: 0; overflow: hidden;
-}
-/* Mirror of the page list's strip. The chevron docks to the END edge when the
- panel is shut, so there is always a way back in. */
-.sp-insp-rz.sp-shut { cursor: default; }
-.sp-insp-rz.sp-shut:hover { background: transparent; }
-.sp-insp-rz.sp-shut .sp-pane-tab {
- inset-inline-end: 0; left: auto; transform: translateY(-50%);
+ padding: 10px 10px max(16px, env(safe-area-inset-bottom));
}
.sp-insp-title {
@@ -1757,18 +1707,9 @@ body.sp-col-resizing { cursor: col-resize; user-select: none; }
}
.sp-insp .sp-select { max-width: 100%; }
-/* THE SAME BARGAIN THE PAGE LIST MAKES BELOW THE BREAKPOINT: an overlay, not a
- third column. 820px of window does not hold two panels and a page. */
-@media (max-width: 820px) {
- .sp-insp-rz { display: none; }
- .sp-insp { display: none; }
- .sp-insp.sp-open {
- display: block; position: fixed; inset: 0 0 0 auto; width: 288px;
- z-index: 50; box-shadow: 0 0 50px rgb(var(--shade) / .3);
- padding-top: max(14px, env(safe-area-inset-top));
- }
- [dir='rtl'] .sp-insp.sp-open { inset: 0 auto 0 0; }
-}
+/* Below the breakpoint BOTH panels are overlays, not columns — 820px of window
+ does not hold two panels and a page. The kernel panel does that itself
+ (`drawerBelow`, editor.ts DRAWER_BELOW). */
/* THE BUTTON IS SHOWN AT EVERY WIDTH, and this is a correction.
It was hidden above the breakpoint on the reasoning that the chevron on the