Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

spaces: an invite says it carries version history, and can leave it out (#673)

nyblnet630db2c8371c
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 40c866e7..dc30a2dd 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -10000,3 +10000,27 @@ option on invites.
Pointers: spaces/src/history.ts, scripts/test-spaces-history.ts,
scripts/test-spaces-save-revisions.ts (the prepare rows and the main.ts pins),
scripts/test-spaces-copytiers.ts (real revisions per tier).
+
+## 2026-10-10 — a spaces invite discloses its history and can leave it out
+
+**Decision.** The kernel's invite tier keeps the `history` class, and the
+maintainer's ruling makes that conditional: an invite may carry history only
+when the inviter is told so and can leave it out. So **Share → Invite to
+edit…** on a space that has any history field opens one kernel dialog first:
+"This copy includes the space’s version history.", a **Leave version history
+out** checkbox (unticked, default include), Cancel and Save invite…. A space
+with no history field gets no step.
+
+**Leaving it out is by class, not by name.** `inviteCopy(doc, { withHistory:
+false })` is the invite tier exactly, then every field `SPACES_FIELDS` classes
+`history` is removed (share.ts `HISTORY_CLASS`, typed through the kernel's
+`FieldsOfClass`). Today that is `revisions` and `trail`; a history field
+declared later is covered by the same choice without an edit. Nothing else
+in the copy changes: same collab projection, same fresh invite, same pages.
+This is the one post-projection edit an invite makes besides `collab.on`, and
+it only ever removes fields; the copy-tier rig's hand-strip sweep is unchanged
+and still green.
+
+Pointers: spaces/src/share.ts, spaces/src/editor.ts `confirmInviteHistory`,
+scripts/test-spaces-copytiers.ts (the invite-choice rows and the planted
+builder that ignores the option).
diff --git a/scripts/test-spaces-copytiers.ts b/scripts/test-spaces-copytiers.ts
index a6f37fcb..bd80ab4e 100644
--- a/scripts/test-spaces-copytiers.ts
+++ b/scripts/test-spaces-copytiers.ts
@@ -51,7 +51,7 @@ const g = globalThis as unknown as Record<string, unknown>
g.localStorage = shim
g.window = g.window ?? { localStorage: shim, addEventListener() {}, setTimeout, clearTimeout }
-const { inviteCopy, readerCopy, duplicateAsNew } = await import('../spaces/src/share.ts')
+const { inviteCopy, readerCopy, duplicateAsNew, HISTORY_CLASS, hasHistory } = await import('../spaces/src/share.ts')
const { extractSpace } = await import('../spaces/src/portable.ts')
const { readingCopy, stripComments } = await import('../spaces/src/reading.ts')
const { docForExport, FORMAT } = await import('../spaces/src/model.ts')
@@ -222,6 +222,64 @@ console.log('\nreal in-file history (history.ts), tier by tier')
}
// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// THE INVITE'S HISTORY CHOICE (the maintainer's history ruling): an invite
+// keeps history only when the inviter was told and could leave it out. The
+// default keeps the history class byte-for-byte; "Leave version history out"
+// is the invite tier minus every field classed 'history' — read from the map
+// (share.ts HISTORY_CLASS), never named by hand — and NOTHING else changes.
+console.log('\ninvite — "Leave version history out" (share.ts inviteCopy { withHistory })')
+type InviteBuilder = (d: SpacesDoc, o: { withHistory?: boolean }) => Promise<SpacesDoc | null>
+/** Everything but the history class and the freshly-minted invite keys. */
+const sansHistory = (o: Obj): string => {
+ const x = clone(o)
+ for (const k of HISTORY_CLASS) delete x[k]
+ const c = x.collab as Obj | undefined
+ if (c) { delete c.invite }
+ return JSON.stringify(Object.fromEntries(Object.entries(x).sort(([a], [b]) => a.localeCompare(b))))
+}
+async function checkInviteChoice(build: InviteBuilder, label: string): Promise<boolean> {
+ const before = failures
+ const src = source()
+ const keep = (await build(source(), {}))! as Obj
+ const keepExplicit = (await build(source(), { withHistory: true }))! as Obj
+ const out = (await build(source(), { withHistory: false }))! as Obj
+ ok(JSON.stringify(keep.revisions) === JSON.stringify(src.revisions) && JSON.stringify(keep.trail) === JSON.stringify((src as Obj).trail),
+ `${label}: the DEFAULT invite keeps revisions and trail byte-for-byte`)
+ ok(JSON.stringify(keepExplicit.revisions) === JSON.stringify(src.revisions), `${label}: withHistory:true is the same as the default`)
+ ok(!('revisions' in out) && !('trail' in out), `${label}: "leave out" — no revisions, no trail`)
+ ok(!JSON.stringify(out).includes('THE-WHOLE-SPACE'), `${label}: "leave out" — the deleted page's text appears nowhere`)
+ ok(sansHistory(out) === sansHistory(keep), `${label}: "leave out" — everything else identical to the default invite (collab minus its fresh invite keys included)`)
+ ok((out.collab as Obj)?.role === 'writer' && (out.collab as Obj)?.on === true && !!(out.collab as Obj)?.invite,
+ `${label}: "leave out" is still a live writer invite`)
+ noSecrets(out, `${label} (leave out)`, true)
+ return failures === before
+}
+{
+ ok(JSON.stringify([...HISTORY_CLASS].sort()) === JSON.stringify(Object.keys(SPACES_FIELDS).filter((k) => (SPACES_FIELDS as Record<string, string>)[k] === 'history').sort()),
+ `HISTORY_CLASS is the map's history class (${HISTORY_CLASS.join(', ')})`)
+ ok(hasHistory(source()) && !hasHistory({ ...source(), revisions: undefined, trail: undefined } as SpacesDoc),
+ 'hasHistory: true with revisions or trail, false with neither (the notice shows only then)')
+ await checkInviteChoice(inviteCopy, 'invite')
+ // NOT VACUOUS: a builder that ignores the option must fail these rows
+ const ignoring: InviteBuilder = (d) => inviteCopy(d)
+ const f0 = failures, c0 = checks
+ console.log(' (planted builder that ignores the option — these rows MUST fail:)')
+ const passed = await checkInviteChoice(ignoring, 'planted')
+ const red = failures - f0
+ failures = f0; checks = c0
+ ok(!passed && red >= 2, `an invite builder that ignores "leave version history out" FAILS these checks (${red} rows red)`)
+ // the editor hands the inviter's choice to the builder
+ const { readFileSync, existsSync } = await import('node:fs')
+ const { dirname, join, resolve } = await import('node:path')
+ let root = resolve(process.cwd())
+ while (!existsSync(join(root, 'spaces/src/docclass.ts')) && dirname(root) !== root) root = dirname(root)
+ const ed = readFileSync(join(root, 'spaces/src/editor.ts'), 'utf8')
+ const sc = ed.slice(ed.indexOf('private async shareCopy('), ed.indexOf('private confirmInviteHistory('))
+ ok(/hasHistory\(this\.store\.doc\)[\s\S]*confirmInviteHistory\(\)[\s\S]*inviteCopy\(this\.store\.doc, \{ withHistory \}\)/.test(sc),
+ 'the Share → Invite step asks only when the space has history, and passes the answer to inviteCopy')
+}
+
console.log('\nreader — "Share → view-only copy" (share.ts readerCopy)')
const EXPECT_READER = sorted([...CONTENT, 'docId', 'collab', 'readonly'])
// THE ABSENT-FIELD CASE. A space with no `readonly` key at all — almost every
diff --git a/spaces/CHANGELOG.md b/spaces/CHANGELOG.md
index b575e1c3..1103dd2c 100644
--- a/spaces/CHANGELOG.md
+++ b/spaces/CHANGELOG.md
@@ -1316,6 +1316,13 @@ Versions follow `0.MINOR.PATCH` while pre-1.0.
Pasting document JSON over the space no longer touches the history, and
neither does undo.
+- **Invites say they carry the history, and can leave it out.** When a space
+ has version history, **Share → Invite to edit…** now asks first: "This copy
+ includes the space’s version history." Ticking **Leave version history out**
+ saves the invite with no versions, so the deleted text in them stays behind;
+ the file you are editing keeps all of them either way. The default is to
+ include it. A space with no history goes straight to saving, as before.
+
## [0.1.0] — 2026-08-03
First release.
diff --git a/spaces/src/editor.ts b/spaces/src/editor.ts
index 4c7fe224..981cb911 100644
--- a/spaces/src/editor.ts
+++ b/spaces/src/editor.ts
@@ -6269,6 +6269,16 @@ export class Editor {
// the way out would arm this space's session for a file that carries none
// of its keys, which is a session nobody asked for.
if (kind === 'reading') { await this.saveReadingCopy(); return }
+ // An invite KEEPS the space's version history (the kernel's invite rule),
+ // and history remembers text that was deleted. So when there is any, the
+ // inviter is told before the copy is made and may leave it out. A space
+ // with no history gets no extra step — nothing to disclose.
+ let withHistory = true
+ if (kind === 'invite' && shareModule.hasHistory(this.store.doc)) {
+ const choice = await this.confirmInviteHistory()
+ if (choice === null) return
+ withHistory = choice
+ }
await this.goLive()
// Committed first for the same reason slides commits its text edit: a
// half-typed block that only exists in the DOM is not in the copy.
@@ -6278,7 +6288,7 @@ export class Editor {
// (readerCopy clears it again — a viewer is not a fork.)
shareModule.stampSync(this.store, this.session)
const out = kind === 'invite'
- ? await shareModule.inviteCopy(this.store.doc)
+ ? await shareModule.inviteCopy(this.store.doc, { withHistory })
: shareModule.readerCopy(this.store.doc)
if (!out) {
this.notice(kind === 'invite'
@@ -6294,6 +6304,42 @@ export class Editor {
}
}
+ /**
+ * The one step before an invite of a space that has history: say that the
+ * copy carries it, and offer to leave it out (default: include). Resolves
+ * true = include, false = leave out, null = cancelled. A kernel dialog via
+ * openOverlay; the Save button is the user gesture the file picker needs.
+ */
+ private confirmInviteHistory(): Promise<boolean | null> {
+ return new Promise((resolve) => {
+ let answered = false
+ const done = (v: boolean | null) => { if (!answered) { answered = true; resolve(v) } }
+ const d = this.openOverlay(t('Invite to edit…').replace(/…$/, ''), (body, close) => {
+ body.append(el('p', 'sp-note', t('This copy includes the space’s version history.')))
+ const label = el('label', 'sp-ab-check')
+ const cb = el('input', 'sp-invite-leaveout')
+ cb.type = 'checkbox'
+ label.append(cb, document.createTextNode(' ' + t('Leave version history out')))
+ label.title = t('Versions include text that was deleted. This file keeps them either way.')
+ body.append(label)
+ const acts = el('div', 'sp-actions sp-dlg-actions')
+ const cancel = el('button', 'sp-btn', t('Cancel'))
+ cancel.type = 'button'
+ cancel.addEventListener('click', () => { done(null); close() })
+ const go = el('button', 'sp-btn sp-primary', t('Save invite…'))
+ go.type = 'button'
+ go.addEventListener('click', () => { done(!cb.checked); close() })
+ acts.append(cancel, go)
+ body.append(acts)
+ queueMicrotask(() => go.focus())
+ })
+ d.card.classList.add('sp-dlg-narrow')
+ // Escape, the scrim or another overlay: closing without an answer is a
+ // cancel. closeOverlay() runs overlayOff on every close path.
+ this.overlayOff.push(() => done(null))
+ })
+ }
+
/**
* Save a copy for somebody who is only going to read it.
*
diff --git a/spaces/src/i18n/de.ts b/spaces/src/i18n/de.ts
index 5d301d23..f15f76e4 100644
--- a/spaces/src/i18n/de.ts
+++ b/spaces/src/i18n/de.ts
@@ -961,9 +961,13 @@ export const de: Catalog = {
"{p} page(s), {b} block(s) changed": "{p} Seite(n), {b} Block/Blöcke geändert",
"Versions in this file…": "Versionen in dieser Datei…",
"Kept inside the file, one per save, so they travel with it. Restoring is undoable.": "In der Datei aufbewahrt, eine pro Speichern, und reisen mit ihr. Wiederherstellen lässt sich rückgängig machen.",
- "This space is too large to keep versions inside the file.": "Dieser Bereich ist zu groß, um Versionen in der Datei aufzubewahren.",
+ "This space is too large to keep versions inside the file.": "Dieser Space ist zu groß, um Versionen in der Datei aufzubewahren.",
"Versions include text you have deleted. They travel in this file and in invites; reading copies, view-only copies and Copy document JSON leave them out.": "Versionen enthalten auch Text, den du gelöscht hast. Sie reisen in dieser Datei und in Einladungen mit; Lesekopien, Nur-Ansehen-Kopien und „Dokument-JSON kopieren“ lassen sie weg.",
"Clear history…": "Verlauf löschen…",
"First version kept in this file": "Erste in dieser Datei aufbewahrte Version",
"Changes outside the pages — title, design, footnotes or templates": "Änderungen außerhalb der Seiten — Titel, Gestaltung, Fußnoten oder Vorlagen",
+ "This copy includes the space’s version history.": "Diese Kopie enthält den Versionsverlauf des Space.",
+ "Leave version history out": "Versionsverlauf weglassen",
+ "Versions include text that was deleted. This file keeps them either way.": "Versionen enthalten auch gelöschten Text. Diese Datei behält sie in jedem Fall.",
+ "Save invite…": "Einladung speichern…",
}
diff --git a/spaces/src/i18n/es.ts b/spaces/src/i18n/es.ts
index 33ade92a..7cfd3557 100644
--- a/spaces/src/i18n/es.ts
+++ b/spaces/src/i18n/es.ts
@@ -966,4 +966,8 @@ export const es: Catalog = {
"Clear history…": "Borrar el historial…",
"First version kept in this file": "Primera versión guardada en este archivo",
"Changes outside the pages — title, design, footnotes or templates": "Cambios fuera de las páginas: título, diseño, notas al pie o plantillas",
+ "This copy includes the space’s version history.": "Esta copia incluye el historial de versiones del espacio.",
+ "Leave version history out": "Dejar fuera el historial de versiones",
+ "Versions include text that was deleted. This file keeps them either way.": "Las versiones incluyen texto que se borró. Este archivo las conserva en cualquier caso.",
+ "Save invite…": "Guardar invitación…",
}
diff --git a/spaces/src/i18n/fr.ts b/spaces/src/i18n/fr.ts
index 222308ed..e1858d03 100644
--- a/spaces/src/i18n/fr.ts
+++ b/spaces/src/i18n/fr.ts
@@ -966,4 +966,8 @@ export const fr: Catalog = {
"Clear history…": "Effacer l’historique…",
"First version kept in this file": "Première version conservée dans ce fichier",
"Changes outside the pages — title, design, footnotes or templates": "Modifications hors des pages — titre, design, notes de bas de page ou modèles",
+ "This copy includes the space’s version history.": "Cette copie inclut l’historique des versions de l’espace.",
+ "Leave version history out": "Ne pas inclure l’historique des versions",
+ "Versions include text that was deleted. This file keeps them either way.": "Les versions contiennent du texte supprimé. Ce fichier les conserve dans tous les cas.",
+ "Save invite…": "Enregistrer l’invitation…",
}
diff --git a/spaces/src/i18n/it.ts b/spaces/src/i18n/it.ts
index a6e7a7e5..b78fab1a 100644
--- a/spaces/src/i18n/it.ts
+++ b/spaces/src/i18n/it.ts
@@ -966,4 +966,8 @@ export const it: Catalog = {
"Clear history…": "Cancella la cronologia…",
"First version kept in this file": "Prima versione conservata in questo file",
"Changes outside the pages — title, design, footnotes or templates": "Modifiche fuori dalle pagine: titolo, design, note a piè di pagina o modelli",
+ "This copy includes the space’s version history.": "Questa copia include la cronologia delle versioni dello spazio.",
+ "Leave version history out": "Escludi la cronologia delle versioni",
+ "Versions include text that was deleted. This file keeps them either way.": "Le versioni includono testo eliminato. Questo file le conserva in ogni caso.",
+ "Save invite…": "Salva l’invito…",
}
diff --git a/spaces/src/i18n/ja.ts b/spaces/src/i18n/ja.ts
index 83d40bfc..e732cdb5 100644
--- a/spaces/src/i18n/ja.ts
+++ b/spaces/src/i18n/ja.ts
@@ -966,4 +966,8 @@ export const ja: Catalog = {
"Clear history…": "履歴を削除…",
"First version kept in this file": "このファイルに記録された最初のバージョン",
"Changes outside the pages — title, design, footnotes or templates": "ページ以外の変更 — タイトル、デザイン、脚注、テンプレート",
+ "This copy includes the space’s version history.": "このコピーには、スペースのバージョン履歴が含まれます。",
+ "Leave version history out": "バージョン履歴を含めない",
+ "Versions include text that was deleted. This file keeps them either way.": "バージョンには削除された本文も含まれます。このファイルにはどちらの場合も残ります。",
+ "Save invite…": "招待を保存…",
}
diff --git a/spaces/src/i18n/packed.ts b/spaces/src/i18n/packed.ts
index 7b105842..7f09204e 100644
--- a/spaces/src/i18n/packed.ts
+++ b/spaces/src/i18n/packed.ts
@@ -374,6 +374,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Layout": ["レイアウト","版式","版式","Composición","Mise en page","Layout","Impaginazione","Paginação"],
"Leave it empty to use the tone mark": ["空のままにすると種類の記号を使います","留空则使用该类型的标记","留空則使用該類型的標記","Déjalo vacío para usar el símbolo del tipo","Laissez vide pour utiliser le symbole du type","Leer lassen, um das Symbol der Art zu verwenden","Lascia vuoto per usare il simbolo del tipo","Deixe vazio para usar o símbolo do tipo"],
"Leave the reading view": ["読書ビューを終了","退出阅读视图","離開閱讀檢視","Salir de la vista de lectura","Quitter la vue lecture","Leseansicht verlassen","Esci dalla vista di lettura","Sair da vista de leitura"],
+ "Leave version history out": ["バージョン履歴を含めない","不包含版本历史","不包含版本歷程","Dejar fuera el historial de versiones","Ne pas inclure l’historique des versions","Versionsverlauf weglassen","Escludi la cronologia delle versioni","Deixar de fora o histórico de versões"],
"Ledger": ["台帳","账簿","帳簿","Libro mayor","Grand livre","Hauptbuch","Libro mastro","Livro-razão"],
"Light": ["ライト","浅色","淺色","Claro","Clair","Hell","Chiaro","Claro"],
"Line spacing": ["行間","行距","行距","Interlineado","Interligne","Zeilenabstand","Interlinea","Entrelinha"],
@@ -590,6 +591,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Save as template": ["テンプレートとして保存","保存为模板","儲存為範本","Guardar como plantilla","Enregistrer comme modèle","Als Vorlage sichern","Salva come modello","Guardar como modelo"],
"Save as… — copy, new space, password": ["別名で保存… — コピー・新しいスペース・パスワード","另存为… — 副本、新空间、密码","另存為… — 副本、新空間、密碼","Guardar como… — copia, espacio nuevo, contraseña","Enregistrer sous… — copie, nouvel espace, mot de passe","Speichern unter… — Kopie, neuer Space, Passwort","Salva come… — copia, nuovo spazio, password","Guardar como… — cópia, novo espaço, palavra-passe"],
"Save failed — see console": ["保存に失敗 — コンソールを確認","保存失败 — 请查看控制台","儲存失敗 — 請查看主控台","Error al guardar — mira la consola","Échec de l’enregistrement — voir la console","Speichern fehlgeschlagen — siehe Konsole","Salvataggio non riuscito — vedi console","Falha ao guardar — vê a consola"],
+ "Save invite…": ["招待を保存…","保存邀请…","儲存邀請…","Guardar invitación…","Enregistrer l’invitation…","Einladung speichern…","Salva l’invito…","Guardar convite…"],
"Save template": ["テンプレートを保存","保存模板","儲存範本","Guardar plantilla","Enregistrer le modèle","Vorlage sichern","Salva modello","Guardar modelo"],
"Save this page as a template": ["このページをテンプレートとして保存","把这一页保存为模板","把這一頁儲存為範本","Guardar esta página como plantilla","Enregistrer cette page comme modèle","Diese Seite als Vorlage sichern","Salva questa pagina come modello","Guardar esta página como modelo"],
"Saved": ["保存しました","已保存","已儲存","Guardado","Enregistré","Gespeichert","Salvato","Guardado"],
@@ -706,6 +708,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"This browser cannot write back to the file, so every save makes a new copy. Chrome and Edge on a computer can save in place.": ["このブラウザはファイルに書き戻せないため、保存のたびに新しいコピーができます。パソコンの Chrome と Edge なら直接上書き保存できます。","此浏览器无法写回原文件,因此每次保存都会生成新副本。电脑上的 Chrome 和 Edge 可以就地保存。","此瀏覽器無法寫回檔案,因此每次儲存都會產生新的副本。電腦版的 Chrome 和 Edge 可以就地儲存。","Este navegador no puede reescribir el archivo, así que cada guardado crea una copia nueva. Chrome y Edge en un ordenador sí pueden guardar en el sitio.","Ce navigateur ne peut pas réécrire le fichier : chaque enregistrement crée donc une nouvelle copie. Chrome et Edge sur ordinateur enregistrent sur place.","Dieser Browser kann nicht in die Datei zurückschreiben, deshalb entsteht bei jedem Speichern eine neue Kopie. Chrome und Edge auf dem Computer können direkt speichern.","Questo browser non può riscrivere il file, quindi ogni salvataggio crea una nuova copia. Chrome ed Edge su computer possono salvare sul posto.","Este navegador não consegue escrever de volta no ficheiro, por isso cada vez que guarda cria uma nova cópia. O Chrome e o Edge num computador conseguem guardar no local."],
"This clip is {size} and travels inside the file, making it that much bigger for everyone you send it to. Embed it anyway?": ["このクリップは {size} あり、ファイルの中に一緒に入ります。その分、送る相手全員にとってファイルが大きくなります。それでも埋め込みますか?","这个片段有 {size},会嵌在文件内部,你发给谁,文件对谁就大出这么多。仍要嵌入吗?","這個片段有 {size},而且會跟著檔案一起走,你傳給的每個人拿到的檔案都會大這麼多。仍要嵌入嗎?","Este clip pesa {size} y viaja dentro del archivo, que crecerá otro tanto para todos a quienes se lo envíes. ¿Incrustarlo de todos modos?","Ce clip fait {size} et voyage dans le fichier, ce qui l’alourdit d’autant pour toutes les personnes à qui vous l’envoyez. L’intégrer quand même ?","Dieser Clip ist {size} groß und reist in der Datei mit — die Datei wird für jeden, dem du sie schickst, entsprechend größer. Trotzdem einbetten?","Questa clip è di {size} e viaggia dentro il file, rendendolo altrettanto più grande per chiunque la riceva. Incorporarla comunque?","Este clipe tem {size} e viaja dentro do ficheiro, tornando-o maior para todas as pessoas a quem o enviar. Incorporar mesmo assim?"],
"This copy goes offline; the others carry on": ["このコピーはオフラインになります。ほかの人はそのまま続けられます","此副本将离线;其他人继续协作","此副本將離線;其他人繼續協作","Esta copia se desconecta; las demás siguen","Cette copie passe hors ligne ; les autres continuent","Diese Kopie geht offline; die anderen machen weiter","Questa copia va offline; le altre continuano","Esta cópia fica offline; as outras continuam"],
+ "This copy includes the space’s version history.": ["このコピーには、スペースのバージョン履歴が含まれます。","此副本包含空间的版本历史。","此副本包含空間的版本歷程。","Esta copia incluye el historial de versiones del espacio.","Cette copie inclut l’historique des versions de l’espace.","Diese Kopie enthält den Versionsverlauf des Space.","Questa copia include la cronologia delle versioni dello spazio.","Esta cópia inclui o histórico de versões do espaço."],
"This embed is inside itself — the loop stops here.": ["この埋め込みは自分自身を含んでいます。ここでループを止めました。","该嵌入包含了自身——循环在此停止。","這個嵌入包含了自身——迴圈在此停止。","Esta inserción se contiene a sí misma: el bucle se detiene aquí.","Cette insertion se contient elle-même — la boucle s’arrête ici.","Diese Einbettung enthält sich selbst – die Schleife endet hier.","Questa incorporazione contiene sé stessa — il ciclo si ferma qui.","Esta incorporação contém-se a si própria — o ciclo para aqui."],
"This embed points at a page that is not here.": ["この埋め込みの参照先ページが見つかりません。","该嵌入指向的页面不存在。","這個嵌入指向的頁面不存在。","Esta inserción apunta a una página que no está aquí.","Cette insertion pointe vers une page qui n’est pas là.","Diese Einbettung zeigt auf eine Seite, die nicht hier ist.","Questa incorporazione punta a una pagina che non c’è.","Esta incorporação aponta para uma página que não está aqui."],
"This file": ["このファイル","此文件","此檔案","Este archivo","Ce fichier","Diese Datei","Questo file","Este ficheiro"],
@@ -731,7 +734,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"This space has no pages.": ["このスペースにはページがありません。","此空间没有页面。","此空間沒有任何頁面。","Este espacio no tiene páginas.","Cet espace n’a aucune page.","Dieser Space hat keine Seiten.","Questo spazio non ha pagine.","Este espaço não tem páginas."],
"This space is encrypted, so no versions are kept.": ["このスペースは暗号化されているため、バージョンは保存されません。","此空间已加密,因此不保存任何版本。","此空間已加密,因此不保存任何版本。","Este espacio está cifrado, así que no se guarda ninguna versión.","Cet espace est chiffré : aucune version n’est conservée.","Dieser Space ist verschlüsselt, deshalb werden keine Versionen aufbewahrt.","Questo spazio è cifrato, quindi non viene conservata alcuna versione.","Este espaço está cifrado, por isso não são guardadas versões."],
"This space is locked": ["このスペースはロックされています","此空间已锁定","此空間已鎖定","Este espacio está bloqueado","Cet espace est verrouillé","Dieser Space ist gesperrt","Questo spazio è bloccato","Este espaço está bloqueado"],
- "This space is too large to keep versions inside the file.": ["このスペースは大きすぎるため、ファイルの中にバージョンを保持できません。","此空间太大,无法在文件内保存版本。","此空間太大,無法在檔案內保存版本。","Este espacio es demasiado grande para guardar versiones dentro del archivo.","Cet espace est trop volumineux pour conserver des versions dans le fichier.","Dieser Bereich ist zu groß, um Versionen in der Datei aufzubewahren.","Questo spazio è troppo grande per conservare versioni nel file.","Este espaço é demasiado grande para guardar versões dentro do ficheiro."],
+ "This space is too large to keep versions inside the file.": ["このスペースは大きすぎるため、ファイルの中にバージョンを保持できません。","此空间太大,无法在文件内保存版本。","此空間太大,無法在檔案內保存版本。","Este espacio es demasiado grande para guardar versiones dentro del archivo.","Cet espace est trop volumineux pour conserver des versions dans le fichier.","Dieser Space ist zu groß, um Versionen in der Datei aufzubewahren.","Questo spazio è troppo grande per conservare versioni nel file.","Este espaço é demasiado grande para guardar versões dentro do ficheiro."],
"This space no longer uses a design of its own.": ["このスペースは独自のデザインを使わなくなりました。","此空间不再使用自己的设计。","此空間不再使用自己的設計。","Este espacio ya no usa un diseño propio.","Cet espace n’utilise plus de design qui lui soit propre.","Dieser Space verwendet keine eigene Gestaltung mehr.","Questo spazio non usa più un design proprio.","Este espaço já não usa um design próprio."],
"This space reads right-to-left; a deck has no such setting.": ["このスペースは右から左へ読みます。デッキにはその設定がありません。","这个空间从右向左阅读;演示文稿没有这项设置。","這個空間由右至左閱讀;簡報沒有這項設定。","Este espacio se lee de derecha a izquierda; una presentación no tiene ese ajuste.","Cet espace se lit de droite à gauche ; une présentation n’a pas ce réglage.","Dieser Raum wird von rechts nach links gelesen; eine Präsentation hat diese Einstellung nicht.","Questo spazio si legge da destra a sinistra; una presentazione non ha questa impostazione.","Este espaço lê-se da direita para a esquerda; uma apresentação não tem essa definição."],
"This view chooses its pages in a way this build does not understand, so it is showing the backlog instead.": ["このビューは、このバージョンが理解できない方法でページを選んでいるため、代わりにバックログを表示しています。","此视图以本版本无法理解的方式选择页面,因此改为显示待办列表。","此檢視以本版本無法理解的方式選擇頁面,因此改為顯示待辦清單。","Esta vista elige sus páginas de una forma que esta versión no entiende, así que muestra la lista de tareas.","Cette vue choisit ses pages d’une façon que cette version ne comprend pas ; elle affiche donc le backlog.","Diese Ansicht wählt ihre Seiten auf eine Weise, die diese Version nicht versteht, und zeigt stattdessen den Backlog.","Questa vista sceglie le sue pagine in un modo che questa versione non comprende, quindi mostra il backlog.","Esta vista escolhe as suas páginas de uma forma que esta versão não entende, por isso mostra o backlog."],
@@ -800,6 +803,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Versions are kept in this browser only — never in the file, never online. Restoring is undoable.": ["バージョンはこのブラウザーにのみ保存されます。ファイルにもオンラインにも残りません。復元は取り消せます。","版本仅保存在此浏览器中,不会写入文件,也不会上传。恢复操作可以撤销。","版本僅保存在此瀏覽器中,不會寫入檔案,也不會上傳。還原操作可以復原。","Las versiones se guardan solo en este navegador: nunca en el archivo ni en línea. Restaurar se puede deshacer.","Les versions sont conservées uniquement dans ce navigateur — jamais dans le fichier, jamais en ligne. La restauration est annulable.","Versionen liegen nur in diesem Browser — nie in der Datei, nie online. Das Wiederherstellen lässt sich rückgängig machen.","Le versioni restano solo in questo browser: mai nel file, mai online. Il ripristino si può annullare.","As versões ficam apenas neste navegador — nunca no ficheiro, nunca online. Restaurar pode ser desfeito."],
"Versions in this file": ["このファイルの中のバージョン","此文件中的版本","此檔案中的版本","Versiones dentro de este archivo","Versions dans ce fichier","Versionen in dieser Datei","Versioni in questo file","Versões dentro deste ficheiro"],
"Versions in this file…": ["このファイルの中のバージョン…","此文件中的版本…","此檔案中的版本…","Versiones dentro de este archivo…","Versions dans ce fichier…","Versionen in dieser Datei…","Versioni in questo file…","Versões dentro deste ficheiro…"],
+ "Versions include text that was deleted. This file keeps them either way.": ["バージョンには削除された本文も含まれます。このファイルにはどちらの場合も残ります。","版本中包含已删除的文字。无论如何,此文件都会保留它们。","版本中包含已刪除的文字。無論如何,此檔案都會保留它們。","Las versiones incluyen texto que se borró. Este archivo las conserva en cualquier caso.","Les versions contiennent du texte supprimé. Ce fichier les conserve dans tous les cas.","Versionen enthalten auch gelöschten Text. Diese Datei behält sie in jedem Fall.","Le versioni includono testo eliminato. Questo file le conserva in ogni caso.","As versões incluem texto que foi apagado. Este ficheiro guarda-as em qualquer caso."],
"Versions include text you have deleted. They travel in this file and in invites; reading copies, view-only copies and Copy document JSON leave them out.": ["バージョンには、削除した本文も含まれます。このファイルと招待には含まれますが、閲覧用コピー、表示専用コピー、「ドキュメント JSON をコピー」には含まれません。","版本中包含你删掉的文字。它们会随此文件和邀请一起流转;阅读副本、仅查看副本和“复制文档 JSON”都不包含它们。","版本中包含你刪掉的文字。它們會隨此檔案和邀請一起流轉;閱讀副本、僅檢視副本和「複製文件 JSON」都不包含它們。","Las versiones incluyen texto que has borrado. Viajan en este archivo y en las invitaciones; las copias de lectura, las copias de solo ver y «Copiar JSON del documento» las dejan fuera.","Les versions contiennent du texte que vous avez supprimé. Elles voyagent dans ce fichier et dans les invitations ; les copies de lecture, les copies en lecture seule et « Copier le JSON du document » les laissent de côté.","Versionen enthalten auch Text, den du gelöscht hast. Sie reisen in dieser Datei und in Einladungen mit; Lesekopien, Nur-Ansehen-Kopien und „Dokument-JSON kopieren“ lassen sie weg.","Le versioni includono testo che hai eliminato. Viaggiano in questo file e negli inviti; le copie di lettura, le copie di sola visualizzazione e «Copia JSON del documento» le escludono.","As versões incluem texto que apagaste. Viajam neste ficheiro e nos convites; as cópias de leitura, as cópias só de visualização e «Copiar JSON do documento» deixam-nas de fora."],
"Video": ["動画","视频","影片","Vídeo","Vidéo","Video","Video","Vídeo"],
"Video from {host}": ["{host} の動画","来自 {host} 的视频","來自 {host} 的影片","Vídeo de {host}","Vidéo provenant de {host}","Video von {host}","Video da {host}","Vídeo de {host}"],
diff --git a/spaces/src/i18n/pt.ts b/spaces/src/i18n/pt.ts
index dce014da..b82b657e 100644
--- a/spaces/src/i18n/pt.ts
+++ b/spaces/src/i18n/pt.ts
@@ -966,4 +966,8 @@ export const pt: Catalog = {
"Clear history…": "Limpar o histórico…",
"First version kept in this file": "Primeira versão guardada neste ficheiro",
"Changes outside the pages — title, design, footnotes or templates": "Alterações fora das páginas — título, design, notas de rodapé ou modelos",
+ "This copy includes the space’s version history.": "Esta cópia inclui o histórico de versões do espaço.",
+ "Leave version history out": "Deixar de fora o histórico de versões",
+ "Versions include text that was deleted. This file keeps them either way.": "As versões incluem texto que foi apagado. Este ficheiro guarda-as em qualquer caso.",
+ "Save invite…": "Guardar convite…",
}
diff --git a/spaces/src/i18n/zh-Hans.ts b/spaces/src/i18n/zh-Hans.ts
index bf04300e..b9e897e2 100644
--- a/spaces/src/i18n/zh-Hans.ts
+++ b/spaces/src/i18n/zh-Hans.ts
@@ -966,4 +966,8 @@ export const zh_Hans: Catalog = {
"Clear history…": "清除历史…",
"First version kept in this file": "此文件中保存的第一个版本",
"Changes outside the pages — title, design, footnotes or templates": "页面之外的改动——标题、设计、脚注或模板",
+ "This copy includes the space’s version history.": "此副本包含空间的版本历史。",
+ "Leave version history out": "不包含版本历史",
+ "Versions include text that was deleted. This file keeps them either way.": "版本中包含已删除的文字。无论如何,此文件都会保留它们。",
+ "Save invite…": "保存邀请…",
}
diff --git a/spaces/src/i18n/zh-Hant.ts b/spaces/src/i18n/zh-Hant.ts
index 30a573f3..471be5f8 100644
--- a/spaces/src/i18n/zh-Hant.ts
+++ b/spaces/src/i18n/zh-Hant.ts
@@ -966,4 +966,8 @@ export const zh_Hant: Catalog = {
"Clear history…": "清除歷史…",
"First version kept in this file": "此檔案中保存的第一個版本",
"Changes outside the pages — title, design, footnotes or templates": "頁面之外的變更——標題、設計、註腳或範本",
+ "This copy includes the space’s version history.": "此副本包含空間的版本歷程。",
+ "Leave version history out": "不包含版本歷程",
+ "Versions include text that was deleted. This file keeps them either way.": "版本中包含已刪除的文字。無論如何,此檔案都會保留它們。",
+ "Save invite…": "儲存邀請…",
}
diff --git a/spaces/src/share.ts b/spaces/src/share.ts
index e04a37ed..2fe7fd8f 100644
--- a/spaces/src/share.ts
+++ b/spaces/src/share.ts
@@ -33,7 +33,7 @@
// client and the deployed worker drift apart.
import { mintInvite } from '../../kernel/src/sync/online.ts'
-import { projectForCopy } from '../../kernel/src/docfields.ts'
+import { projectForCopy, type FieldsOfClass } from '../../kernel/src/docfields.ts'
import type { SpacesDoc } from './model.ts'
import { SPACES_FIELDS } from './docclass.ts'
@@ -101,7 +101,29 @@ export function canWrite(doc: SpacesDoc): boolean {
* Returns null when this copy is not the owner: a member copy cannot mint an
* invite, because it does not hold the key the chain is rooted in.
*/
-export async function inviteCopy(doc: SpacesDoc): Promise<SpacesDoc | null> {
+/** The fields the map classes 'history' (`revisions`, `trail`), READ from
+ * SPACES_FIELDS — never a hand list, so a history field added later is
+ * covered by the invite's "Leave version history out" the day it is declared. */
+export type HistoryField = FieldsOfClass<typeof SPACES_FIELDS, 'history'>
+export const HISTORY_CLASS: readonly HistoryField[] = (Object.keys(SPACES_FIELDS) as Array<keyof typeof SPACES_FIELDS>)
+ .filter((k): k is HistoryField => SPACES_FIELDS[k] === 'history')
+
+/** Does this space carry any history an invite would hand over? */
+export function hasHistory(doc: SpacesDoc): boolean {
+ return HISTORY_CLASS.some((k) => (doc as Record<string, unknown>)[k] !== undefined)
+}
+
+export interface InviteOpts {
+ /**
+ * Keep the history class in the copy — the kernel's invite rule, and the
+ * default. `false` is the inviter's "Leave version history out": the copy is
+ * the invite tier exactly, minus every field classed 'history'. History
+ * remembers text that was deleted, and an invite is a file for someone else.
+ */
+ withHistory?: boolean
+}
+
+export async function inviteCopy(doc: SpacesDoc, opts: InviteOpts = {}): Promise<SpacesDoc | null> {
const c = doc.collab
if (!c?.room || !c.key || !isOwner(doc)) return null
const invite = await mintInvite(c.ownerPriv!, 'writer')
@@ -114,6 +136,8 @@ export async function inviteCopy(doc: SpacesDoc): Promise<SpacesDoc | null> {
const out = projectForCopy(clone(doc), SPACES_FIELDS, 'invite', { invite })
// the one thing a space adds: the copy is live from the moment it opens
if (out.collab) out.collab.on = true
+ // the inviter chose to leave history out: drop it by CLASS, not by name
+ if (opts.withHistory === false) for (const k of HISTORY_CLASS) delete (out as Record<string, unknown>)[k]
return out
}