Slides text box: insert-to-edit, drag sizing, content-fit auto-grow#298
Conversation
Three coordinated improvements to the slides text-box authoring flow to match Google Slides: insert drops the caret straight into edit mode, text boxes can be drawn by dragging (width + position), and box height fits its content live (grow + shrink, min one line). Auto-grow needs a new onContentHeightChange callback + setContentHeight() seam in the docs text-box engine, which currently computes layout.totalHeight only for internal use. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Plan covers four TDD tasks: docs content-height callback + setter, slides wrapper live resize, text drag sizing, and editor insert-to-edit with commit-time height fit. Refines the design doc to persist frame height at commit (one undo batch) rather than per-keystroke. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
computeLayout already produces layout.totalHeight but only used it internally. Expose it via an onContentHeightChange option (fired from renderNow, de-duped on change) and a setContentHeight() setter so a host can grow/shrink the editing surface to fit content. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The wrapper forwards docs onContentHeightChange: it resizes its container + canvas to the new logical height (times slide scale and browser dpr), delegates setContentHeight so the docs editor's pointer math stays consistent, then reports the height to the host. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Text insert now uses the same click-vs-drag rect logic as shapes: a drag sets width + top-left, a sub-threshold drag keeps TEXT_DEFAULT_W. Height stays TEXT_DEFAULT_H at insert; the editor fits it to content on the first layout, so the drawn height is intentionally not retained. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Inserting a text box now drag-sizes and drops the caret straight inside (enterEditMode on pointerup) instead of leaving an empty selected box. The latest content height reported during editing is written into frame.h at commit, in the same batch as the text — one undo entry, content-fit height matching Google Slides. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code-review follow-ups: a near-vertical text drag cleared the click threshold but yielded a sliver-width box that auto-grew into a 1-char column — clamp drag width to MIN_TEXT_BOX_W. Also document why the wrapper's onContentHeightChange may reference api before assignment (it only fires via rAF, after the const binds). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements Google Slides–like text-box auto-grow behavior by extending the docs text engine with height-change callbacks and a height-setter API, wiring those callbacks through the slides wrapper to resize containers and canvases, updating the text insertion flow to use click-vs-drag sizing, and integrating height tracking and commit-time persistence in the slides editor. ChangesSlides Text Box Auto-Grow Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Verification: verify:selfResult: ✅ PASS in 219.2s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
buildInsertElement JSDoc and the hoverPreview / onInsertHoverMove notes still described text as a single-click fixed-size insert; update them to the drag-to-size + content-fit-height behavior this branch introduced. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Brings the Slides text-box authoring flow in line with Google Slides:
Mechanism
@wafflebase/docstext engine: newonContentHeightChangeoption (fired fromrenderNowafter layout, de-duped) +setContentHeight()setter.computeLayoutalready producedlayout.totalHeight; it was only used internally.setContentHeight, and reports the logical height to the editor.frame.hat commit.Design:
docs/design/slides/slides-textbox-autogrow.md· Plan:docs/tasks/active/20260525-slides-textbox-autogrow-todo.mdNon-goals
Width autofit, a per-element autofit-mode selector, and auto-grow for text inside non-text shapes.
Test Plan
pnpm verify:fast(lint + unit) — greenpnpm verify:self(+ all builds + entropy/knip/doc-staleness) — greentest-canvas-env; insert-to-edit + one-undo height-fit testspnpm dev: insert via click and via drag → caret inside, one-line tall; type to grow, delete to shrink; reopen → height preserved; shapes still select-only; double-click still editsKnown limitations
enterEditModeresolves the element top-level, so auto-grow applies to top-level text boxes; text inside groups is out of scope (pre-existing).🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests