Unify cell paragraph layout with body layoutBlock#167
Conversation
Captures the duplicated layoutCellInlines / layoutBlock split that causes Increase Indent to silently no-op on paragraphs inside table cells. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Prepare for cell paragraph layout unification by sharing the body layout primitives. No behavior change on body paragraphs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pin the indent-in-cell bug and three related missing behaviors (marginLeft, textIndent, lineHeight, heading defaults) before unifying cell and body paragraph layout in the next commit. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
layoutCellBlocks now reuses layoutBlock + assignLineHeights, so cells honor block.style.marginLeft, textIndent, lineHeight, and heading/ title/subtitle defaults — same semantics as body paragraphs. Fixes Increase Indent having no effect on paragraphs inside table cells. The previous duplicated layoutCellInlines + splitWords are removed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Records the design note in docs-tables.md, captures the duplicated- layout lesson, and archives the task per the project workflow. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The cell branch of resolvePositionPixel left cursorX at 0 when the target line had no runs (empty list-item or empty paragraph with marginLeft). The caret then rendered at the cell content origin instead of after the bullet/number marker, mismatching the body-side behavior. Mirror layout.ts's body fallback: when the resolved cell line has no runs, place the caret at the block's effective marginLeft (plus list indent for list-items). For an empty bullet at level 0 this puts the caret immediately to the right of the marker, where typed text would appear once the user starts typing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR consolidates table cell paragraph layout with the shared body paragraph layout pipeline by exporting Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 121.2s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Two issues surfaced in DOCX-imported documents after #167 unified the cell paragraph layout with the body's layoutBlock. 1. Cells with stored `lineHeight: 0.7` (planted by docx-style-map's unconditional `line / 240` mapping for `<w:spacing w:line=...>` regardless of `lineRule`) collapsed every line below the font's own pixel height once cells started honoring the value, so characters from adjacent lines overlapped. Floor the multiplier at 1.0 inside `assignLineHeights` so a sub-1.0 value can never crash text into the line below. The DOCX `lineRule` mishandling is the underlying data bug; that import fix is left as a follow-up. 2. The cell text baseline used `runLineY + line.height * 0.75`, which places the glyph's ascent ~5% of the font size above the line's declared top whenever lineHeight is tight (≈ 1.0). At a paginated row split this leaked a sliver of the next page's first line into the previous page's clip region — the same line then rendered fully on the next page, producing a visible double-draw at the boundary. Switch to the centered formula already used by the body path in doc-canvas and the list-marker path in the same file: `(line.height + fontSize * 0.8) / 2`. The glyph ascent now sits inside the line box for any lineHeight ≥ 1.0, so the page-split clip cleanly excludes it. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
applyBlockStyle({ marginLeft })updated the model, butlayoutCellInlinesignoredblock.style.marginLeft. Bullets worked because list indent took a separatelistLevelpath.layoutCellInlines(175 lines of word-wrap + line-height + image handling) with a call to the body-sidelayoutBlock+ newassignLineHeightshelper. Cells now honormarginLeft,textIndent,lineHeight, and heading/title/subtitle defaults the same way body paragraphs do.table-layout.tsplus a 4-test regression suite covering each newly honored style.resolvePositionPixelwas missing the empty-line fallback that the body branch already had, leaving the caret at cell origin (x=0) instead of after the bullet/number marker.Test plan
pnpm verify:fast— 36 docs test files / 629 tests passmarginLeftvalues that were silently ignored by the old cell layout will now visibly indent. Outdent (Shift+Tab) cleans them up.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests