Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
v0.8.3: fullscreen presenting, responsive topbar, drag modifiers, hover fix, mobile pass
nyblnet8f7c4ee0f9ac
diff --git a/CLAUDE.md b/CLAUDE.mdindex 7c672607..835a851e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -180,6 +180,16 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.Undo under collab is snapshot-based and may revert concurrent remoteedits to the same properties (documented LWW compromise).- `src/editor/` — vanilla-TS editor. Moveable + Selecto handle manipulation.+ Interaction modifiers: Shift = keep-ratio resize / axis-locked drag / 15°+ rotate snap; ⌘/Ctrl-drag = duplicate (originals move, copies stay — one+ undo step; Alt stays reserved for deep-select, so it can't be the copy+ key). Present: real fullscreen via overlay.requestFullscreen at start ++ F toggle (denied requests degrade to tab-fill — that IS the testing/+ sharing mode). Topbar is responsive: labels collapse to icons <1280px,+ the bar itself x-scrolls; phones (<700px) boot with both side panels+ collapsed (canvas-first; toggles/[/] bring them back). Deck buttons use+ ONE invisible hit-rect above button+label (hard-won #7) — never put+ `link` on both a rect and its label text (two mismatched hover pills).Alt/Option-click digs through overlapping elements (capture-phase, beatsMoveable's control box). Fill/stroke colors carry alpha (color input + % pair,rgba round-trip); shapes support `fillGradient` (linear, CSS-convention angle,diff --git a/slides/package.json b/slides/package.jsonindex 11f89cb1..9491f090 100644--- a/slides/package.json+++ b/slides/package.json@@ -1,7 +1,7 @@{"name": "bento-slides","private": true,- "version": "0.8.2",+ "version": "0.8.3","type": "module","scripts": {"dev": "vite",diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.tsindex 165475f8..2411fdb5 100644--- a/slides/src/editor/canvas.ts+++ b/slides/src/editor/canvas.ts@@ -6,7 +6,7 @@ import Moveable from 'moveable'import Selecto from 'selecto'import type { Store } from '../store'import { t } from '../i18n'-import type { SlideElement } from '../model'+import { uid, type SlideElement } from '../model'import { renderSlide, sanitizeHtml } from '../render'import { autoformatAtCaret, clearAutoformat, markdownToHtml, undoAutoformat } from './markdown'import { PathEditor } from './patheditor'@@ -503,18 +503,53 @@ export class SlideCanvas {// --- moveable -------------------------------------------------------------+ /** ⌘/Ctrl-drag duplicate: originals move, copies stay behind (committed at drag end) */+ private pendingCopy: SlideElement[] | null = null+private wireMoveable() {const mv = this.moveable+ // start positions per target — Shift axis-locks against these+ const dragStarts = new Map<HTMLElement, { left: number; top: number }>()++ const noteDragStart = (target: HTMLElement, inputEvent: MouseEvent | undefined) => {+ dragStarts.set(target, {+ left: parseFloat(target.style.left) || 0,+ top: parseFloat(target.style.top) || 0,+ })+ if (inputEvent && (inputEvent.metaKey || inputEvent.ctrlKey) && !this.pendingCopy) {+ // duplicate-drag: snapshot the selection now; the stationary copies+ // are committed in one undo step together with the moved frames+ this.pendingCopy = this.store.selectedElements.map(+ (el) => JSON.parse(JSON.stringify(el)) as SlideElement,+ )+ }+ }+ const axisLock = (target: HTMLElement, left: number, top: number, ev: { inputEvent?: MouseEvent; dist?: number[] }) => {+ const start = dragStarts.get(target)+ if (!start || !ev.inputEvent?.shiftKey || !ev.dist) return { left, top }+ return Math.abs(ev.dist[0]) >= Math.abs(ev.dist[1])+ ? { left, top: start.top }+ : { left: start.left, top }+ }+ mv.on('dragStart', (e) => noteDragStart(e.target as HTMLElement, e.inputEvent as MouseEvent))+ mv.on('dragGroupStart', (e) =>+ e.events.forEach((ev) => noteDragStart(ev.target as HTMLElement, e.inputEvent as MouseEvent)),+ )mv.on('drag', (e) => {- e.target.style.left = `${e.left}px`- e.target.style.top = `${e.top}px`+ const p = axisLock(e.target as HTMLElement, e.left, e.top, e)+ e.target.style.left = `${p.left}px`+ e.target.style.top = `${p.top}px`})mv.on('dragGroup', (e) => e.events.forEach((ev) => {- ev.target.style.left = `${ev.left}px`- ev.target.style.top = `${ev.top}px`+ const p = axisLock(ev.target as HTMLElement, ev.left, ev.top, ev)+ ev.target.style.left = `${p.left}px`+ ev.target.style.top = `${p.top}px`}))+ // Shift while resizing keeps the aspect ratio (checked live per move)+ mv.on('resizeStart', (e) => { mv.keepRatio = !!(e.inputEvent as MouseEvent | undefined)?.shiftKey })mv.on('resize', (e) => {+ mv.keepRatio = !!(e.inputEvent as MouseEvent | undefined)?.shiftKeye.target.style.width = `${e.width}px`e.target.style.height = `${e.height}px`e.target.style.left = `${e.drag.left}px`@@ -526,19 +561,58 @@ export class SlideCanvas {ev.target.style.left = `${ev.drag.left}px`ev.target.style.top = `${ev.drag.top}px`}))+ // Shift while rotating snaps to 15° steps+ mv.on('rotateStart', (e) => { mv.throttleRotate = (e.inputEvent as MouseEvent | undefined)?.shiftKey ? 15 : 1 })mv.on('rotate', (e) => {+ mv.throttleRotate = (e.inputEvent as MouseEvent | undefined)?.shiftKey ? 15 : 1e.target.style.transform = `rotate(${e.rotation}deg)`})mv.on('rotateGroup', (e) => e.events.forEach((ev) => {ev.target.style.transform = ev.transform}))- const commitFrames = () => this.commitDomFrames(this.selectedNodes())- mv.on('dragEnd', ({ isDrag }) => isDrag && commitFrames())- mv.on('dragGroupEnd', ({ isDrag }) => isDrag && commitFrames())- mv.on('resizeEnd', ({ isDrag }) => isDrag && commitFrames())+ const commitFrames = () => {+ const copies = this.pendingCopy+ this.pendingCopy = null+ if (copies?.length) {+ // one undo step: stationary duplicates (fresh ids) + moved originals+ const nodes = this.selectedNodes()+ const frames = nodes.map((node) => ({+ id: node.dataset.elId!,+ x: parseFloat(node.style.left) || 0,+ y: parseFloat(node.style.top) || 0,+ }))+ this.store.commit(() => {+ const dupes = copies.map((el) => ({ ...el, id: uid(el.type[0]) }))+ this.store.slide.elements.push(...dupes)+ for (const f of frames) {+ const el = this.store.element(f.id)+ if (!el) continue+ el.x = Math.round(f.x * 10) / 10+ el.y = Math.round(f.y * 10) / 10+ }+ })+ return+ }+ this.commitDomFrames(this.selectedNodes())+ }+ mv.on('dragEnd', ({ isDrag }) => {+ if (isDrag) commitFrames()+ else this.pendingCopy = null+ })+ mv.on('dragGroupEnd', ({ isDrag }) => {+ if (isDrag) commitFrames()+ else this.pendingCopy = null+ })+ mv.on('resizeEnd', ({ isDrag }) => {+ mv.keepRatio = false+ if (isDrag) commitFrames()+ })mv.on('resizeGroupEnd', ({ isDrag }) => isDrag && commitFrames())- mv.on('rotateEnd', ({ isDrag }) => isDrag && commitFrames())+ mv.on('rotateEnd', ({ isDrag }) => {+ mv.throttleRotate = 1+ if (isDrag) commitFrames()+ })mv.on('rotateGroupEnd', ({ isDrag }) => isDrag && commitFrames())}diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 51462e20..06b4d5ca 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -194,7 +194,7 @@ export class Editor {}, 1500)const undoB = btn(ICONS.undo, '', () => this.store.undo(), t('Undo (⌘Z)'))const redoB = btn(ICONS.redo, '', () => this.store.redo(), t('Redo (⇧⌘Z)'))- const presentB = btn(ICONS.play, t('Present'), () => this.present(), t('Present from current slide'))+ const presentB = btn(ICONS.play, t('Present'), () => this.present(), t('Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends'))presentB.classList.add('ed-btn-primary')const saveB = btn(ICONS.save, t('Save'), () => this.save(false), t('Save — rewrite this file in place (⌘S)'))const saveAsB = btn(ICONS.download, '', () => this.save(true), t('Save a copy — pick a new file, leave this one untouched'))@@ -215,6 +215,13 @@ export class Editor {this.root.append(bar, main)+ // phones/small windows: start with both panels collapsed so the CANVAS+ // is what you see — the topbar toggles (and [ / ]) bring them back+ if (window.innerWidth < 700) {+ this.sidebar.classList.add('ed-collapsed')+ this.props.classList.add('ed-collapsed')+ }+this.restorePanelWidths()this.canvas = new SlideCanvas(canvasWrap, this.store)this.canvas.onCommentModeChange = (on) => commentB.classList.toggle('ed-btn-armed', on)diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.tsindex 5ce4a4a5..0ce1b6c8 100644--- a/slides/src/i18n/de.ts+++ b/slides/src/i18n/de.ts@@ -270,4 +270,5 @@ export const de: Catalog = {"Save as template…": "Als Vorlage speichern…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "Speichert eine Vorlagenkopie: Wer sie öffnet, erhält ein frisches, unabhängiges Deck mit eigener Identität und eigenen Schlüsseln.","Template saved — every open of it starts a fresh deck": "Vorlage gespeichert — jedes Öffnen startet ein frisches Deck",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "Ab aktueller Folie präsentieren — F wechselt Vollbild, S öffnet die Referentenansicht, Esc beendet",}diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.tsindex 535f546c..cfb48732 100644--- a/slides/src/i18n/es.ts+++ b/slides/src/i18n/es.ts@@ -270,4 +270,5 @@ export const es: Catalog = {"Save as template…": "Guardar como plantilla…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "Guarda una copia como plantilla: cada persona que la abra obtiene una presentación nueva e independiente, con identidad y claves propias.","Template saved — every open of it starts a fresh deck": "Plantilla guardada: cada apertura inicia una presentación nueva",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "Presentar desde la diapositiva actual — F alterna pantalla completa, S abre la vista de ponente, Esc termina",}diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.tsindex bb6cba27..f85fcdb6 100644--- a/slides/src/i18n/fr.ts+++ b/slides/src/i18n/fr.ts@@ -270,4 +270,5 @@ export const fr: Catalog = {"Save as template…": "Enregistrer comme modèle…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "Enregistre une copie modèle : chaque personne qui l'ouvre obtient un diaporama neuf et indépendant, avec sa propre identité et ses propres clés.","Template saved — every open of it starts a fresh deck": "Modèle enregistré — chaque ouverture démarre un nouveau diaporama",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "Présenter depuis la diapositive actuelle — F bascule le plein écran, S ouvre la vue présentateur, Échap termine",}diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.tsindex 1bed105f..def9a3f6 100644--- a/slides/src/i18n/it.ts+++ b/slides/src/i18n/it.ts@@ -270,4 +270,5 @@ export const it: Catalog = {"Save as template…": "Salva come modello…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "Salva una copia modello: chiunque la apra ottiene una presentazione nuova e indipendente, con identità e chiavi proprie.","Template saved — every open of it starts a fresh deck": "Modello salvato: ogni apertura avvia una nuova presentazione",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "Presenta dalla diapositiva corrente — F alterna lo schermo intero, S apre la vista relatore, Esc termina",}diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.tsindex a3009755..6073b5f3 100644--- a/slides/src/i18n/ja.ts+++ b/slides/src/i18n/ja.ts@@ -270,4 +270,5 @@ export const ja: Catalog = {"Save as template…": "テンプレートとして保存…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "テンプレートを保存します。開いた人はそれぞれ、独自の ID とキーを持つ独立した新しいデッキを取得します。","Template saved — every open of it starts a fresh deck": "テンプレートを保存しました — 開くたびに新しいデッキが始まります",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "現在のスライドからプレゼン開始 — F で全画面切替、S で発表者ビュー、Esc で終了",}diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.tsindex 5adf3aa3..4270525b 100644--- a/slides/src/i18n/zh-Hans.ts+++ b/slides/src/i18n/zh-Hans.ts@@ -270,4 +270,5 @@ export const zhHans: Catalog = {"Save as template…": "另存为模板…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "保存为模板副本:每个打开它的人都会得到一份全新的独立演示文稿,拥有自己的标识和密钥。","Template saved — every open of it starts a fresh deck": "模板已保存 — 每次打开都会生成新的演示文稿",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "从当前页开始演示 — F 切换全屏,S 打开演讲者视图,Esc 结束",}diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.tsindex a100089c..b39d57f9 100644--- a/slides/src/i18n/zh-Hant.ts+++ b/slides/src/i18n/zh-Hant.ts@@ -270,4 +270,5 @@ export const zhHant: Catalog = {"Save as template…": "另存為範本…","Saves a template copy: everyone who opens it gets a fresh, independent deck with its own identity and keys.": "儲存為範本副本:每個開啟它的人都會得到一份全新的獨立簡報,擁有自己的識別碼與金鑰。","Template saved — every open of it starts a fresh deck": "範本已儲存 — 每次開啟都會產生新的簡報",+ "Present from current slide — F toggles fullscreen, S opens speaker view, Esc ends": "從目前頁面開始簡報 — F 切換全螢幕,S 開啟簡報者檢視,Esc 結束",}diff --git a/slides/src/present.ts b/slides/src/present.tsindex 1ec2bd31..6232646c 100644--- a/slides/src/present.ts+++ b/slides/src/present.ts@@ -196,9 +196,23 @@ export function startPresentation(updateSpeaker()}+ // Real fullscreen (F toggles; Present enters it by default). The overlay+ // element is what goes fullscreen, so the speaker popup stays independent.+ // Requests can be denied (iframes, no user activation) — tab-fill mode is+ // the graceful floor, and stays the mode for testing/sharing via F.+ const enterFullscreen = () => {+ overlay.requestFullscreen?.({ navigationUI: 'hide' }).catch(() => {})+ }+ const toggleFullscreen = () => {+ if (document.fullscreenElement) document.exitFullscreen().catch(() => {})+ else enterFullscreen()+ }+ enterFullscreen()+const exit = () => {if (exited) returnexited = true+ if (document.fullscreenElement) document.exitFullscreen().catch(() => {})const last = deck.getIndices().htry {deck.destroy()@@ -231,6 +245,12 @@ export function startPresentation(openSpeaker()return}+ if (ev.key === 'f' || ev.key === 'F') {+ ev.preventDefault()+ ev.stopPropagation()+ toggleFullscreen()+ return+ }const key = ev.key || ({ 32: ' ', 37: 'ArrowLeft', 39: 'ArrowRight', 33: 'PageUp', 34: 'PageDown' } as Record<number, string>)[ev.keyCode]if (key === 'ArrowRight' || key === 'PageDown' || key === ' ') {ev.preventDefault()diff --git a/slides/src/starterdeck.ts b/slides/src/starterdeck.tsindex 5bb5fa26..fafcb245 100644--- a/slides/src/starterdeck.ts+++ b/slides/src/starterdeck.ts@@ -543,11 +543,17 @@ export function starterDoc(): BentoDoc {shape('rect', {id: T_B, x: 944, y: 560, w: 216, h: 52, radius: 26, fill: STEEL, fillGradient: GRAD_STEEL,stroke: 'rgba(255,255,255,0.18)', strokeWidth: 1,- link: S_CHARTS_PIE,}),text({x: 944, y: 574, w: 216, h: 28, html: 'See the split →', fontSize: 17, fontWeight: 700,- color: '#FFFFFF', align: 'center', link: S_CHARTS_PIE,+ color: '#FFFFFF', align: 'center',+ }),+ // ONE interactive surface per control: an invisible hit rect above+ // button + label — a single, coherent hover outline, and the label+ // never swallows the click (hard-won detail #7)+ shape('rect', {+ id: 'sd-hit-charts', x: 944, y: 560, w: 216, h: 52, radius: 26,+ fill: 'rgba(0,0,0,0)', link: S_CHARTS_PIE,}),],}),@@ -576,11 +582,14 @@ export function starterDoc(): BentoDoc {shape('rect', {id: T_B, x: 944, y: 560, w: 216, h: 52, radius: 26, fill: STEEL, fillGradient: GRAD_STEEL,stroke: 'rgba(255,255,255,0.18)', strokeWidth: 1,- link: S_CHARTS,}),text({x: 944, y: 574, w: 216, h: 28, html: '← Back to bars', fontSize: 17, fontWeight: 700,- color: '#FFFFFF', align: 'center', link: S_CHARTS,+ color: '#FFFFFF', align: 'center',+ }),+ shape('rect', {+ id: 'sd-hit-charts', x: 944, y: 560, w: 216, h: 52, radius: 26,+ fill: 'rgba(0,0,0,0)', link: S_CHARTS,}),],}),@@ -727,11 +736,15 @@ export function starterDoc(): BentoDoc {}),shape('rect', {id: 'sd-ch-btn', x: 964, y: 452, w: 220, h: 52, radius: 26, fill: PEACH, fillGradient: GRAD_PEACH,- shadow: { y: 10, blur: 26, color: 'rgba(0,0,0,0.4)' }, link: scene.to,+ shadow: { y: 10, blur: 26, color: 'rgba(0,0,0,0.4)' },}),text({id: 'sd-ch-btnlabel', x: 964, y: 466, w: 220, h: 28, html: scene.chip, align: 'center',- fontSize: 16, fontWeight: 700, color: INK, link: scene.to,+ fontSize: 16, fontWeight: 700, color: INK,+ }),+ shape('rect', {+ id: 'sd-ch-hit', x: 964, y: 452, w: 220, h: 52, radius: 26,+ fill: 'rgba(0,0,0,0)', link: scene.to,}),text({x: 96, y: 660, w: 800, h: 26,diff --git a/slides/src/styles.css b/slides/src/styles.cssindex e65f51e3..3c2e5c04 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -1114,3 +1114,17 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }font: inherit;font-size: 12.5px;}++/* --- responsive topbar: stays usable at any width ----------------------- */+/* narrow: button labels collapse to icons (tooltips still carry meaning) */+@media (max-width: 1280px) {+ .ed-topbar .ed-btn > span { display: none; }+ .ed-topbar .ed-btn.ed-btn-update > span { display: inline; } /* version chip is signal */+ .ed-topbar { gap: 6px; padding: 8px 8px; }+ .ed-title { min-width: 60px; }+}+/* very narrow: the bar itself scrolls sideways rather than clipping */+.ed-topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }+.ed-topbar::-webkit-scrollbar { height: 4px; }+.ed-topbar .ed-group { flex-shrink: 0; }+.ed-logo { flex-shrink: 0; }