Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

spaces: one rule for where a command lives (#356)

nyblnet000468e21b2e
diff --git a/scripts/test-spaces-model.ts b/scripts/test-spaces-model.ts
index 36ec2beb..178ecdee 100644
--- a/scripts/test-spaces-model.ts
+++ b/scripts/test-spaces-model.ts
@@ -440,9 +440,17 @@ for (const [label, input, err] of [
const ed = fs.readFileSync(new URL('../spaces/src/editor.ts', import.meta.url), 'utf8')
const css = fs.readFileSync(new URL('../spaces/src/styles.css', import.meta.url), 'utf8')
- ok(/const secondary: Array<\{/.test(ed), 'the secondary topbar actions are declared as ONE list')
- ok(/secondary\.map\(/.test(ed), '…the inline row is built from that list')
- ok(/for \(const a of secondary\)/.test(ed), '…and the ⋯ menu is built from the SAME list')
+ // TWO lists now, and the split is the point. Everything used to be one list
+ // rendered BOTH inline and into ⋯ unconditionally, so on a desktop half of ⋯
+ // pointed at buttons already on screen. What still must not happen is a ⋯
+ // menu maintained BY HAND as a copy of the row — so each list is declared
+ // once and ⋯ takes the inline one only when the bar has actually dropped it.
+ ok(/const barActions: BarAction\[\]/.test(ed), 'the bar actions are declared as one typed list')
+ ok(/const menuActions: BarAction\[\]/.test(ed), '…the ⋯-only actions as another')
+ ok(/barActions\.map\(/.test(ed), '…the inline row is built from the bar list')
+ ok(/for \(const a of menuActions\)/.test(ed), '…⋯ always carries the menu-only actions')
+ ok(/isFolded\(\)\) \{\s*\n\s*for \(const a of barActions\)/.test(ed),
+ '…and picks up the bar list ONLY once folded, or ⋯ duplicates the visible row')
// WHICH TIER a rule lives in is the thing worth pinning — but the tiers are
// no longer px media queries. They were (820 and 600), and the numbers moved
@@ -464,7 +472,12 @@ for (const [label, input, err] of [
ok(inTier('compact', /\.sp-primary span\.sp-savelabel \{ display: none/), "…including Save's")
ok(inTier('tight', /\.sp-mark-word \{ display: none/), 'tight drops the wordmark, keeping the mark')
ok(inTier('fold', /\.sp-sec \{ display: none/), 'fold moves the secondary row into ⋯')
- ok(inTier('fold', /\.sp-more \{ display: inline-flex/), '…which is where ⋯ appears')
+ // ⋯ is no longer fold-only: it is the home of the once-a-session commands, so
+ // gating it on the fold would put New page, the journal, import, print and
+ // About out of a desktop user's reach entirely.
+ ok(/^\.sp-more \{ display: inline-flex/m.test(css),
+ '⋯ is in the bar at EVERY width, being a home and not only an overflow')
+ ok(!/\.sp-bar-fold \.sp-more \{ display/.test(css), '…so it is not gated on the fold any more')
ok(inTier('fold', /\.sp-mark \{ display: none/), '…and the mark goes (About is in ⋯)')
ok(inTier('fold', /\.sp-group-history \{ display: none/), '…and the history pair')
ok(inTier('fold', /\.sp-split \.sp-caret \{ display: none/), '…and the save caret')
diff --git a/spaces/src/editor.ts b/spaces/src/editor.ts
index 4d50e6d8..853885d5 100644
--- a/spaces/src/editor.ts
+++ b/spaces/src/editor.ts
@@ -248,7 +248,7 @@ export class Editor {
'<rect x="14" y="5" width="13" height="10" rx="2.5" fill="#FF9E8A"/>' +
'<rect x="14" y="17" width="13" height="10" rx="2.5" fill="#F0EBE0"/>' +
'</svg><b class="sp-mark-word">bento<span>/</span>spaces</b>'
- mark.title = t('About bento/spaces — version, updates, language, password')
+ mark.title = t('About this space')
mark.addEventListener('click', () => this.openAbout())
// Pages panel toggle — on every width, like slides' Slides/Format toggles.
@@ -298,38 +298,57 @@ export class Editor {
this.redoB = iconBtn('redo', t('Redo (⇧⌘Z)'), () => { this.store.redo(); this.repaint() })
const search = iconBtn('search', t('Search all pages (⌘K)'), () => this.openSearch())
- // SECONDARY ACTIONS, declared ONCE.
+ // WHERE A COMMAND LIVES. One rule, because the bar used to have none and it
+ // showed: eight secondary buttons sat in the bar AND were repeated verbatim
+ // in the ⋯ menu at the same time, so half of ⋯ pointed at things already on
+ // screen. Print and Password each had two homes. About had three entry
+ // points under two different names — all calling one dialog.
//
- // Measured at 375px before this existed: the bar wanted 678px, so seven of
- // eleven controls sat off the right edge — including Save. On a phone the
- // file could not be saved at all.
+ // · The bar carries what you reach for WHILE WRITING.
+ // · ⋯ carries the rest, plus whatever the bar has had to drop.
+ // · Save ▾ is only about writing THIS file somewhere.
+ // · Nothing is listed in two places at the same width.
//
- // Below the breakpoint these collapse into the ⋯ menu and the inline copies
- // are hidden. One list feeds both, because a phone menu maintained by hand
- // as a copy of the desktop row drifts the first time either one changes.
- const secondary: Array<{
+ // The measurement that produced the fold still holds: at 375px the old bar
+ // wanted 678px, so seven of eleven controls — Save included — sat off the
+ // right edge. Below the breakpoint the inline copies hide and ⋯ picks them
+ // up, one list feeding both, because a phone menu maintained by hand as a
+ // copy of the desktop row drifts the first time either one changes.
+ type BarAction = {
icon: IconName
label: string
hint: string
run: () => void
keep?: (b: HTMLButtonElement) => void
- }> = [
+ }
+
+ // Reached while writing, so it stays in the bar until the bar runs out of
+ // room. Reading view is a MODE — you leave and re-enter it while working,
+ // and a mode you cannot see the state of is a mode you lose track of.
+ const barActions: BarAction[] = [
+ { icon: 'eye', label: t('Reading view'), hint: t('The pages without the editing tools'),
+ run: () => this.toggleReading(),
+ keep: (b) => { this.readB = b } },
+ ]
+
+ // Reached once a session or less. A button in the bar for something you do
+ // once is a button in the way of everything you do constantly, so these
+ // live in ⋯ at every width — findable, out of the road, and each with the
+ // keyboard shortcut printed beside it.
+ const menuActions: BarAction[] = [
{ icon: 'page', label: t('New page'), hint: '⌘⌥N', run: () => this.newPage() },
- { icon: 'markdown', label: t('Import Markdown…'), hint: t('A folder of notes, or another space'),
- run: () => this.openImport() },
{ icon: 'book', label: t("Today's journal"), hint: '⌘⇧J', run: () => this.openJournal() },
{ icon: 'board', label: t('New issue'), hint: '⌘⇧I', run: () => this.newIssue() },
{ icon: 'tag', label: t('Make this page an issue'), hint: t('Adds status, priority, assignee, estimate'),
run: () => this.makeIssue() },
- { icon: 'eye', label: t('Reading view'), hint: t('The pages without the editing tools'),
- run: () => this.toggleReading(),
- keep: (b) => { this.readB = b } },
+ { icon: 'markdown', label: t('Import Markdown…'), hint: t('A folder of notes, or another space'),
+ run: () => this.openImport() },
{ icon: 'print', label: t('Print or save as PDF'), hint: '⌘P', run: () => this.openPrint() },
{ icon: 'info', label: t('About this space'), hint: t('Version, language, password, exports'),
run: () => this.openAbout() },
]
- const inlineSecondary = secondary.map((a) => {
+ const inlineSecondary = barActions.map((a) => {
const b = iconBtn(a.icon, a.hint && a.hint.length < 12 ? `${a.label} (${a.hint})` : a.label, a.run)
b.classList.add('sp-sec')
a.keep?.(b)
@@ -363,9 +382,16 @@ export class Editor {
close(); this.store.redo(); this.repaint()
}, { off: !this.store.canRedo }))
}
- for (const a of secondary) {
+ for (const a of menuActions) {
menu.append(this.menuItem(a.icon, a.label, a.hint, () => { close(); a.run() }))
}
+ // …and only THEN what the bar itself has had to give up. Listing these
+ // unconditionally is what made ⋯ a duplicate of the visible row.
+ if (this.isFolded()) {
+ for (const a of barActions) {
+ menu.append(this.menuItem(a.icon, a.label, a.hint, () => { close(); a.run() }))
+ }
+ }
if (this.isFolded()) {
menu.append(this.menuItem('copy', t('Save a copy…'), t('A second file — the original is left alone'), () => {
close(); void this.saveAs('copy')
@@ -410,12 +436,6 @@ export class Editor {
menu.append(this.menuItem('page', t('Export page as a space…'), t('One page and what is under it, as its own file'), () => {
close(); this.openExportSpace()
}))
- menu.append(this.menuItem('print', t('Print / PDF…'), t('The whole space, or just this page'), () => {
- close(); this.openPrint()
- }))
- menu.append(this.menuItem('lock', t('Password…'), t('Encrypt the document inside this file'), () => {
- close(); this.openAbout()
- }))
})
saveMore.classList.add('sp-caret', 'sp-dd-end')
diff --git a/spaces/src/i18n/packed.ts b/spaces/src/i18n/packed.ts
index 6493cf17..16dc818b 100644
--- a/spaces/src/i18n/packed.ts
+++ b/spaces/src/i18n/packed.ts
@@ -29,7 +29,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"A space needs at least one page": ["スペースには少なくとも 1 ページが必要です","空间至少要有一个页面","空間至少要有一個頁面","Un espacio necesita al menos una página","Un espace doit contenir au moins une page","Ein Space braucht mindestens eine Seite","Uno spazio deve avere almeno una pagina","Um espaço precisa de pelo menos uma página"],
"A still frame, shown before play — and what a printout or a file preview shows": ["再生前に表示される静止画 — 印刷やファイルのプレビューで表示されるのもこれです","播放前显示的静帧 — 打印和文件预览中显示的也是它","播放前顯示的靜態畫面 — 列印和檔案預覽顯示的也是它","Un fotograma fijo, que se muestra antes de reproducir — y es lo que aparece al imprimir o en la vista previa del archivo","Une image fixe, affichée avant la lecture — et c’est elle qui apparaît à l’impression et dans l’aperçu du fichier","Ein Standbild, das vor dem Abspielen zu sehen ist — und das, was im Ausdruck und in der Dateivorschau erscheint","Un fotogramma fisso, mostrato prima della riproduzione — ed è quello che compare in stampa e nell’anteprima del file","Uma imagem fixa, mostrada antes da reprodução — e é o que aparece na impressão e na pré-visualização do ficheiro"],
"A typed value on this page": ["このページの型付きの値","此页面上的类型化值","此頁面上的型別值","Un valor con tipo en esta página","Une valeur typée sur cette page","Ein typisierter Wert auf dieser Seite","Un valore tipizzato su questa pagina","Um valor tipado nesta página"],
- "About bento/spaces — version, updates, language, password": ["bento/spaces について — バージョン・更新・言語・パスワード","关于 bento/spaces — 版本、更新、语言、密码","關於 bento/spaces — 版本、更新、語言、密碼","Acerca de bento/spaces: versión, actualizaciones, idioma, contraseña","À propos de bento/spaces — version, mises à jour, langue, mot de passe","Über bento/spaces — Version, Updates, Sprache, Passwort","Informazioni su bento/spaces — versione, aggiornamenti, lingua, password","Acerca do bento/spaces — versão, atualizações, idioma, palavra-passe"],
"About this space": ["このスペースについて","关于此空间","關於此空間","Acerca de este espacio","À propos de cet espace","Über diesen Space","Informazioni su questo spazio","Sobre este espaço"],
"Access reset — only copies saved from now on can join": ["アクセスをリセットしました — 今後保存したコピーだけが参加できます","访问已重置 — 只有此后保存的副本才能加入","存取已重設 — 只有此後儲存的副本才能加入","Acceso restablecido — solo las copias guardadas a partir de ahora podrán unirse","Accès réinitialisé — seules les copies enregistrées désormais pourront rejoindre","Zugriff zurückgesetzt — nur ab jetzt gespeicherte Kopien können beitreten","Accesso reimpostato — solo le copie salvate d’ora in poi potranno unirsi","Acesso redefinido — apenas cópias salvas de agora em diante podem entrar"],
"Add a block below": ["下にブロックを追加","在下方添加块","在下方新增區塊","Añadir un bloque debajo","Ajouter un bloc en dessous","Block darunter hinzufügen","Aggiungi un blocco sotto","Adicionar um bloco abaixo"],
@@ -153,7 +152,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Editor": ["編集者","编辑者","編輯者","Editor","Éditeur","Bearbeiter","Editor","Editor"],
"Editor copy saved — recipients join live with edit access": ["編集者コピーを保存しました — 受け取った人は編集権限つきでライブに参加します","编辑者副本已保存 — 收到的人可带编辑权限加入实时会话","編輯者副本已儲存 — 收到的人可帶編輯權限加入即時會話","Copia de editor guardada — quien la reciba se une en vivo con acceso de edición","Copie éditeur enregistrée — les destinataires rejoignent la session en direct avec accès en écriture","Bearbeiter-Kopie gespeichert — Empfänger treten live mit Schreibzugriff bei","Copia editor salvata — chi la riceve entra live con accesso in modifica","Cópia de editor salva — quem receber entra ao vivo com acesso de edição"],
"Embedded in the file": ["ファイルに埋め込み済み","已嵌入文件","已嵌入檔案","Incrustado en el archivo","Intégré au fichier","In der Datei eingebettet","Incorporato nel file","Embutido no arquivo"],
- "Encrypt the document inside this file": ["このファイル内のドキュメントを暗号化","加密此文件内的文档","加密此檔案內的文件","Cifrar el documento dentro de este archivo","Chiffrer le document à l’intérieur de ce fichier","Das Dokument in dieser Datei verschlüsseln","Cifra il documento dentro questo file","Encriptar o documento dentro deste ficheiro"],
"Enter the password to open it.": ["開くにはパスワードを入力してください。","输入密码以打开。","請輸入密碼以開啟。","Introduce la contraseña para abrirlo.","Saisissez le mot de passe pour l’ouvrir.","Gib das Passwort ein, um ihn zu öffnen.","Inserisci la password per aprirlo.","Introduza a palavra-passe para o abrir."],
"Every page opens wide on this screen from now on": ["この画面では今後すべてのページを広く表示します","在此屏幕上,之后所有页面都会以加宽方式打开","在此螢幕上,之後所有頁面都會以加寬方式開啟","A partir de ahora todas las páginas se abren anchas en esta pantalla","Désormais toutes les pages s’ouvrent en large sur cet écran","Auf diesem Bildschirm öffnen ab jetzt alle Seiten breit","Da ora tutte le pagine si aprono larghe su questo schermo","A partir de agora todas as páginas abrem largas neste ecrã"],
"Every page, as one .md file": ["すべてのページを 1 つの .md ファイルに","所有页面合并为一个 .md 文件","所有頁面合併為一個 .md 檔","Todas las páginas, en un solo archivo .md","Toutes les pages, en un seul fichier .md","Jede Seite, in einer .md-Datei","Tutte le pagine, in un unico file .md","Todas as páginas num único ficheiro .md"],
@@ -292,7 +290,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Password": ["パスワード","密码","密碼","Contraseña","Mot de passe","Passwort","Password","Palavra-passe"],
"Password removed. Save to write the space unencrypted.": ["パスワードを削除しました。保存すると、このスペースは暗号化なしで書き込まれます。","已移除密码。保存后空间将以未加密方式写入。","已移除密碼。儲存後空間將以未加密方式寫入。","Contraseña eliminada. Guarda para escribir el espacio sin cifrar.","Mot de passe supprimé. Enregistrez pour écrire l’espace non chiffré.","Passwort entfernt. Speichere, um den Space unverschlüsselt zu schreiben.","Password rimossa. Salva per scrivere lo spazio non cifrato.","Palavra-passe removida. Guarde para escrever o espaço sem encriptação."],
"Password set. Save to write the space encrypted.": ["パスワードを設定しました。保存すると、このスペースは暗号化して書き込まれます。","已设置密码。保存后空间将以加密方式写入。","已設定密碼。儲存後空間將以加密方式寫入。","Contraseña establecida. Guarda para escribir el espacio cifrado.","Mot de passe défini. Enregistrez pour écrire l’espace chiffré.","Passwort gesetzt. Speichere, um den Space verschlüsselt zu schreiben.","Password impostata. Salva per scrivere lo spazio cifrato.","Palavra-passe definida. Guarde para escrever o espaço encriptado."],
- "Password…": ["パスワード…","密码…","密碼…","Contraseña…","Mot de passe…","Passwort…","Password…","Palavra-passe…"],
"Paste document JSON here…": ["ここにドキュメント JSON を貼り付け…","在此粘贴文档 JSON…","在此貼上文件 JSON…","Pega aquí el JSON del documento…","Collez le JSON du document ici…","Dokument-JSON hier einfügen…","Incolla qui il JSON del documento…","Cole aqui o JSON do documento…"],
"Paste or type a link": ["リンクを貼り付けるか入力してください","粘贴或输入链接","貼上或輸入連結","Pega o escribe un enlace","Collez ou saisissez un lien","Link einfügen oder eingeben","Incolla o scrivi un collegamento","Cole ou digite um link"],
"People in this space": ["このスペースにいる人","此空间中的人","此空間中的人","Personas en este espacio","Personnes dans cet espace","Personen in diesem Space","Persone in questo spazio","Pessoas neste espaço"],
@@ -306,7 +303,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Poster…": ["ポスター…","封面图…","封面圖…","Póster…","Affiche…","Poster…","Poster…","Miniatura…"],
"Previous (⇧⏎)": ["前へ (⇧⏎)","上一个 (⇧⏎)","上一個 (⇧⏎)","Anterior (⇧⏎)","Précédent (⇧⏎)","Zurück (⇧⏎)","Precedente (⇧⏎)","Anterior (⇧⏎)"],
"Print": ["印刷","打印","列印","Imprimir","Imprimer","Drucken","Stampa","Imprimir"],
- "Print / PDF…": ["印刷 / PDF…","打印 / PDF…","列印 / PDF…","Imprimir / PDF…","Imprimer / PDF…","Drucken / PDF…","Stampa / PDF…","Imprimir / PDF…"],
"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"],
@@ -416,7 +412,6 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"The rest name notes that were not in the selection, and are left as text.": ["残りは選択に含まれていないノートを指しており、テキストのまま残ります。","其余指向不在所选范围内的笔记,保留为文字。","其餘指向不在所選範圍內的筆記,保留為文字。","El resto nombra notas que no estaban en la selección y se dejan como texto.","Les autres désignent des notes absentes de la sélection et restent en texte.","Der Rest nennt Notizen, die nicht in der Auswahl waren, und bleibt als Text stehen.","Gli altri nominano note che non erano nella selezione e restano come testo.","Os restantes nomeiam notas que não estavam na seleção e ficam como texto."],
"The theme follows whoever opens the file. It is never written into the document.": ["テーマはファイルを開いた人に従います。ドキュメントには書き込まれません。","主题跟随打开文件的人,绝不会写入文档。","主題取決於開啟檔案的人,永遠不會寫入文件中。","El tema sigue a quien abre el archivo. Nunca se escribe en el documento.","Le thème suit la personne qui ouvre le fichier. Il n’est jamais écrit dans le document.","Das Design richtet sich danach, wer die Datei öffnet. Es wird nie ins Dokument geschrieben.","Il tema segue chi apre il file. Non viene mai scritto nel documento.","O tema segue quem abre o ficheiro. Nunca é escrito no documento."],
"The whole space": ["スペース全体","整个空间","整個空間","Todo el espacio","Tout l’espace","Der ganze Space","L’intero spazio","Todo o espaço"],
- "The whole space, or just this page": ["スペース全体、またはこのページだけ","整个空间,或仅这一页","整個空間,或僅此頁面","Todo el espacio, o solo esta página","Tout l’espace, ou seulement cette page","Der ganze Space oder nur diese Seite","L’intero spazio, o solo questa pagina","Todo o espaço, ou apenas esta página"],
"These windows are on this computer. Start a session to work with someone elsewhere.": ["これらのウィンドウはこのパソコン内のものです。別の場所にいる人と作業するにはセッションを開始してください。","这些窗口都在本机。若要与其他地方的人协作,请开始一个会话。","這些視窗都在本機。若要與其他地方的人協作,請開始一個工作階段。","Estas ventanas están en este ordenador. Inicia una sesión para trabajar con alguien en otro sitio.","Ces fenêtres sont sur cet ordinateur. Démarrez une session pour travailler avec quelqu’un ailleurs.","Diese Fenster sind auf diesem Computer. Starte eine Sitzung, um mit jemand anderem zu arbeiten.","Queste finestre sono su questo computer. Avvia una sessione per lavorare con qualcuno altrove.","Estas janelas estão neste computador. Inicia uma sessão para trabalhar com alguém noutro lugar."],
"This block has no settings of its own — its content is all of it.": ["このブロックに固有の設定はありません — 中身がすべてです。","这个块没有自己的设置 — 内容就是它的全部。","這個區塊沒有自己的設定 — 內容就是它的全部。","Este bloque no tiene ajustes propios: su contenido es todo lo que hay.","Ce bloc n’a pas de réglages à lui — son contenu, c’est tout.","Dieser Block hat keine eigenen Einstellungen — sein Inhalt ist alles.","Questo blocco non ha impostazioni proprie: il suo contenuto è tutto.","Este bloco não tem definições próprias — o conteúdo é tudo o que há."],
"This block’s settings, and the page’s": ["このブロックの設定と、ページの設定","这个块的设置,还有页面的设置","這個區塊的設定,還有頁面的設定","Los ajustes de este bloque, y los de la página","Les réglages de ce bloc, et ceux de la page","Die Einstellungen dieses Blocks — und die der Seite","Le impostazioni di questo blocco, e quelle della pagina","As definições deste bloco, e as da página"],
diff --git a/spaces/src/styles.css b/spaces/src/styles.css
index f77f72c3..d6de45df 100644
--- a/spaces/src/styles.css
+++ b/spaces/src/styles.css
@@ -1327,7 +1327,13 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
The rule is slides' rule: drop text and fold the less-used controls into ⋯,
so every action stays reachable at every width. A horizontally scrolling
toolbar hides the same controls, just less honestly. */
-.sp-more { display: none; }
+/* ⋯ IS A HOME, NOT JUST AN OVERFLOW. It used to be display:none until the bar
+ folded, which was right while every command it held also had a button in the
+ bar. It no longer does: the commands you reach for once a session live here
+ at every width, so hiding it on a desktop would make New page, the journal,
+ import, print and About unreachable with a mouse. It still ALSO collects
+ whatever the bar drops as the window narrows. */
+.sp-more { display: inline-flex; }
/* The tier starts at the DRAWER breakpoint (820px), not at 720. It was 720, and
measured at 768 — an iPad in portrait — the bar still laid out 795px wide: the
@@ -1361,7 +1367,6 @@ button.sp-callout-chip:hover { text-decoration: underline; text-underline-offset
away, and the editor asks the DOM which tier is live rather than re-deriving
it from a width — see fitTopbar. */
.sp-bar-fold .sp-sec { display: none; }
-.sp-bar-fold .sp-more { display: inline-flex; }
.sp-bar-fold .sp-mark { display: none; }
.sp-bar-fold .sp-group-history { display: none; }
.sp-bar-fold .sp-split .sp-caret { display: none; }