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
tsimport { 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 element in its constructor. - Assistant
Let me check what props core passes to node view renderers:
- Assistant
Now let me look at existing tests and the changeset conventions:
- Assistant
Now let me see the top of table.ts for imports and the full View option type:
- Assistant
Now I'll implement the fix. First,
TableView.ts: - Assistant
The
TODO: fixcomment is pre-existing and unrelated. Now let me add a unit test: - Assistant
Now run the tests for this package:
- Assistant
All pass. Now lint and build:
- Assistant
Now add a changeset, following the existing format:
- Assistant
Let me run the full unit suite to be safe:
- Assistant
All 1068 unit tests pass. Here's the final diff:
- Assistant
The fix is implemented and verified. Summary of the changes:
What was changed
packages/extension-table/src/table/table.tsaddNodeView()now passesmergeAttributes(this.options.HTMLAttributes, HTMLAttributes)(configured options merged with the node's rendered attributes) as a 4th constructor argument to the —
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.