Untitled conversation
- User
[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 me check what props tiptap core passes to
addNodeViewrenderers: - Assistant
Now let me check where
TableViewis instantiated/referenced across the repo: - Assistant
Now I'll implement the fix. First,
TableView.ts: - Assistant
Now let me verify the build type-checks (including the
columnResizing({ View })assignment): - Assistant
Build passes. Now a unit test for the regression:
- Assistant
All 4 pass. Now run the full extension-table test suite and lint:
- Assistant
Lint passes on the changed package. The full-repo
pnpm lintcrash looks like a Node crash unrelated to my change — let me confirm: - Assistant
The full-repo format check crashes due to environment thread limits (EAGAIN spawning workers), not my change. Let me check the script and run it scoped:
- Assistant
Format and lint pass. Now add a changeset — let me check the conventions:
- Assistant
Let me view the final diff and run the full unit test suite:
- Assistant
All checks pass. The fix is complete — here's a summary:
Changes
packages/extension-table/src/table/TableView.tsTableView's constructor now accepts two additional optional parameters:_view?: EditorView(to match theViewoption's call signature) and . When provided, the attributes are applied to the inner element via , mirroring what the schema's does. The existing handling is unchanged and keeps its precedence.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.