ISSUE DESCRIPTION [Bug]: extension-table 3.23 TableView NodeView ignores HTMLAttributes…
- User
ISSUE DESCRIPTION
[Bug]: extension-table 3.23 TableView NodeView ignores HTMLAttributes (regression from 3.22.4)
Affected Packages
@tiptap/extension-table
Version(s)
3.23.1 (also 3.23.2, 3.23.4)
Bug Description
Summary
In
@tiptap/extension-table3.23.x, configuring the Table extension withHTMLAttributesno longer applies those attributes to the rendered<table>element whenresizable: false(the default). The class/attributes silently disappear from the DOM.This is a regression from 3.22.4, where the same configuration worked correctly.
TableViewexisted byte-identical in 3.22.4, but the Table extension had noaddNodeView()method, so ProseMirror always fell back to the schema'srenderHTML. 3.23 addedaddNodeView()that wires the NodeView in, bypassingrenderHTML.Reproduction
import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Table, TableRow, TableHeader, TableCell } from '@tiptap/extension-table'; new Editor({ extensions: [ StarterKit, Table.configure({ HTMLAttributes: { class: 'my-custom-table' } }), TableRow, TableHeader, TableCell ], content: '<table><tbody><tr><td>cell</td></tr></tbody></table>' });Inspect the rendered DOM. The
<table>element has noclass="my-custom-table".Browser Used
Chrome
Code Example URL
https://codesandbox.io/p/devbox/laughing-glade-n4qh4r
Expected Behavior
The
<table>element should render withclass="my-custom-table"(the documented Table.configure HTMLAttributes behavior), regardless of theresizablesetting.A minimal fix would have
TableViewapplythis.options.HTMLAttributesto the inner<table>element in its constructor.Additional Context (Optional)
Root cause
3.23 introduced
addNodeView()on the Table extension (extension-tabledist/index.jsaround line 645):addNodeView() { const isResizable = this.options.resizable && this.editor.isEditable; const View = this.options.View; if (isResizable || !View) { return null; } return ({ node, view }) => new View(node, this.options.cellMinWidth, view); } Assistant
Now let's replace the constructor:
Assistant
No hidden chars, plain text. Let's use
editcommand with line range instead.Assistant
Now update table.ts type signature and addNodeView call site.
Assistant
Need to import
EditorViewtype now.Assistant
Now update
table.ts: the View type signature and theaddNodeView()call site to pass HTMLAttributes as 4th argument.Assistant
Now update the
addNodeViewcall site:Assistant
Now let's run the existing tests for extension-table using vitest.
Assistant
All existing tests pass. Now let's write a reproduction script to confirm fix.
Assistant
Test passes. Let's verify it actually fails on the old code (sanity check by reverting temporarily) to confirm this test catches the regression.
Assistant
Confirmed the bug reproduces on the old code and is fixed by our change. Now remove the temporary test file (per instructions not to add tests to repo) and run full test suite again.
Assistant
Now let's typecheck the package to make sure TS types are consistent.
Assistant
Builds successfully with types. Let's clean up build artifacts (dist) since we shouldn't leave build output as changes unless already tracked.
Assistant
dist is gitignored, good — no extra changes to clean. Let's view the full diff for review.
Assistant
Good, no crash for resizable mode. Clean up temp test file.
Assistant
Now let's run the full extension-table test suite once more plus any broader tests that reference Table (e.g., extension-table-of-contents, starter-kit) to be safe.
Assistant
All pass. Let's also run full lint on the changed files to catch style issues.
Assistant
Lint passes. Now let's check the long line in table.ts (line 88) doesn't exceed formatting conventions (prettier). Let's run prettier check.
Assistant
Line 88 exceeds 120 chars. Let's format with oxfmt.
Assistant
Formatting fixed nicely. Let's re-run tests and lint to confirm everything still works.
Assistant
Everything passes: tests, lint, and formatting. Let's do a final review of the diff.
Assistant
This looks complete and correct. Let me now write out the checklist assessment.
Checklist review:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.