fix(extension-table): omit default colspan and rowspan when rendering cells - #8183
fix(extension-table): omit default colspan and rowspan when rendering cells#8183rawsun007 wants to merge 2 commits into
Conversation
… cells Both attributes default to 1 in the schema and were rendered unconditionally, so every cell serialized as <td colspan="1" rowspan="1">. That is redundant markup, and it rewrites table HTML on a parse and serialize round trip. Render them only when the value differs from 1, which is what prosemirror-tables does. Fixes ueberdosis#8176 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c79b1fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary
WalkthroughTable cell and header serialization now omits default ChangesTable span serialization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/omit-default-table-cell-spans.md:
- Line 5: Rewrite the changeset body as one short, accurate sentence describing
that table cells and headers omit default colspan="1" and rowspan="1" attributes
when serialized. Remove the incorrect claim that existing markup remains
unchanged, and preserve the required changeset frontmatter.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 566764a5-90e2-4a24-978a-8274604e9a7f
📒 Files selected for processing (6)
.changeset/omit-default-table-cell-spans.mdpackages/extension-table/__tests__/tableCell.spec.tspackages/extension-table/__tests__/tableCommands.spec.tspackages/extension-table/src/cell/table-cell.tspackages/extension-table/src/header/table-header.tspackages/extension-table/src/utils/renderSpanAttribute.ts
The old text claimed a parse and serialize round trip leaves markup unchanged, which is not true for input that spells out colspan="1". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fixes #8176
colspanandrowspandefault to1inTableCellandTableHeader, and both were rendered unconditionally, so every cell came out as:Besides the extra markup, it means parsing existing table HTML and serializing it back changes the document. (Input that spells out
colspan="1"now loses the attribute instead of keeping it, which is the same cell either way.)Added a small
renderSpanAttributehelper that returns{}when the value is1(or missing) and used it for both attributes onTableCellandTableHeader. Cells that actually span still render the attribute. This matches how prosemirror-tables serializes them.Only the rendering changes, the schema defaults and parsing are untouched.
Verification
New tests in
tableCell.spec.tscover both directions, plain cells and spanning cells:Reverting just
packages/extension-table/srcturns them red, along with the two existing markup assertions this fix updates:The two
tableCommands.spec.tsexpectations were pinned to the oldcolspan="1" rowspan="1"output and are updated here.Full unit suite:
176 files, 1819 passed.oxlintandoxfmt --checkclean onpackages/extension-table.Changeset included (patch).