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
Node is available. Let's use node instead.
Assistant
Now update TableView.ts to accept and apply HTMLAttributes.
Assistant
Now let's check that update() method also should keep HTMLAttributes applied - store it and reapply in update? Actually static config attributes should persist since not overwritten. But let's check
updatemethod doesn't reset table's other attributes, so fine. Let's build/typecheck.Assistant
Let's just run type checking with tsc directly using the build tsconfig, targeting only the relevant file for speed, and in background with timeout control.
Assistant
Good - no errors related to our TableView.ts or table.ts changes; all pre-existing errors unrelated to our change. Now let's build just this package using tsup with a longer timeout, running in background.
Assistant
Build succeeds. Now let's write a quick test to reproduce the issue using jsdom to verify HTMLAttributes are applied.
Assistant
Good, there's an existing test file with similar setup. Let's create a temporary reproduce script using vitest to verify our fix works before removing it.
Assistant
Test passes. Let's confirm it would have failed before the fix, by checking out the change temporarily.
Assistant
Confirmed reproduction of the bug and that our fix resolves it. Restore the fix.
Assistant
Now let's remove the temporary test file and run the full existing test suite for extension-table.
Assistant
All existing tests pass. Let's also run a broader check across packages depending on extension-table (e.g., extension-table-of-contents, any other place using TableView) and check for other usages that might construct TableView directly with fewer args (to make sure default param doesn't break).
Assistant
Now let's add a helper function after the type declarations, before
export const Table.Assistant
Now update
addProseMirrorPluginsandaddNodeViewto use this wrapper.Assistant
Now let's view the whole modified section and run the tests again (including edge case: resizable true with default View null aka disabled).
Assistant
Now let's typecheck for errors related to our file only, and rerun tests.
Assistant
No new type errors from our source files. Now let's write test scripts for both resizable false and true, run, then clean up.
Assistant
All four scenarios pass, including resizable:true and the View:null fallback. Let's clean up temp test and rerun the full extension-table test suite plus a broader sanity check.
Assistant
All pass. Let's also rebuild the package to make sure everything still compiles with the additional wrapper function.
Assistant
Build succeeds. Now let's view the full diff for review.
Assistant
No new type errors. Now let's run lint if available for these files.
Assistant
Lint passes with 0 errors. Let's run full extension-table test suite once more and also check other packages that might reference TableView (e.g., extension-table-of-contents, or docs) just to be safe.
Assistant
Only in extension-table itself. Let's run the full test suite once more for final confirmation and check git status/diff.
Assistant
dist is git-ignored, so no need to worry about it in the diff. Everything looks good. Let's do a final review of the complete diff.
Assistant
This resolves the issue comprehensively. Let's do a final full test run across the whole test suite for extension-table related areas one more time, and check that dist directory changes are cleaned up (not needed since git-ignored).
Assistant
All 454 tests pass across core and extension-table packages. Now the final checklist review.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.