Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
spaces: the Bases table is edited and sorted in place (#390)
nyblnet78e699c94a19
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex 876ed51e..2a33b804 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -5665,3 +5665,40 @@ Options, none chosen:raised from the bento/type branch during #384 and deliberately NOT decidedthere, which was the right call — a single app's feature branch is the wrongplace to set a cross-app default.++## 2026-08-28 — bento/spaces: a table column sorts, a title column does not++The Bases table became editable and sortable in place: a column header cycles+ascending → descending → none, and a cell opens the same picker the page's own+header strip opens.++Two things settled that another agent could otherwise contradict.++**Unsorted DELETES the key.** The header writes the view's existing `sort`+through the existing `editView`, and the third click passes `undefined` so the+key is removed rather than stored as `[]`. A view sorted and unsorted from its+header is byte-identical to one nobody ever touched. `cycleSort` in fields.ts is+where that third state lives, so it is one function rather than a rule the two+sort controls each have to remember.++**The page-title column is NOT sortable, deliberately.** A view's `sort` names a+FIELD: `sortRows` looks each key up in `doc.fields` and skips what it cannot+find, and `unknownSortKeys` reports the miss as "newer than this build". A+pseudo-key like `{key:'title'}` would therefore be a key EVERY shipped build+reports as unreadable and does not apply — and teaching `sortRows` about a+non-field key means a second ordering mechanism living beside the first, in a+format where both are permanent. One order stored in two shapes is the thing+that later disagrees with itself. The column is a plain `<th>` and does not+pretend otherwise. If title order is wanted later, the honest shape is a real+field, not a special case in the sorter.++**A cell edit can CREATE the prop block**, the way a board drop already could:+`editor.putField` is the one place a page gains a field, and it goes through+`propBlock`, so the readable `html` is written with the value. A table column+exists because SOME row carries that field; the rows that do not get an empty+cell, and editing it is how the field arrives on that page.++The picker was split from `openFieldPicker` into `fieldPicker(f, cur, anchor,+write)` — a picker over a WRITER rather than a block id, because a cell can+stand for a value that has no block yet. The header strip, the board's card chip+and a cell are now one control with three writers, not three controls.diff --git a/scripts/test-spaces-model.ts b/scripts/test-spaces-model.tsindex c0fe24c2..77baba2d 100644--- a/scripts/test-spaces-model.ts+++ b/scripts/test-spaces-model.ts@@ -40,7 +40,7 @@ import {DEFAULT_FIELDS, fieldsOf, fieldByKey, optionOf, propHtml, propBlock,valuesOf, isIssue, issuesOf, headerLength, propBlockOf,passesFilter, filterCount, unknownFilterKeys, phaseField, isOpenPhase, reorderPages,- sortRows, unknownSortKeys, type IssueRow,+ sortRows, unknownSortKeys, sortDirOf, cycleSort, type IssueRow,} from '../spaces/src/fields.ts'import { inlineHtml, parseNote, planImport } from '../spaces/src/markdown.ts'import {@@ -1862,6 +1862,119 @@ function fsTable(f: string): string {'a status from a newer build sorts after every one this build knows')}+// ---- SORTING BY A TABLE COLUMN HEADER --------------------------------------+// A header is the second control that writes `sort`, and the one a reader will+// actually reach for. Two properties, both of which fail silently:+//+// · THE THIRD STATE IS "NONE". A header that only flips between ascending and+// descending can never give a hand-arranged board its order back, and+// "manual order" is not a sort called manual — it is the ABSENCE of the key.+// Storing `sort: []` would satisfy every screen and would still leave a+// view somebody sorted and unsorted permanently different from one nobody+// touched, in a file on somebody else's disk.+//+// · THE ARROW AND THE ORDER READ THE SAME FACT. A header that computed its+// own direction beside the one sortRows applies is a display that can+// disagree with the rows underneath it.+{+ const doc = { fields: DEFAULT_FIELDS } as unknown as SpacesDoc+ const j = (v: unknown) => JSON.stringify(v)++ ok(j(cycleSort(undefined, 'status')) === j([{ key: 'status' }]),+ 'the first click on a column sorts by it, ascending')+ ok(!Object.prototype.hasOwnProperty.call((cycleSort(undefined, 'status') ?? [])[0] ?? {}, 'dir'),+ "…and writes NO `dir`, because absent is what ascending has always meant")+ ok(j(cycleSort([{ key: 'status' }], 'status')) === j([{ key: 'status', dir: 'desc' }]),+ 'the second click reverses it')+ ok(cycleSort([{ key: 'status', dir: 'desc' }], 'status') === undefined,+ 'the third click returns to NO SORT — and says so with undefined, never an empty array')+ ok(j(cycleSort([{ key: 'status', dir: 'desc' }], 'priority')) === j([{ key: 'priority' }]),+ 'clicking a DIFFERENT column starts that column fresh, ascending')++ // the byte-identity rule the whole format follows, proved on the block itself+ const block: Record<string, unknown> = { id: 'v', type: 'view', html: 'Issues' }+ const pristine = j(block)+ const write = (k: string) => {+ const next = cycleSort(block.sort, k)+ if (next === undefined) delete block.sort+ else block.sort = next+ }+ write('status'); write('status'); write('status')+ ok(j(block) === pristine,+ 'a view sorted and unsorted from its header is BYTE-IDENTICAL to one nobody ever touched')++ // the arrow is the order, not a second opinion about it+ ok(sortDirOf(undefined, 'status') === undefined && sortDirOf('nonsense', 'status') === undefined,+ 'a malformed sort points no arrow rather than throwing — it came out of a file someone sent you')+ ok(sortDirOf([{ key: 'status' }], 'status') === 'asc',+ 'an entry with no direction reads as ascending, the way sortRows applies it')+ ok(sortDirOf([{ key: 'status' }], 'priority') === undefined,+ 'and a column that is not the sort key carries no arrow')+ const rows2: IssueRow[] = [+ { page: { id: 'a', title: 'a', blocks: [] } as Page, values: new Map([['status', 'done']]) },+ { page: { id: 'b', title: 'b', blocks: [] } as Page, values: new Map([['status', 'backlog']]) },+ ]+ const desc = cycleSort(cycleSort(undefined, 'status'), 'status')+ ok(sortDirOf(desc, 'status') === 'desc'+ && sortRows(doc, rows2, desc).map((r) => r.page.id).join('') === 'ab',+ 'the arrow the header shows and the order sortRows produces come from the one key')+}++// ---- the table's HEADERS and CELLS are controls, and only where there is an+// ---- editor ----------------------------------------------------------------+// Both are emitted by the ONE renderer, which also paints the reading view, a+// printout and a locked space. A control that escapes the editable guard is a+// button a reader can press and a shape on paper that means nothing.+{+ const fs = nodeFs+ const ren = fs.readFileSync(new URL('../spaces/src/render.ts', import.meta.url), 'utf8')+ const ed = fs.readFileSync(new URL('../spaces/src/editor.ts', import.meta.url), 'utf8')+ const tbl = ren.slice(ren.indexOf("if (layout === 'table') {"), ren.indexOf("if (layout === 'list') {"))++ ok(/if \(opts\.editable\) \{[\s\S]{0,900}?sortB\.dataset\.sortCol/.test(tbl),+ 'the sortable header is a control ONLY where there is an editor')+ ok(/if \(opts\.editable && f\) \{[\s\S]{0,600}?cell\.dataset\.cellPage/.test(tbl),+ '…and so is the editable cell')+ ok((tbl.match(/sortCol/g) ?? []).length === 1 && (tbl.match(/cellPage/g) ?? []).length === 1,+ 'neither is created anywhere else in the table, where no guard would cover it')+ ok(/th\.setAttribute\('aria-sort'/.test(tbl),+ 'the sort state reaches a screen reader as aria-sort, not only as an arrow glyph')++ // the page column: no sort control, because a view's sort names a FIELD and+ // sortRows cannot express a title. Pinned so nobody quietly invents a second+ // ordering mechanism to fill the gap.+ const first = tbl.slice(tbl.indexOf('const th0'), tbl.indexOf('hr.appendChild(th0)'))+ .replace(/^\s*\/\/[^\n]*$/gm, '')+ ok(!first.includes('sortCol') && !first.includes('button'),+ 'the page-title column carries no sort control — a sort key is a field, and a title is not one')++ // a header click writes through the SAME editView every other view control+ // uses, so "no sort" deletes the key rather than storing an empty array+ ok(/data-sort-col[\s\S]{0,700}?cycleSort\([\s\S]{0,80}?\.sort, h\.dataset\.sortCol!\)/.test(ed)+ && /data-sort-col[\s\S]{0,700}?this\.editView\(/.test(ed),+ 'a header click writes the view’s own sort through editView, which deletes rather than stores empty')++ // a cell writes through the one writer, so `value` and the readable `html`+ // can never fall out of step — and a page that lacks the field GAINS it, the+ // way a board drop already does+ ok(/private putField\(page: Page, f: FieldSpec, value: unknown\): void \{\s*const own = propBlockOf\(page, f\.key\)\s*if \(own\) this\.applyField\(own, f, value\)\s*else page\.blocks\.splice\(headerLength\(page\), 0, propBlock\(/.test(ed),+ 'a cell edit on a page WITHOUT that field adds the prop block, with its readable html written by propBlock')+ ok(/private setCell\([\s\S]{0,900}?s\.commit\(\(\) => this\.putField\(page, f, value\)/.test(ed),+ 'and every cell write goes through it, inside one commit')+ ok(/private setCell\([\s\S]{0,900}?if \(own && \(own as \{ value\?: unknown \}\)\.value === value\) return/.test(ed),+ 'choosing the value a cell already holds commits NOTHING — not a step you press ⌘Z past')+ ok(/private setCell\([\s\S]{0,900}?const scope = pageId === s\.pageId \? 'page' : 'doc'/.test(ed),+ 'a cell on ANOTHER page takes a document undo entry, or undo would restore the view and leave the value')++ // ONE picker. A cell that opened a picker of its own would be a second place+ // for the choosing to drift from the header strip's.+ ok((ed.match(/private fieldPicker\(/g) ?? []).length === 1+ && /this\.fieldPicker\(f, \(b as \{ value\?: unknown \}\)\.value, anchor, \(v\) => this\.setField\(blockId, v\)\)/.test(ed),+ 'the header strip’s picker and the cell’s are the same picker over different writers')+ ok(/private openCellPicker\([\s\S]{0,800}?this\.fieldPicker\(f, own \? \(own as \{ value\?: unknown \}\)\.value : undefined, anchor/.test(ed),+ '…and a cell standing for a value that does not exist yet opens it with nothing selected')+}+// ---- what a board and a field EXPORT ---------------------------------------// The readable `html` on a prop block is the whole reason the format degrades// instead of vanishing. The exporter is its most important consumer and was thediff --git a/spaces/src/editor.ts b/spaces/src/editor.tsindex 8d986f06..c01cd6f2 100644--- a/spaces/src/editor.ts+++ b/spaces/src/editor.ts@@ -9,7 +9,7 @@// backlinks and (later) collaboration key on.import {- type Block, type TableShape, type SpacesDoc, newBlock, newPage, effectiveParents, isRemote,+ type Block, type Page, type TableShape, type SpacesDoc, newBlock, newPage, effectiveParents, isRemote,tableOf, writeTable, TABLE_MAX_COLS, TABLE_MAX_ROWS, linkCard, linkCardHtml, unresolvedOn,parseDoc, uid,} from './model'@@ -26,6 +26,7 @@ import { MENU_SPECS, MD_SPECS, SPEC, CALLOUT_TONES } from './blocks'import {fieldByKey, fieldsOf, propHtml, propBlock, propBlockOf, isIssue, headerLength,reorderPages, columnMoves, ISSUE_FIELDS, withField, freeFieldKey, FIELD_TYPE_LABEL,+ cycleSort,type DropAim, type FieldSpec, type ViewFilter, type ViewSort,} from './fields'import { planImport, type SourceFile } from './markdown'@@ -1425,12 +1426,91 @@ export class Editor {b.html = propHtml(f, value)}+ /**+ * Set a field ON A PAGE, adding the prop block when the page does not carry+ * one — the case a board drop already had and a table cell now has too.+ *+ * A page can be in a view without carrying every field the view shows: a+ * board grouped by something an issue never had, or a table column that+ * exists because SOME other row has it. The value arrives in the header strip+ * where the others are, through propBlock, so the readable `html` is written+ * with it. A value written without its readable form is a value an older+ * build, a thumbnailer, a grep and the markdown export all see as nothing.+ *+ * Not a commit of its own: the caller decides what one user action was.+ */+ private putField(page: Page, f: FieldSpec, value: unknown): void {+ const own = propBlockOf(page, f.key)+ if (own) this.applyField(own, f, value)+ else page.blocks.splice(headerLength(page), 0, propBlock(f, value, newBlock('prop').id))+ }++ /**+ * A TABLE CELL, opened for editing. The same picker the page's own header+ * strip opens, over the same writer a board drop uses.+ *+ * Addressed by PAGE AND KEY rather than by block id, because the interesting+ * cell is the empty one: the page has no prop block for that column, and the+ * edit is what creates it. Looking the block up here — after the value is+ * chosen, in setCell — also means an opened-and-dismissed picker writes+ * nothing at all.+ */+ private openCellPicker(pageId: string, key: string, anchor: HTMLElement): void {+ const s = this.store+ if (s.readOnly || this.reading) return+ const page = s.index.page.get(pageId)+ const f = fieldByKey(s.doc, key)+ if (!page || !f) return+ const own = propBlockOf(page, key)+ this.fieldPicker(f, own ? (own as { value?: unknown }).value : undefined, anchor,+ (v) => this.setCell(pageId, key, v))+ }++ /**+ * Write one cell. Nothing happens when the value did not change: a picker+ * opened and closed on the value already there must not be a step you press+ * ⌘Z past.+ *+ * PAGE SCOPE ONLY WHEN THE ROW IS THE PAGE IN VIEW, for the reason setField+ * carries: a page-scoped checkpoint snapshots `store.pageId`, and a cell in a+ * table almost always belongs to ANOTHER page — undo would restore the page+ * holding the view and leave the changed value exactly where it was.+ */+ private setCell(pageId: string, key: string, value: unknown): void {+ const s = this.store+ const page = s.index.page.get(pageId)+ const f = fieldByKey(s.doc, key)+ if (!page || !f || s.readOnly || this.reading) return+ const own = propBlockOf(page, key)+ if (own && (own as { value?: unknown }).value === value) return+ const scope = pageId === s.pageId ? 'page' : 'doc'+ s.commit(() => this.putField(page, f, value), { scope })+ this.paintPage()+ }+private openFieldPicker(blockId: string, anchor: HTMLElement): void {const s = this.storeif (s.readOnly || this.reading) returnconst b = s.block(blockId)const f = b && fieldByKey(s.doc, String((b as { key?: unknown }).key ?? ''))if (!b || !f) return+ this.fieldPicker(f, (b as { value?: unknown }).value, anchor, (v) => this.setField(blockId, v))+ }++ /**+ * THE ONE PICKER for a field value: a list of options for a select, one input+ * for anything else.+ *+ * Takes a WRITER rather than a block id, and that is the whole reason it was+ * split out of openFieldPicker. A table cell can stand for a value that does+ * not exist yet — the page carries no such prop block — so there is no id to+ * hand it. Everything else about choosing a value has to stay identical+ * across the header strip, the board's card chip and a cell, or the same+ * gesture reads as three different controls.+ */+ private fieldPicker(+ f: FieldSpec, cur: unknown, anchor: HTMLElement, write: (v: unknown) => void,+ ): void {this.closeOverlay()const pop = el('div', this.isDrawer() ? 'sp-pop sp-sheet' : 'sp-pop')@@ -1438,17 +1518,17 @@ export class Editor {this.trapAndClose(pop)if (f.vt === 'select' && f.options?.length) {- const cur = String((b as { value?: unknown }).value ?? '')+ const now = String(cur ?? '')for (const o of f.options) {const item = document.createElement('button')- item.className = 'sp-dditem' + (o.id === cur ? ' sp-sel' : '')+ item.className = 'sp-dditem' + (o.id === now ? ' sp-sel' : '')item.type = 'button'const dot = el('span', 'sp-prop-dot')if (o.color) dot.style.background = o.colorconst name = document.createElement('span')name.textContent = o.labelitem.append(dot, name)- item.addEventListener('click', () => { this.closeOverlay(); this.setField(blockId, o.id) })+ item.addEventListener('click', () => { this.closeOverlay(); write(o.id) })pop.append(item)}} else {@@ -1456,14 +1536,14 @@ export class Editor {const input = document.createElement('input')input.className = 'sp-find'input.type = f.vt === 'number' ? 'number' : f.vt === 'date' ? 'date' : 'text'- input.value = String((b as { value?: unknown }).value ?? '')+ input.value = String(cur ?? '')input.placeholder = f.labelinput.addEventListener('keydown', (e) => {if (e.key === 'Enter') {e.preventDefault()const raw = input.value.trim()this.closeOverlay()- this.setField(blockId, f.vt === 'number' ? (raw === '' ? '' : Number(raw)) : raw)+ write(f.vt === 'number' ? (raw === '' ? '' : Number(raw)) : raw)}})pop.append(input)@@ -1533,6 +1613,28 @@ export class Editor {})}+ // THE TABLE, made to work. A header is a control and a cell is a control,+ // both real <button>s from the renderer, so the keyboard reaches them and+ // Enter fires this same click — there is no second key path to keep in+ // step with the pointer one.+ for (const h of v.querySelectorAll<HTMLElement>('[data-sort-col]')) {+ h.addEventListener('click', () => {+ // ascending -> descending -> none, written into the view's OWN sort.+ // The third state deletes the key rather than storing an empty array,+ // so a table sorted and unsorted is byte-identical to one nobody+ // touched — the rule filter, source and layout all follow.+ const now = this.store.block(v.dataset.blockId ?? '')+ this.editView(v.dataset.blockId!, 'sort',+ cycleSort((now as { sort?: unknown } | undefined)?.sort, h.dataset.sortCol!))+ })+ }+ for (const c of v.querySelectorAll<HTMLElement>('[data-cell-field]')) {+ c.addEventListener('click', (e) => {+ e.preventDefault()+ this.openCellPicker(c.dataset.cellPage!, c.dataset.cellField!, c)+ })+ }+// NO BOARD, NO DRAG. A list has cards but no columns, so a draggable card// there is an affordance that promises something nothing can accept.const board = v.querySelector('.sp-board')@@ -1626,14 +1728,7 @@ export class Editor {if (!setting && !order) returns.commit(() => {- if (setting) {- if (own) this.applyField(own, f, optId)- // A page can reach a column without carrying that field at all (a board- // grouped by something an issue never had). It gains the value, in the- // header strip where the others are — through propBlock, so the- // readable form is written with it.- else page.blocks.splice(headerLength(page), 0, propBlock(f, optId, newBlock('prop').id))- }+ if (setting) this.putField(page, f, optId)if (order) s.doc.pages = order})this.repaint()diff --git a/spaces/src/fields.ts b/spaces/src/fields.tsindex f32ba303..2ec8c029 100644--- a/spaces/src/fields.ts+++ b/spaces/src/fields.ts@@ -571,3 +571,34 @@ export function columnMoves(cards: string[], moved: string, aim: DropAim): booleconst next = [...rest.slice(0, target), moved, ...rest.slice(target)]return next.join('\u001f') !== cards.join('\u001f')}++/**+ * Which direction a view is sorted in BY THIS FIELD, if it is.+ *+ * Reads the same `sort` the format already carries — there is no second place+ * a table header's arrow could come from, and inventing one would let the arrow+ * and the order disagree. `undefined` means this column is not the sort key;+ * an entry with no `dir` is ascending, which is what absence has always meant.+ */+export const sortDirOf = (sort: unknown, key: string): 'asc' | 'desc' | undefined => {+ const cur = (Array.isArray(sort) ? sort : [])[0] as ViewSort | undefined+ if (!cur || String(cur.key ?? '') !== key) return undefined+ return cur.dir === 'desc' ? 'desc' : 'asc'+}++/**+ * The sort a CLICK ON A COLUMN HEADER produces: ascending → descending → none.+ *+ * The third state is the one that matters. A header that only flips between two+ * directions can never give a hand-arranged board its order back, and "manual+ * order" is not a sort called manual — it is the ABSENCE of the key. So this+ * returns `undefined` there, and the caller deletes the key rather than storing+ * an empty array: a view sorted and unsorted is byte-identical to one nobody+ * ever touched.+ */+export function cycleSort(sort: unknown, key: string): ViewSort[] | undefined {+ const dir = sortDirOf(sort, key)+ if (dir === undefined) return [{ key }]+ if (dir === 'asc') return [{ key, dir: 'desc' }]+ return undefined+}diff --git a/spaces/src/i18n/de.ts b/spaces/src/i18n/de.tsindex 8f3fc2da..4dc7b95e 100644--- a/spaces/src/i18n/de.ts+++ b/spaces/src/i18n/de.ts@@ -390,6 +390,7 @@ export const de: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "Erscheint neben deinem Cursor und in der Personenliste — nur in diesem Browser gespeichert.","Site name": "Name der Website","Sort": "Sortieren",+ "Sort by {field}": "Nach {field} sortieren","Space name": "Space-Name","Start live session": "Live-Sitzung starten","Start silent": "Ohne Ton starten",diff --git a/spaces/src/i18n/es.ts b/spaces/src/i18n/es.tsindex 856bc060..78f4ed77 100644--- a/spaces/src/i18n/es.ts+++ b/spaces/src/i18n/es.ts@@ -390,6 +390,7 @@ export const es: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "Aparece junto a tu cursor y en la lista de Personas — se guarda solo en este navegador.","Site name": "Nombre del sitio","Sort": "Ordenar",+ "Sort by {field}": "Ordenar por {field}","Space name": "Nombre del espacio","Start live session": "Iniciar sesión en vivo","Start silent": "Empezar en silencio",diff --git a/spaces/src/i18n/fr.ts b/spaces/src/i18n/fr.tsindex 29628492..632c312b 100644--- a/spaces/src/i18n/fr.ts+++ b/spaces/src/i18n/fr.ts@@ -390,6 +390,7 @@ export const fr: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "Affiché près de votre curseur et dans la liste Personnes — stocké uniquement dans ce navigateur.","Site name": "Nom du site","Sort": "Trier",+ "Sort by {field}": "Trier par {field}","Space name": "Nom de l’espace","Start live session": "Démarrer la session en direct","Start silent": "Démarrer sans le son",diff --git a/spaces/src/i18n/it.ts b/spaces/src/i18n/it.tsindex 67055323..a3b114e9 100644--- a/spaces/src/i18n/it.ts+++ b/spaces/src/i18n/it.ts@@ -390,6 +390,7 @@ export const it: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "Appare accanto al tuo cursore e nell’elenco Persone — salvato solo in questo browser.","Site name": "Nome del sito","Sort": "Ordina",+ "Sort by {field}": "Ordina per {field}","Space name": "Nome dello spazio","Start live session": "Avvia sessione dal vivo","Start silent": "Parti senza audio",diff --git a/spaces/src/i18n/ja.ts b/spaces/src/i18n/ja.tsindex c7f05edc..dded55b2 100644--- a/spaces/src/i18n/ja.ts+++ b/spaces/src/i18n/ja.ts@@ -390,6 +390,7 @@ export const ja: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "カーソルの横とメンバーリストに表示されます — このブラウザにのみ保存されます。","Site name": "サイト名","Sort": "並べ替え",+ "Sort by {field}": "{field}で並べ替え","Space name": "スペース名","Start live session": "ライブセッションを開始","Start silent": "音を出さずに開始する",diff --git a/spaces/src/i18n/packed.ts b/spaces/src/i18n/packed.tsindex 38585383..31a19f90 100644--- a/spaces/src/i18n/packed.ts+++ b/spaces/src/i18n/packed.ts@@ -398,6 +398,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {"Shown next to your cursor and in the People list — stored only in this browser.": ["カーソルの横とメンバーリストに表示されます — このブラウザにのみ保存されます。","显示在你的光标旁和成员列表中 — 仅保存在此浏览器。","顯示在你的游標旁和成員列表中 — 僅儲存在此瀏覽器。","Aparece junto a tu cursor y en la lista de Personas — se guarda solo en este navegador.","Affiché près de votre curseur et dans la liste Personnes — stocké uniquement dans ce navigateur.","Erscheint neben deinem Cursor und in der Personenliste — nur in diesem Browser gespeichert.","Appare accanto al tuo cursore e nell’elenco Persone — salvato solo in questo browser.","Exibido ao lado do seu cursor e na lista de Pessoas — guardado apenas neste navegador."],"Site name": ["サイト名","网站名称","網站名稱","Nombre del sitio","Nom du site","Name der Website","Nome del sito","Nome do site"],"Sort": ["並べ替え","排序","排序","Ordenar","Trier","Sortieren","Ordina","Ordenar"],+ "Sort by {field}": ["{field}で並べ替え","按{field}排序","依{field}排序","Ordenar por {field}","Trier par {field}","Nach {field} sortieren","Ordina per {field}","Ordenar por {field}"],"Space name": ["スペース名","空间名称","空間名稱","Nombre del espacio","Nom de l’espace","Space-Name","Nome dello spazio","Nome do espaço"],"Start live session": ["ライブセッションを開始","开始实时会话","開始即時工作階段","Iniciar sesión en vivo","Démarrer la session en direct","Live-Sitzung starten","Avvia sessione dal vivo","Iniciar sessão ao vivo"],"Start silent": ["音を出さずに開始する","开始时静音","開始時靜音","Empezar en silencio","Démarrer sans le son","Ohne Ton starten","Parti senza audio","Começar sem som"],diff --git a/spaces/src/i18n/pt.ts b/spaces/src/i18n/pt.tsindex 8ee3f827..f37de9ae 100644--- a/spaces/src/i18n/pt.ts+++ b/spaces/src/i18n/pt.ts@@ -390,6 +390,7 @@ export const pt: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "Exibido ao lado do seu cursor e na lista de Pessoas — guardado apenas neste navegador.","Site name": "Nome do site","Sort": "Ordenar",+ "Sort by {field}": "Ordenar por {field}","Space name": "Nome do espaço","Start live session": "Iniciar sessão ao vivo","Start silent": "Começar sem som",diff --git a/spaces/src/i18n/zh-Hans.ts b/spaces/src/i18n/zh-Hans.tsindex 7409e77b..c8ca3f3b 100644--- a/spaces/src/i18n/zh-Hans.ts+++ b/spaces/src/i18n/zh-Hans.ts@@ -390,6 +390,7 @@ export const zh_Hans: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "显示在你的光标旁和成员列表中 — 仅保存在此浏览器。","Site name": "网站名称","Sort": "排序",+ "Sort by {field}": "按{field}排序","Space name": "空间名称","Start live session": "开始实时会话","Start silent": "开始时静音",diff --git a/spaces/src/i18n/zh-Hant.ts b/spaces/src/i18n/zh-Hant.tsindex 5c71ec51..b51f3900 100644--- a/spaces/src/i18n/zh-Hant.ts+++ b/spaces/src/i18n/zh-Hant.ts@@ -390,6 +390,7 @@ export const zh_Hant: Catalog = {"Shown next to your cursor and in the People list — stored only in this browser.": "顯示在你的游標旁和成員列表中 — 僅儲存在此瀏覽器。","Site name": "網站名稱","Sort": "排序",+ "Sort by {field}": "依{field}排序","Space name": "空間名稱","Start live session": "開始即時工作階段","Start silent": "開始時靜音",diff --git a/spaces/src/render.ts b/spaces/src/render.tsindex a7964694..382ffca6 100644--- a/spaces/src/render.ts+++ b/spaces/src/render.ts@@ -17,7 +17,7 @@ import { TAG_OF, LIST_OF, SPEC, TONE, mediaPlayback } from './blocks'import {fieldByKey, fieldsOf, optionOf, viewRows, headerLength, propBlockOf,passesFilter, filterCount, unknownFilterKeys,- sortRows, unknownSortKeys, type ViewSort, type FieldSpec,+ sortRows, unknownSortKeys, sortDirOf, type ViewSort, type FieldSpec,} from './fields'import { answer, feed, freshContext, type CalcCtx } from './calc.ts'import { ICONS, type IconName } from './icons'@@ -1183,15 +1183,73 @@ function renderView(host: HTMLElement, b: Block, doc: SpacesDoc, opts: RenderOptconst thead = document.createElement('thead')const hr = document.createElement('tr')const th0 = document.createElement('th')+ // THE PAGE COLUMN DOES NOT SORT, and it says so by being a plain heading+ // rather than a dead button. A view's `sort` names a FIELD: sortRows looks+ // each key up in the schema and skips what it cannot find, so ordering by+ // title would need a second ordering mechanism living beside the first —+ // and one order stored in two shapes is the thing that later disagrees with+ // itself. A pseudo-key like `title` is worse still: every build that ships+ // today would report it through unknownSortKeys as "newer than this build"+ // and then not apply it. Better a column that plainly does not sort.th0.textContent = t('Page')hr.appendChild(th0)for (const k of keys) {const th = document.createElement('th')- th.textContent = fieldByKey(doc, k)?.label ?? k+ const label = fieldByKey(doc, k)?.label ?? k+ const dir = sortDirOf(sort, k)+ // The state lives on the TH as aria-sort, the attribute a screen reader+ // already announces; the arrow is what a sighted reader reads. Two+ // renderings of ONE fact — the view's own `sort` — so there is no second+ // place the arrow could come from and no way for it to disagree with the+ // order the rows are actually in.+ th.setAttribute('aria-sort', dir === 'asc' ? 'ascending' : dir === 'desc' ? 'descending' : 'none')+ // A READER GETS THE HEADING, not the control — the rule the card chip and+ // every view button already follow: a printout and a locked space show+ // the view, never the things that change it.+ if (opts.editable) {+ const sortB = document.createElement('button')+ sortB.type = 'button'+ sortB.className = 'sp-view-sort' + (dir ? ' sp-on' : '')+ sortB.dataset.sortCol = k+ sortB.title = t('Sort by {field}', { field: label })+ sortB.setAttribute('aria-label', t('Sort by {field}', { field: label }))+ const arrow = document.createElement('span')+ arrow.className = 'sp-sortdir'+ arrow.setAttribute('aria-hidden', 'true')+ arrow.textContent = dir === 'asc' ? '\u2191' : dir === 'desc' ? '\u2193' : ''+ sortB.append(document.createTextNode(label), arrow)+ th.appendChild(sortB)+ } else {+ th.textContent = label+ }hr.appendChild(th)}thead.appendChild(hr)table.appendChild(thead)++ // What a cell SHOWS. THROUGH THE OPTION, so a select shows its label and+ // its colour rather than the id the model stores — the same thing propHtml+ // does for the header strip, and for the same reason: the id is not for+ // reading. An unset value is an em dash, so an empty cell is still a place+ // you can aim at.+ const fill = (into: HTMLElement, f: FieldSpec | undefined, v: unknown): void => {+ const opt = optionOf(f, v)+ if (opt) {+ const chip = document.createElement('span')+ chip.className = 'sp-prop-chip'+ const dot = document.createElement('span')+ dot.className = 'sp-prop-dot'+ if (opt.color) dot.style.background = opt.color+ chip.append(dot, document.createTextNode(opt.label))+ into.appendChild(chip)+ } else if (v !== undefined && v !== null && String(v) !== '') {+ into.appendChild(document.createTextNode(shownValue(f, v)))+ } else {+ into.classList.add('sp-view-empty')+ into.appendChild(document.createTextNode('\u2014'))+ }+ }+const tb = document.createElement('tbody')for (const r of rows) {const tr = document.createElement('tr')@@ -1208,23 +1266,23 @@ function renderView(host: HTMLElement, b: Block, doc: SpacesDoc, opts: RenderOptconst td = document.createElement('td')const f = fieldByKey(doc, k)const v = r.values.get(k)- // THROUGH THE OPTION, so a select shows its label and its colour rather- // than the id the model stores — the same thing propHtml does for the- // header strip, and for the same reason: the id is not for reading.- const opt = optionOf(f, v)- if (opt) {- const chip = document.createElement('span')- chip.className = 'sp-prop-chip'- const dot = document.createElement('span')- dot.className = 'sp-prop-dot'- if (opt.color) dot.style.background = opt.color- chip.append(dot, document.createTextNode(opt.label))- td.appendChild(chip)- } else if (v !== undefined && v !== null && String(v) !== '') {- td.textContent = String(v)+ // A CELL IS A CONTROL where there is an editor — a real <button>, so it+ // is in the tab order and answers Enter and Space without a key handler+ // of its own. It is emitted even for a page carrying no such prop block:+ // an empty cell is how the field gets ONTO that page, exactly as+ // dropping a card into a column is.+ if (opts.editable && f) {+ const cell = document.createElement('button')+ cell.type = 'button'+ cell.className = 'sp-view-cell'+ cell.dataset.cellPage = r.page.id+ cell.dataset.cellField = k+ cell.title = t('Change {field}', { field: f.label })+ cell.setAttribute('aria-label', t('Change {field}', { field: f.label }))+ fill(cell, f, v)+ td.appendChild(cell)} else {- td.className = 'sp-view-empty'- td.textContent = '—'+ fill(td, f, v)}tr.appendChild(td)}diff --git a/spaces/src/styles.css b/spaces/src/styles.cssindex 76aa1255..37d5bf1c 100644--- a/spaces/src/styles.css+++ b/spaces/src/styles.css@@ -1867,6 +1867,28 @@ button.sp-issue-set:hover { background: var(--chrome-2); border-color: var(--edg.sp-view-cellink { color: var(--ink); text-decoration: none; }.sp-view-cellink:hover { text-decoration: underline; }.sp-view-empty { color: var(--ph, var(--muted)); }+/* A HEADER AND A CELL ARE CONTROLS, and they say so only on approach: a table+ whose every box is drawn as a button reads as a form, and this is a document.+ So no chrome at rest, a tint on hover, and a real focus ring — the keyboard+ is the one reader that cannot hover, and it must still be able to see where+ it is. */+.sp-view-sort {+ font: inherit; color: inherit; background: none; border: 0; border-radius: 5px;+ padding: 2px 4px; margin: 0 0 0 -4px; cursor: pointer;+ display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;+}+.sp-view-sort:hover { background: var(--chrome); color: var(--ink); }+.sp-view-sort.sp-on { color: var(--ink); }+.sp-sortdir { font-size: 10px; line-height: 1; }+.sp-view-cell {+ font: inherit; color: inherit; background: none; border: 0; border-radius: 5px;+ padding: 2px 6px; margin: -2px 0 -2px -6px; cursor: pointer; text-align: start;+ max-width: 100%; min-width: 2.2em;+}+.sp-view-cell:hover { background: var(--chrome); box-shadow: inset 0 0 0 1px var(--line); }+.sp-view-sort:focus-visible, .sp-view-cell:focus-visible {+ outline: 2px solid var(--accent, currentColor); outline-offset: 1px;+}/* a select's value, the same chip the header strip and the board cards use */.sp-prop-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }