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
Good. Now let's implement the fix in TableView.ts and update the call sites in table.ts.
Assistant
Now let's update the TableView.ts file to accept HTMLAttributes and view params:
Assistant
I'll use the
edit/replacespecial commands instead. Let's open the file first.Assistant
Now let's replace the constructor body:
Assistant
Now use
editwith explicit line range instead.Assistant
Now update the
addNodeViewcall site:Assistant
Let's find where TableOptions interface ends to insert helper function after it.
Assistant
Let me add a blank line before
declare module:Assistant
Now update
addProseMirrorPluginsto usebindHTMLAttributesToView:Assistant
There's an extra
},at line 548 (duplicate closing brace). Let's fix.Assistant
Let's add a blank line between the two methods for readability, then verify the whole file compiles.
Assistant
Now let's build/typecheck this package.
Assistant
Build succeeds without type errors. Now let's run existing tests for extension-table.
Assistant
All tests pass. Now let's create a reproduce script to verify the fix works for the reported scenario.
Assistant
This gives a good template for a reproduce script using jsdom via vitest. Let's write a temporary test file to verify the fix (not part of the repo test suite - will delete after).
Assistant
Both cases (resizable false and true) work now. Let's remove the temp test file and re-run the full test suite once more to be sure.
Assistant
Let's also verify no other test files remain and run the broader build one more time, then check git diff for final review.
Assistant
Good, temp test files are gone and only source files are modified. Let's view the final diff.
Assistant
This looks clean. Let's run the full build once more and also run a broader test pass across the repo related packages that might import extension-table (e.g., extension-table-of-contents, kit).
Assistant
All 1064 tests across the entire repository pass. Let's do a final review of the diff and clean up any leftover temp files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.