Skip to content

fix(extension-table): stop rendering default colspan and rowspan on cells - #8177

Open
lazerg wants to merge 2 commits into
ueberdosis:mainfrom
lazerg:fix/8176-table-default-spans
Open

fix(extension-table): stop rendering default colspan and rowspan on cells#8177
lazerg wants to merge 2 commits into
ueberdosis:mainfrom
lazerg:fix/8176-table-default-spans

Conversation

@lazerg

@lazerg lazerg commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes

Fixes #8176

Changes and Review

Every <td> and <th> came out with colspan="1" rowspan="1", because both attributes default to 1 in the schema and that default was rendered like any other value. Parsing existing table HTML and serializing it again therefore changed the markup. Both attributes now render only when they are greater than 1, which is what prosemirror-tables does.

To verify: load a table with plain cells into the editor and call getHTML(). Cells come back as <td><p>Cell</p></td>, and cells that really span still carry colspan/rowspan.

Checklist

  • I have added a changeset if necessary.
  • I have added tests if possible.
  • I have made sure to test my changes myself.

Responsibility

  • I have reviewed and understand these changes, and I take responsibility for this PR, even if an AI agent created it.

@lazerg
lazerg requested a review from a team as a code owner August 11, 2026 00:22
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 9afc1b4
🔍 Latest deploy log https://app.netlify.com/projects/tiptap-embed/deploys/6a7a6dc119fe45000857bbde
😎 Deploy Preview https://deploy-preview-8177--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9afc1b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 74 packages
Name Type
@tiptap/extension-table Patch
@tiptap/extension-table-cell Patch
@tiptap/extension-table-header Patch
@tiptap/extension-table-row Patch
@tiptap/core Patch
@tiptap/extension-audio Patch
@tiptap/extension-blockquote Patch
@tiptap/extension-bold Patch
@tiptap/extension-bubble-menu Patch
@tiptap/extension-bullet-list Patch
@tiptap/extension-code-block-lowlight Patch
@tiptap/extension-code-block Patch
@tiptap/extension-code Patch
@tiptap/extension-collaboration-caret Patch
@tiptap/extension-collaboration Patch
@tiptap/extension-color Patch
@tiptap/extension-details Patch
@tiptap/extension-document Patch
@tiptap/extension-drag-handle-react Patch
@tiptap/extension-drag-handle-vue-2 Patch
@tiptap/extension-drag-handle-vue-3 Patch
@tiptap/extension-drag-handle Patch
@tiptap/extension-emoji Patch
@tiptap/extension-file-handler Patch
@tiptap/extension-find-and-replace Patch
@tiptap/extension-floating-menu Patch
@tiptap/extension-font-family Patch
@tiptap/extension-hard-break Patch
@tiptap/extension-heading Patch
@tiptap/extension-highlight Patch
@tiptap/extension-horizontal-rule Patch
@tiptap/extension-image Patch
@tiptap/extension-invisible-characters Patch
@tiptap/extension-italic Patch
@tiptap/extension-link Patch
@tiptap/extension-list Patch
@tiptap/extension-mathematics Patch
@tiptap/extension-mention Patch
@tiptap/extension-node-range Patch
@tiptap/extension-ordered-list Patch
@tiptap/extension-paragraph Patch
@tiptap/extension-ruby-text Patch
@tiptap/extension-strike Patch
@tiptap/extension-subscript Patch
@tiptap/extension-superscript Patch
@tiptap/extension-table-of-contents Patch
@tiptap/extension-text-align Patch
@tiptap/extension-text-style Patch
@tiptap/extension-text Patch
@tiptap/extension-twitch Patch
@tiptap/extension-typography Patch
@tiptap/extension-underline Patch
@tiptap/extension-unique-id Patch
@tiptap/extension-youtube Patch
@tiptap/extensions Patch
@tiptap/html Patch
@tiptap/markdown Patch
@tiptap/pm Patch
@tiptap/react Patch
@tiptap/starter-kit Patch
@tiptap/static-renderer Patch
@tiptap/suggestion Patch
@tiptap/vue-2 Patch
@tiptap/vue-3 Patch
@tiptap/extension-character-count Patch
@tiptap/extension-dropcursor Patch
@tiptap/extension-focus Patch
@tiptap/extension-gapcursor Patch
@tiptap/extension-history Patch
@tiptap/extension-list-item Patch
@tiptap/extension-list-keymap Patch
@tiptap/extension-placeholder Patch
@tiptap/extension-task-item Patch
@tiptap/extension-task-list Patch

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

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 435b3921-4d4c-4f37-b8a3-701b2cdfb776

📥 Commits

Reviewing files that changed from the base of the PR and between 9813dee and 9afc1b4.

📒 Files selected for processing (3)
  • .changeset/2026-08-11-table-default-spans.md
  • packages/extension-table/__tests__/tableCell.spec.ts
  • packages/extension-table/__tests__/tableHeader.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/extension-table/tests/tableCell.spec.ts
  • .changeset/2026-08-11-table-default-spans.md
  • packages/extension-table/tests/tableHeader.spec.ts

📝 Walkthrough

