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 first locate the table extension implementation and its tests, then trace the NodeView constructor/API so the fix preserves attribute merging and update behavior rather than only hardcoding the reported class case.
- Assistant
The source is in
packages/extension-table/src/table. Since ripgrep is unavailable, I’ll inspect the implementation, exported option types, package scripts, and nearby tests using standard tools. - Assistant
TableViewcurrently receives only the node and width, whilerenderHTMLmerges configured attributes with schema/node attributes and computed sizing styles. I’ll inspect the exactaddNodeViewcall and git history/status to determine the intended compatibility constraints, especially for customViewconstructors. - Assistant
The NodeView was added specifically for non-resizable column synchronization and retains the conventional first three constructor arguments for custom views. The clean compatibility-preserving approach is to add an optional fourth
HTMLAttributesargument, pass it from the extension, and have the built-in view apply it. Before editing, I’ll inspect prior commits and attribute utility behavior to account for class/style/boolean attributes and updates. - Assistant
There is established NodeView attribute synchronization code in the task-item extension. I’ll compare that implementation and core merge semantics, then model the table behavior consistently, including removing stale attributes if configured values change or node attributes update.
- Assistant
The callback’s
HTMLAttributesrepresents rendered node attributes, while static extension options are applied separately in existing NodeViews. For tables,renderHTMLmerges both sources. I’ll confirm the callback construction and then implement the same merged attribute set for the built-inTableView, while keeping custom three-argument views source-compatible. - Assistant
I’ll inspect the core renderer details and type signatures now. This will establish whether passing a fourth argument requires widening only the table option type and whether configured attributes need explicit merging before construction.
- Assistant
The renderer confirms static
Table.options.HTMLAttributesare not included in callback attributes, so both sets must be merged explicitly. I’ll reproduce the constructor-level failure with a temporary jsdom script against the current source behavior, then patch the view to accept merged attributes as an optional fourth parameter. The thirdEditorViewparameter remains unchanged for custom-view compatibility. - Assistant
The repository root does not expose jsdom, so that ad-hoc reproduction could not run. I’ll use the project’s installed browser-DOM implementation if available; otherwise the source trace itself conclusively shows that no configured attributes are read. Then I’ll apply the focused patch.
- Assistant
happy-domis declared but its root symlink is absent in this partial install. Rather than altering dependencies, I’ll proceed with the source-level reproduction (the constructor demonstrably only readsnode.attrs.style) and make the compatibility-safe changes in the two source files. - Assistant
Python is also unavailable in this environment, so I’ll use the repository’s provided
replacecommand for the same exact edits. - Assistant
The constructor and option type edits applied correctly; the final call-site replacement was blocked by the editor window range. I’ll apply it at the reported location, then run formatting/type/build checks.
- Assistant
The implementation now merges static configured attributes with rendered node attributes exactly as schema rendering does, skips nullish DOM values, and leaves computed width synchronization intact. I’ll run the extension build and relevant tests.
- Assistant
The package-manager command did not start because Corepack attempted an interactive pnpm download, which this environment forbids. I’ll invoke the already-installed local build/test binaries directly and inspect available executables first.
- Assistant
Local
tsup,tsc, andvitestare available. I’ll use those directly, passing the package’s tsup config and running only extension-table tests. - Assistant
All 34 relevant tests pass. The initial build invocation failed only because tsup resolves entries relative to the current directory, so I’ll rerun it from the package directory. Before that, I’m tightening style handling: merged
styleattributes should not be overwritten by the legacy directnode.attrs.stylefallback, while direct/resize-plugin construction without the new fourth argument must retain its old style behavior. I’ll also use the preciseEditorViewtype instead ofunknown. - Assistant
The build reached declaration generation and correctly caught that the import replacement had been blocked by the editor’s window; the style edit was also blocked by Bash history expansion. I’ll apply both via heredocs at the appropriate lines and rerun the build. Generated
distfiles are expected to be ignored, but I’ll verify status afterward. - Assistant
The package now builds successfully, including declarations, and only the two intended source files are modified. I’ll run a temporary reproduction test (removed immediately afterward) using a real Tiptap
Editorand the reportedHTMLAttributesconfiguration, then rerun the relevant suite after the final style adjustment and run lint/format checks on changed files. - Assistant
The relevant suite and lint pass. The temporary reproduction was excluded solely because Vitest only includes files under
packages/**; it was removed as planned. I’ll rerun the same temporary test inside the package’s included path and remove it immediately, then check repository formatting and the final diff. - Assistant
The reproduction test reached editor construction but lacked the required document schema extensions; this is a test harness omission, not a product failure. I’ll rerun it with
Document,Paragraph, andText, matching the repository’s existing table editor setup, and remove it afterward. - Assistant
The real-editor regression reproduction now passes: the non-resizable NodeView’s inner
<table>has both the configured class and a configured data attribute. The temporary file was removed. Final verification is complete: package build/declarations pass, all 34 extension-table tests pass, lint and formatting pass, and only the intended two source files remain changed. I’ll submit the fix now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.