Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Comment anchor feedback; panel sections placed correctly; full z-order
nyblnetf98b1c1861c2
diff --git a/CLAUDE.md b/CLAUDE.mdindex 16a67dcb..9245112c 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -74,7 +74,7 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.'bento-author'; unresolved threads badge the sidebar thumb. ONE entrypoint: the topbar 💬 tool (C) — armed click on an element anchors there,on empty canvas anchors the point; near-full-slide backdrops never- capture (a comment on scenery means the spot). `window.bento.comments()`+ capture (a comment on scenery means the spot). While armed, hover previews the pending anchor (amber outline on elements, pin+coords elsewhere); fresh markers pulse. `window.bento.comments()`returns the flat typed-anchor list — the entry point for AI agentsprocessing flagged issues in a deck.- **Hover content is in-slide, not states**: `showOnHover` sets + slidediff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.tsindex 1e8c3a0e..1ce583ff 100644--- a/slides/src/editor/canvas.ts+++ b/slides/src/editor/canvas.ts@@ -186,46 +186,83 @@ export class SlideCanvas {* that POINT of the slide. Capture phase (Selecto/Moveable never see the* click); Esc or toggling again disarms.*/+ /** Where a comment click at these client coords would anchor.+ * Near-full-slide elements (photos, scrims) don't capture — a comment+ * "here" on scenery means the spot, not the backdrop object. */+ private commentAnchorAt(clientX: number, clientY: number): { x: number; y: number; el?: SlideElement } | null {+ const r = this.scaleHost.getBoundingClientRect()+ const x = Math.round((clientX - r.left) / this.scale)+ const y = Math.round((clientY - r.top) / this.scale)+ const { width, height } = this.store.doc.size+ if (x < 0 || y < 0 || x > width || y > height) return null+ let hit: SlideElement | undefined+ const slideArea = width * height+ for (const el of this.store.slide.elements) {+ if (x < el.x || x > el.x + el.w || y < el.y || y > el.y + el.h) continue+ if (el.w * el.h >= slideArea * 0.8) continue+ const node = this.scaleHost.querySelector<HTMLElement>(`[data-el-id="${CSS.escape(el.id)}"]`)+ if (node && node.style.display !== 'none') hit = el+ }+ return { x, y, el: hit }+ }+toggleCommentMode() {if (this.commentCleanup) {this.commentCleanup()return}this.stage.style.cursor = 'crosshair'+ // live feedback: an amber outline over the element the comment would+ // anchor to, or a pin-dot + coordinates where the point would land+ const hl = document.createElement('div')+ hl.className = 'ed-comment-hl'+ this.stage.appendChild(hl)const cleanup = () => {this.commentCleanup = nullthis.stage.style.cursor = ''+ hl.remove()document.removeEventListener('mousedown', onDown, true)+ document.removeEventListener('mousemove', onMove, true)document.removeEventListener('keydown', onKey, true)this.onCommentModeChange?.(false)}+ const onMove = (ev: MouseEvent) => {+ const a = this.commentAnchorAt(ev.clientX, ev.clientY)+ if (!a) {+ hl.style.display = 'none'+ return+ }+ hl.style.display = ''+ if (a.el) {+ hl.className = 'ed-comment-hl element'+ hl.style.left = `${a.el.x * this.scale - 3}px`+ hl.style.top = `${a.el.y * this.scale - 3}px`+ hl.style.width = `${a.el.w * this.scale + 6}px`+ hl.style.height = `${a.el.h * this.scale + 6}px`+ hl.textContent = ''+ } else {+ hl.className = 'ed-comment-hl pin'+ hl.style.left = `${a.x * this.scale}px`+ hl.style.top = `${a.y * this.scale}px`+ hl.style.width = ''+ hl.style.height = ''+ hl.textContent = `${a.x}, ${a.y}`+ }+ }const onDown = (ev: MouseEvent) => {+ const a = this.commentAnchorAt(ev.clientX, ev.clientY)cleanup()- const r = this.scaleHost.getBoundingClientRect()- const x = Math.round((ev.clientX - r.left) / this.scale)- const y = Math.round((ev.clientY - r.top) / this.scale)- const { width, height } = this.store.doc.size- if (x < 0 || y < 0 || x > width || y > height) return // outside the slide+ if (!a) return // outside the slideev.preventDefault()ev.stopPropagation()- // topmost element under the point wins; empty canvas → point anchor.- // Near-full-slide elements (photos, scrims) don't capture — a comment- // "here" on scenery means the spot, not the backdrop object.- let hit: string | undefined- const slideArea = width * height- for (const el of this.store.slide.elements) {- if (x < el.x || x > el.x + el.w || y < el.y || y > el.y + el.h) continue- if (el.w * el.h >= slideArea * 0.8) continue- const node = this.scaleHost.querySelector<HTMLElement>(`[data-el-id="${CSS.escape(el.id)}"]`)- if (node && node.style.display !== 'none') hit = el.id- }- this.comments.openNew(hit, hit ? undefined : { x, y })+ this.comments.openNew(a.el?.id, a.el ? undefined : { x: a.x, y: a.y })}const onKey = (ev: KeyboardEvent) => {if (ev.key === 'Escape') cleanup()}this.commentCleanup = cleanupdocument.addEventListener('mousedown', onDown, true)+ document.addEventListener('mousemove', onMove, true)document.addEventListener('keydown', onKey, true)this.onCommentModeChange?.(true)}diff --git a/slides/src/editor/comments.ts b/slides/src/editor/comments.tsindex d13cd477..0c5b5b56 100644--- a/slides/src/editor/comments.ts+++ b/slides/src/editor/comments.ts@@ -29,6 +29,7 @@ function relTime(iso: string): string {export class CommentsUI {private layer: HTMLElement+ private justCreated: string | null = nullconstructor(private store: Store,@@ -50,6 +51,10 @@ export class CommentsUI {const el = c.elementId ? slide.elements.find((e) => e.id === c.elementId) : undefinedconst marker = document.createElement('button')marker.className = 'ed-comment-marker' + (c.resolved ? ' resolved' : '')+ if (c.id === this.justCreated) {+ marker.classList.add('fresh')+ setTimeout(() => { this.justCreated = null }, 1200)+ }marker.textContent = String(1 + (c.replies?.length ?? 0))marker.title = `${c.author}: ${c.text.slice(0, 80)}`if (el) {@@ -82,6 +87,7 @@ export class CommentsUI {const comment: Comment = {id: uid('cmt'), elementId, ...(point ?? {}), author, text, at: new Date().toISOString(),}+ this.justCreated = comment.idthis.store.commit(() => {const s = this.store.slides.comments = [...(s.comments ?? []), comment]diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.tsindex 3ec03842..55b7cc1b 100644--- a/slides/src/editor/panels.ts+++ b/slides/src/editor/panels.ts@@ -229,13 +229,18 @@ export class PropsPanel {private buildMultiPanel(els: SlideElement[]) {this.section(`${els.length} elements`)this.opsRow(els)+ this.section('Arrange')+ this.arrangeRows(els)}private buildElementPanel(el: SlideElement) {this.section({ text: 'Text', shape: 'Shape', image: 'Image', svg: 'Diagram', chart: 'Chart' }[el.type])this.opsRow([el])- // geometry+ this.section('Arrange')+ this.arrangeRows([el])++ this.section('Position & size')const geo = document.createElement('div')geo.className = 'ed-grid2'geo.append(@@ -721,12 +726,9 @@ export class PropsPanel {row.className = 'ed-ops'row.append(this.opBtn(ICONS.copy, 'Duplicate', () => this.duplicate(els)),- this.opBtn(ICONS.front, 'Bring to front', () => this.reorder(els, 'front')),- this.opBtn(ICONS.back, 'Send to back', () => this.reorder(els, 'back')),this.opBtn(ICONS.trash, 'Delete', () => this.deleteEls(els)),)this.host.appendChild(row)- this.arrangeRows(els)}/** Align / distribute / step z-order / group — the classic arrange kit. */@@ -751,10 +753,18 @@ export class PropsPanel {textBtn('⤓', 'Align bottom', () => this.align(els, 'bottom')),textBtn('⋯', 'Distribute horizontally (3+)', () => this.distribute(els, 'x'), els.length >= 3),textBtn('⋮', 'Distribute vertically (3+)', () => this.distribute(els, 'y'), els.length >= 3),+ )+ this.host.appendChild(grid)++ const order = document.createElement('div')+ order.className = 'ed-ops ed-arrange'+ order.append(+ textBtn('⤒', 'Bring to front', () => this.reorder(els, 'front')),textBtn('↑', 'Bring forward one step', () => this.step(els, +1)),textBtn('↓', 'Send backward one step', () => this.step(els, -1)),+ textBtn('⤓', 'Send to back', () => this.reorder(els, 'back')),)- this.host.appendChild(grid)+ this.host.appendChild(order)const grouped = els.some((e) => e.groupId)if (els.length > 1 || grouped) {diff --git a/slides/src/styles.css b/slides/src/styles.cssindex 78d53b2f..138a4723 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -522,6 +522,40 @@ html, body {.ed-section-body { display: flex; flex-direction: column; }/* review comments: canvas markers, thread popover, thumb badge */+.ed-comment-hl {+ position: absolute;+ pointer-events: none;+ z-index: 11;+}+.ed-comment-hl.element {+ border: 2px dashed var(--accent);+ border-radius: 6px;+ background: color-mix(in srgb, var(--accent) 8%, transparent);+}+.ed-comment-hl.pin {+ width: 0; height: 0;+ font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;+ color: var(--accent-ink);+ white-space: nowrap;+ padding-left: 12px;+ padding-top: 2px;+}+.ed-comment-hl.pin::before {+ content: '';+ position: absolute;+ left: -5px; top: -5px;+ width: 10px; height: 10px;+ border-radius: 50%;+ border: 2.5px solid var(--accent);+ background: rgb(255 255 255 / 0.7);+}+@keyframes ed-cmt-pop {+ 0% { transform: scale(0.3); }+ 55% { transform: scale(1.35); }+ 100% { transform: scale(1); }+}+.ed-comment-marker.fresh { animation: ed-cmt-pop 0.45s ease-out; }+.ed-comment-layer { position: absolute; inset: 0; pointer-events: none; z-index: 12; }.ed-comment-marker {position: absolute;