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
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
I'll start by exploring the repository structure and locating the Table extension / TableView code related to the HTMLAttributes regression.
- Assistant
Next I'll inspect the Table extension and TableView implementation to see how HTMLAttributes are handled.
- Assistant
Let me open TableView.ts and table.ts
- Assistant
I'll read the rest of TableView and check how HTMLAttributes are applied elsewhere.
- Assistant
I'll check git history and how the columnResizing View is invoked, plus any similar attribute-application patterns.
- Assistant
Let me look at how prosemirror-tables creates the View and what attributes are on the node. Also let me check if there's a way to read HTMLAttributes from options via creating a custom View factory.
- Assistant
Next I'll inspect the prosemirror-tables TableView and how other NodeViews apply HTMLAttributes.
- Assistant
The best approach seems to be: I understand the bug report and the root cause you've identified. The regression in 3.23+ stems from
TableViewbeing instantiated directly inaddNodeView()without passing throughHTMLAttributes, and the resizable path using the columnResizing plugin's contract.To fix this properly while keeping the API 100% backward-compatible, we should:
- Update
TableViewto acceptHTMLAttributesas an optional constructor parameter (4th param, sinceviewis already the 3rd). - Apply those attributes to the
<table>element in the constructor.
- Update
- Assistant
I need to inspect ExtensionManager's nodeViews construction and getRenderedAttributes.
- Assistant
So when using addNodeView through tip tap, the props include
HTMLAttributeswhich are the rendered attributes from the node, NOT the options.HTMLAttributes. Looking at renderHTML: - Assistant
Let me also check if there are attributes defined on table, perhaps style.
- Assistant
I'll look for existing helpers or PR discussions about HTMLAttributes on NodeViews.
- Assistant
Checking the commit that introduced addNodeView and ResizableNodeView's attribute handling.
- Assistant
Implementing the fix: updating TableView to accept and apply HTMLAttributes, and passing them from the Table extension.
- Assistant
Let me implement the TableView changes.
- Assistant
Next I'll update table.ts to pass HTMLAttributes into the View.
- Assistant
I'll update the View type and the addNodeView/addProseMirrorPlugins methods.
- Assistant
Now update addProseMirrorPlugins and addNodeView.
- Assistant
I need to update both addProseMirrorPlugins and addNodeView to pass HTMLAttributes.
- Assistant
Next I'll check how tests resolve packages and run the table-related tests.
- Assistant
I'll write a quick reproduction script and run the extension-table unit tests.
- Assistant
The previous command timed out; checking the environment and retrying the tests.
- Assistant
I'll call vitest directly from node_modules instead of going through pnpm.
- Assistant
Existing tests passed. Next I'll add a temporary reproduction script for the HTMLAttributes bug.
- Assistant
Reproduction tests passed. Cleaning up the temporary test and running the full table test suite.
- Assistant
All extension-table tests passed. Checking TypeScript on the changed files next.
- Assistant
I made a typo. Let me run tsc properly.
- Assistant
There's no type error related to our changes - the collaboration-caret error is pre-existing. Let me specifically typecheck just our files.
- Assistant
I'll check whether a changeset is expected.
- Assistant
Checking the versioning guidelines for whether a changeset is required.
- Assistant
I'll add a changeset documenting this bugfix.
- Assistant
Running the linter on the changed files.
- Assistant
Confirming the final state of both files, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.