Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

v0.8.9: marquee from the grey surround, Alt center-resize, panel overflow

nyblnet5d028c665ed1
diff --git a/CLAUDE.md b/CLAUDE.md
index 7ef9f8ba..3ab6f353 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -181,9 +181,16 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.
edits 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 +
+ rotate snap; Alt/Option = resize from CENTER (deep-select exempts
+ Moveable's control box, so Alt-on-a-handle means center-scale);
+ ⌘/Ctrl-drag = duplicate (originals move, copies stay — one undo step;
+ Alt on element bodies stays deep-select). Selecto's container/
+ dragContainer is the SCROLLER (not the stage) — marquees must be able
+ to start on the grey surround, the natural gesture; floating controls
+ (FABs/zoombar/chevrons) are exempted in the selecto dragStart guard.
+ Pane testing: synthetic drags on Moveable HANDLES don't register at
+ all (verified against pre-change code too) — resize behavior needs a
+ real mouse. 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 by HIDING TEXT, never scrolling: labels
collapse to icons <1200px, the wordmark collapses to the mark <760px.
diff --git a/slides/package.json b/slides/package.json
index ff36ff97..c8ce7b61 100644
--- a/slides/package.json
+++ b/slides/package.json
@@ -1,7 +1,7 @@
{
"name": "bento-slides",
"private": true,
- "version": "0.8.8",
+ "version": "0.8.9",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.ts
index 2411fdb5..f99e5c28 100644
--- a/slides/src/editor/canvas.ts
+++ b/slides/src/editor/canvas.ts
@@ -70,8 +70,8 @@ export class SlideCanvas {
})
this.selecto = new Selecto({
- container: this.stage,
- dragContainer: this.stage,
+ container: this.scroller,
+ dragContainer: this.scroller,
selectableTargets: ['.bento-el'],
selectByClick: true,
selectFromInside: false,
@@ -98,6 +98,8 @@ export class SlideCanvas {
// which otherwise swallows clicks over the current selection.
document.addEventListener('mousedown', (ev) => {
if (!ev.altKey || ev.button !== 0 || this.pathEditor.active) return
+ // Alt on a resize/rotate handle means center-scale, not deep-select
+ if (ev.target instanceof Element && ev.target.closest('.moveable-control-box')) return
const r = this.scaleHost.getBoundingClientRect()
if (ev.clientX < r.left || ev.clientX > r.right || ev.clientY < r.top || ev.clientY > r.bottom) return
if (ev.target instanceof Element && ev.target.closest('.ed-sidebar, .ed-props, .ed-topbar')) return
@@ -546,20 +548,49 @@ export class SlideCanvas {
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 })
+ // Shift while resizing keeps the aspect ratio; Alt/Option scales from
+ // the center (both live per move, combinable)
+ const resizeCenters = new Map<HTMLElement, { cx: number; cy: number }>()
+ const noteResizeStart = (target: HTMLElement) => {
+ resizeCenters.set(target, {
+ cx: (parseFloat(target.style.left) || 0) + (parseFloat(target.style.width) || 0) / 2,
+ cy: (parseFloat(target.style.top) || 0) + (parseFloat(target.style.height) || 0) / 2,
+ })
+ }
+ const applyResize = (
+ target: HTMLElement,
+ w: number,
+ h: number,
+ left: number,
+ top: number,
+ inputEvent: MouseEvent | undefined,
+ ) => {
+ target.style.width = `${w}px`
+ target.style.height = `${h}px`
+ const c = resizeCenters.get(target)
+ if (inputEvent?.altKey && c) {
+ target.style.left = `${c.cx - w / 2}px`
+ target.style.top = `${c.cy - h / 2}px`
+ } else {
+ target.style.left = `${left}px`
+ target.style.top = `${top}px`
+ }
+ }
+ const syncKeepRatio = (inputEvent: MouseEvent | undefined) => {
+ const want = !!inputEvent?.shiftKey
+ if (mv.keepRatio !== want) mv.keepRatio = want
+ }
+ mv.on('resizeStart', (e) => {
+ syncKeepRatio(e.inputEvent as MouseEvent)
+ noteResizeStart(e.target as HTMLElement)
+ })
mv.on('resize', (e) => {
- mv.keepRatio = !!(e.inputEvent as MouseEvent | undefined)?.shiftKey
- e.target.style.width = `${e.width}px`
- e.target.style.height = `${e.height}px`
- e.target.style.left = `${e.drag.left}px`
- e.target.style.top = `${e.drag.top}px`
+ syncKeepRatio(e.inputEvent as MouseEvent)
+ applyResize(e.target as HTMLElement, e.width, e.height, e.drag.left, e.drag.top, e.inputEvent as MouseEvent)
})
+ mv.on('resizeGroupStart', (e) => e.events.forEach((ev) => noteResizeStart(ev.target as HTMLElement)))
mv.on('resizeGroup', (e) => e.events.forEach((ev) => {
- ev.target.style.width = `${ev.width}px`
- ev.target.style.height = `${ev.height}px`
- ev.target.style.left = `${ev.drag.left}px`
- ev.target.style.top = `${ev.drag.top}px`
+ applyResize(ev.target as HTMLElement, ev.width, ev.height, ev.drag.left, ev.drag.top, e.inputEvent as MouseEvent)
}))
// Shift while rotating snaps to 15° steps
mv.on('rotateStart', (e) => { mv.throttleRotate = (e.inputEvent as MouseEvent | undefined)?.shiftKey ? 15 : 1 })
@@ -648,6 +679,11 @@ export class SlideCanvas {
private wireSelecto() {
this.selecto.on('dragStart', (e) => {
const target = e.inputEvent.target as HTMLElement
+ // floating controls over the canvas are not marquee territory
+ if (target.closest('.ed-present-fabs, .ed-zoombar, .ed-panel-toggle, .ed-resizer')) {
+ e.stop()
+ return
+ }
if (this.pathEditor?.active) {
e.stop() // the path overlay owns the pointer while editing
return
diff --git a/slides/src/styles.css b/slides/src/styles.css
index b312aed5..4f534604 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -592,7 +592,13 @@ html, body {
}
/* arrange kit: one compact row per group — tiny label left, buttons right */
-.ed-arrange-row { display: flex; align-items: center; gap: 3px; margin: 3px 0; }
+.ed-arrange-row {
+ display: flex;
+ align-items: center;
+ gap: 3px;
+ margin: 3px 0;
+ flex-wrap: wrap; /* narrow panel: buttons flow to a second line, never overflow */
+}
.ed-arrange-cap {
flex: none;
width: 46px;
@@ -1252,3 +1258,13 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }
box-shadow: 0 3px 10px rgb(20 30 45 / 0.14);
}
.ed-fab-small svg { width: 15px; height: 15px; }
+
+/* right panel: no horizontal scrollbar, ever */
+.ed-props {
+ overflow-x: hidden;
+ scrollbar-gutter: stable;
+}
+.ed-props .ed-row { flex-wrap: wrap; }
+.ed-props input[type='number'] { min-width: 0; }
+.ed-props select { max-width: 100%; min-width: 0; }
+.ed-props input[type='text'] { min-width: 0; max-width: 100%; }