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
I’ll inspect the table extension and its tests/build conventions, then update the NodeView so it merges configured HTML attributes onto the generated table without disturbing existing style/column behavior. I’ll run the focused tests (and a broader relevant suite if practical), verify the diff, and only then submit.
- Assistant
The NodeView factory already supplies rendered node attributes, but the table extension currently discards them and only passes the editor view to the constructor. I’ll preserve the existing three-argument custom
ViewAPI and add an optional fourth attribute argument, merging extension-levelHTMLAttributeswith node-rendered attributes before constructing the view.TableViewwill apply the merged attributes directly to its<table>, preserving class/style merge semantics used byrenderHTML. - Assistant
The focused build succeeds, and the existing column-group test suite passes (9 tests). The repository-wide TypeScript check has unrelated pre-existing errors in demos/dependencies, so it cannot serve as a clean validation signal; the table package itself builds successfully with declarations. The implementation also retains direct
TableViewconstruction behavior by falling back tonode.attrs.stylewhen no rendered attributes are supplied. I’m submitting the verified changes now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.