Summary

  • Omit colspan="1" and rowspan="1" from table cells and headers.
  • Keep these attributes when their values are greater than 1.
  • Update tests and add a changeset for the new HTML output.

Walkthrough

Table cell and header HTML rendering now omits colspan and rowspan when their values are 1. Non-default values remain serialized. Tests and a patch changeset document the updated output.

Changes

Table span serialization

Layer / File(s) Summary
Conditional span rendering and validation
packages/extension-table/src/cell/table-cell.ts, packages/extension-table/src/header/table-header.ts, packages/extension-table/__tests__/*, .changeset/2026-08-11-table-default-spans.md
Table cells and headers omit default span attributes. Non-default spans remain serialized. Tests verify both cases, and the changeset records the update.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: area: core, complexity: easy, impact: medium

Suggested reviewers: bdbch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: default table-cell span attributes are no longer rendered.
Description check ✅ Passed The description includes the linked issue, change summary, verification steps, completed checklist, and responsibility acknowledgment.
Linked Issues check ✅ Passed The changes satisfy issue #8176 for both TableCell and TableHeader, including tests and a changeset.
Out of Scope Changes check ✅ Passed All source, test, and changeset changes directly support the linked issue and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added area: core Core editor engine and ProseMirror integration complexity: medium Moderate change, possibly multiple files impact: medium Affects some users or workflows labels Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.changeset/2026-08-11-table-default-spans.md (1)

5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the changeset to one short user-facing sentence.

Line 5 uses two sentences and includes the internal prosemirror-tables comparison. Replace it with a concise description of the serialized HTML change.

Suggested wording
-Table cells and headers no longer render `colspan="1"` and `rowspan="1"`. Both attributes are only written to the HTML when a cell actually spans more than one column or row, which matches how prosemirror-tables serializes them.
+Table cells and headers omit default `colspan` and `rowspan` attributes from serialized HTML.

As per coding guidelines, .changeset/*.md: Changesets should contain one short sentence describing user-visible behavior without internals or root-cause details.

🤖 Prompt for 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.

In @.changeset/2026-08-11-table-default-spans.md at line 5, Rewrite the
changeset entry as one short user-facing sentence describing that table cells
and headers only serialize colspan and rowspan when their values exceed one;
remove the second sentence and the internal prosemirror-tables reference.

Source: Coding guidelines

packages/extension-table/__tests__/tableCell.spec.ts (1)

140-144: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Complete coverage for both cell types and both span dimensions.

The tests do not fully prove the serialization contract. Add explicit absence checks for default spans and cover non-default rowspan on TableHeader.

  • packages/extension-table/__tests__/tableCell.spec.ts#L140-L144: assert that the serialized HTML does not contain colspan="1" or rowspan="1".
  • packages/extension-table/__tests__/tableHeader.spec.ts#L101-L114: add a valid header fixture with rowspan="2" and assert that it is retained; also assert that default span attributes are absent.

As per coding guidelines, **/*.{ts,tsx}: Add or update unit tests for deterministic user-visible behavior.

🤖 Prompt for 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.

In `@packages/extension-table/__tests__/tableCell.spec.ts` around lines 140 - 144,
Update the serialization assertions in
packages/extension-table/__tests__/tableCell.spec.ts lines 140-144 to verify
colspan="1" and rowspan="1" are absent. In
packages/extension-table/__tests__/tableHeader.spec.ts lines 101-114, add a
valid TableHeader fixture with rowspan="2" and assert it is preserved, while
also asserting default colspan="1" and rowspan="1" attributes are absent.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In @.changeset/2026-08-11-table-default-spans.md:
- Line 5: Rewrite the changeset entry as one short user-facing sentence
describing that table cells and headers only serialize colspan and rowspan when
their values exceed one; remove the second sentence and the internal
prosemirror-tables reference.

In `@packages/extension-table/__tests__/tableCell.spec.ts`:
- Around line 140-144: Update the serialization assertions in
packages/extension-table/__tests__/tableCell.spec.ts lines 140-144 to verify
colspan="1" and rowspan="1" are absent. In
packages/extension-table/__tests__/tableHeader.spec.ts lines 101-114, add a
valid TableHeader fixture with rowspan="2" and assert it is preserved, while
also asserting default colspan="1" and rowspan="1" attributes are absent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 7921546f-7ea4-4dc8-b8a0-fe7f7a1dce2a

📥 Commits

Reviewing files that changed from the base of the PR and between eded5e4 and 9813dee.

📒 Files selected for processing (6)
  • .changeset/2026-08-11-table-default-spans.md
  • packages/extension-table/__tests__/tableCell.spec.ts
  • packages/extension-table/__tests__/tableCommands.spec.ts
  • packages/extension-table/__tests__/tableHeader.spec.ts
  • packages/extension-table/src/cell/table-cell.ts
  • packages/extension-table/src/header/table-header.ts

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 11, 2026
@coderabbitai coderabbitai Bot added complexity: easy Small effort, well-defined scope and removed complexity: medium Moderate change, possibly multiple files labels Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core editor engine and ProseMirror integration complexity: easy Small effort, well-defined scope impact: medium Affects some users or workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TableCell and TableHeader serialize default colspan="1" and rowspan="1" attributes

1 participant