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
Let me start by exploring the repository structure to understand the codebase and find the relevant files for the
@tiptap/extension-tablepackage.Assistant
I need to make one tool call at a time. Let me explore the repository structure.
Assistant
Let me see the full
table.tsfile including therenderHTMLmethod.Assistant
Let me look at the table's attributes and the
__tests__directory to understand the testing approach.Assistant
Now let me look at the
addNodeViewand check if there's anaddAttributesfor the table.Assistant
Now let me look at the
addNodeViewmethod and the full structure. Let me check the existing tests to understand testing patterns.Assistant
Let me look at the test setup and how attributes are applied. Let me check the
mergeAttributesand any DOM attribute helper in core.Assistant
Let me check how tests are run and look at the package.json.
Assistant
Let me check how tests are run - they use vitest. Let me check the root package.json and test configuration.
Assistant
Let me run the existing table tests first to confirm they pass before making changes.
Assistant
Tests pass. Now let me write a reproduction test to confirm the bug.
Assistant
I've confirmed the bug. Now let me understand the table attributes better. Let me search for where the
styleattribute is defined for the table.Assistant
Let me check what attributes the table node actually has by examining the schema.
Assistant
The table has no schema attributes. Let me look at how
renderHTMLworks and check for DOM attribute helpers in core.Assistant
Let me search for how Tiptap applies attributes to DOM elements in node views.
Assistant
Let me check how ProseMirror's
columnResizingplugin uses theViewoption.Assistant
Let me search for any helper that applies an attributes record to a DOM element in the codebase.
Assistant
Let me look at
getRenderedAttributesto understand the HTMLAttributes passed to renderHTML.Assistant
Let me check the git history to understand the recent changes that introduced the regression.
Assistant
Let me look at the commit that added user-defined styles handling to understand the style behavior.
Assistant
Let me check how ProseMirror's columnResizing accesses the node view's table/colgroup properties.
Assistant
So the ProseMirror
TableView(in prosemirror-tables) hastable,colgroup,contentDOM,domproperties. AndcolumnResizingregisters the nodeView asnew View(node, defaultCellMinWidth, view).Let me check how
columnResizingaccesses the node view for updates - it probably uses decorations or directly accesses the view'scolgroup/table. Let me look at line 1915 context.Assistant
Let me look at the type definitions for the
columnResizingView option and theViewtype.Assistant
The
columnResizingViewtype is(new (node, cellMinWidth, view) => NodeView) | null, matching the TiptapViewtype. So I can't change the constructor signature without breakingcolumnResizing. Let me look atcreateColGroupto understand the width computation.Assistant
Let me search for existing tests that use
HTMLAttributeson the table to understand expected behavior.Assistant
Let me also check the table-cell tests for HTMLAttributes usage, and check the e2e tests for HTMLAttributes on table.
Assistant
Let me check where
updateColumnsis called.Assistant
updateColumnsis only called withinTableView(constructor and update). It's exported but only used internally. Let me check if it's exported in the index.Assistant
Let me look at how other tiptap NodeViews apply HTMLAttributes to follow the established pattern.
Assistant
The image NodeView receives
HTMLAttributesas a prop. Let me check how Tiptap'saddNodeViewsystem providesHTMLAttributesto node views.Assistant
Now I have a thorough understanding. Let me check the
ResizableNodeViewpattern isn't relevant and look at the exactaddNodeViewcode once more to craft my fix.Assistant
mergeAttributesis already imported. Now let me implement the fix inaddNodeView. Let me open the file at that section.Assistant
Now let me implement the fix:
Assistant
No python3. Let me use the
editcommand instead. Let me open the file and edit.Assistant
There's a duplicate
},at line 571. Let me remove the extra one.Assistant
The code looks correct now. Let me run my reproduction test to confirm the fix.
Assistant
The fix works. Now let me write a more comprehensive test to verify edge cases.
Assistant
Let me see both failures in detail.
Assistant
My test assertions were wrong — tables without
colwidthusemin-width, notwidth(sincefixedWidthis false). Let me verify and fix the test.Assistant
All edge cases pass. Now let me run the existing tests to ensure I didn't break anything.
Assistant
All tests pass. Now let me clean up my temporary test files since I shouldn't add new tests to the repo.
Assistant
Now let me verify the TypeScript compiles correctly. Let me check for a typecheck script.
Assistant
Let me try a TypeScript type check on the modified file using the build tsconfig.
Assistant
The errors are all pre-existing in unrelated files (static-renderer, vue-3, vitest config). Let me confirm there are no errors in the table extension files.
Assistant
Let me verify that error is pre-existing and unrelated to my change by checking the import.
Assistant
Confirmed: that error is pre-existing (exists without my change) and unrelated. My change introduces no new TypeScript errors.
Let me check if the repo uses changesets and whether I should add one.
Assistant
Let me add a changeset following the repo's convention.
Assistant
Now let me re-run the table tests one final time to confirm everything passes after cleanup.
Assistant
All existing tests pass. Let me run a broader set of tests on packages that might use the Table extension to be thorough.
Assistant
All passing. Let me review my final change with a git diff.
Assistant
My changes are complete. Let me do one final verification with a temporary test matching the exact issue scenario, then remove it.
Assistant
Both the default case (now fixed) and the workaround case still work. Let me clean up the temporary test.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.