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
Let me start by exploring the repository structure to understand the codebase.
Assistant
Now let me look at the existing tests, especially for HTMLAttributes on tables:
Assistant
Now let me understand the issue and think about the fix. Let me check
mergeAttributes:Assistant
Now let me understand the issue more deeply. Let me look at the
addNodeViewsetup in the Table extension again:Assistant
Now I understand the issue clearly. The
TableViewconstructor creates the DOM manually but doesn't applythis.options.HTMLAttributes. Let me see whatViewis being constructed with - it's onlynodeandcellMinWidth. We need to pass the HTML attributes (or all options) to it.Let me check the columnResizing plugin to see how it uses the View:
Assistant
Now I understand. The
TableViewis called with(node, cellMinWidth). Looking at the issue, there are several possible approaches:- Modify the
TableViewconstructor to accept HTML attributes and apply them to the<table>element. - Pass the entire options object to the constructor.
- Modify the
addNodeViewcallback to pass HTML attributes to theView.
Approach 1 is the minimal fix mentioned in the issue. But to make it more general, we should think about the proper way. Let me look at the
Viewinterface definition again to see what the existing signature is:- Modify the
Assistant
Let me check the existing signature more carefully:
Assistant
OK, the signature is
(node, cellMinWidth, view). Changing the signature would be a breaking change. Let's stick with adding a new approach: extending the constructor to accept a config object, while maintaining backwards compatibility.Let me think about the best approach for this fix:
Approach: Make the
TableViewconstructor accept a third optional argument that includesHTMLAttributesor the full options. Then passthis.optionsto the constructor.Looking at the existing signature
(node, cellMinWidth, view), the third argument is alreadyview. We could:- Have a wider second argument (e.g. an object) that includes cellMinWidth
- Add a new fourth argument
- Simply access options via a property
Let me check how the existing signature handles things. Currently the prosemirror-tables
TableViewis byte-identical and exists in 3.22.4. Looking at the issue, the minimal fix is what they suggest: "haveTableViewapplythis.options.HTMLAttributesto the inner<table>element in its constructor."Assistant
Now I have a good understanding. Let me design the fix:
The best approach is to:
- Pass the
HTMLAttributes(or full options) to theTableViewconstructor. - Apply them to the
<table>element inside theTableView.
But changing the signature of
TableViewis a breaking change for users who have customized theirView. Let me look at how to do this without breaking the API.Actually, since the default
View: TableViewand theViewconstructor signature is(node, cellMinWidth, view), we can:- Extend the
TableViewconstructor to accept the options, while still being backwards-compatible. We do this by adding a fourth parameter or by adding a property on the instance.
Let me look at how the
Viewis called externally (only internally, right?):- Pass the
Assistant
Let me look at what the columnResizing plugin expects as
Viewargument:Assistant
Now I see. The
Viewis called asnew View(node, defaultCellMinWidth, view)from both:- The Tiptap
Tableextension inaddNodeView(withthis.options.cellMinWidthand the prosemirror view). - The
columnResizingplugin in the prosemirror-tables library.
To make a backwards-compatible fix:
The best approach would be:
- Have the
TableViewconstructor look at thenode.attrsor its own properties if any HTMLAttributes is passed. - We need to pass
HTMLAttributesto theViewconstructor.
Wait, let me check the prosemirror-tables TableView too:
- The Tiptap
Assistant
Assistant
OK, neither the prosemirror-tables nor Tiptap's TableView apply HTMLAttributes. Both cases need a fix.
Looking at the table.ts code more carefully:
tsAssistant
Now let's think about the cleanest fix:
The cleanest approach would be:
- In the
TableViewconstructor, look at the HTMLAttributes passed. - Modify the signature to accept a 4th optional argument or change the type to be more flexible.
- In
addNodeView, passthis.options.HTMLAttributesto the View.
Let me also check what version Tiptap was on before the change:
- In the
Assistant
Now let me look at when
addNodeView()was added:Assistant
OK so
addNodeViewwas added on April 30, 2026 (commit d2ad165b7). Let me see if a fix has been proposed already in the changesets directory:Assistant
Now let me design my fix. I'll do the following:
- Modify the
TableViewconstructor to accept an additional optional argument that includes and apply them to the element.
- Modify the
Assistant
Assistant
Assistant
Let me check what test infrastructure is in place:
Assistant
Let me reproduce the bug first:
Assistant
I need to use globals:
Assistant
I've reproduced the bug. The table element doesn't have
class="my-custom-table". Now let me implement the fix.Assistant
Now let me look at how the current
Viewtype is set up:Assistant
Let me now implement the fix. I'll modify both files:
-
TableView.ts: ModifyTableViewto:- Accept a 4th optional argument
HTMLAttributes?: Record<string, any> - Apply HTMLAttributes to the
<table>element
- Accept a 4th optional argument
-
table.ts:- Update the
Viewtype signature to include optionalHTMLAttributesargument - Pass
this.options.HTMLAttributesinaddNodeViewcallback
- Update the
Let me also think about how the
mergeAttributesfunction should be applied here. Looking at therenderHTML:tsconst table: DOMOutputSpec = [ 'table', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { style: getTableStyle(), }), colgroup, ['tbody', 0], ]The attribute is built dynamically. So we want to merge the style from HTMLAttributes, the dynamic style, and possibly style from . The order matters.
-
Assistant
Now let me apply the fix. First, modify
TableView.ts:Assistant
Now let me update
table.tsto:- Update the
Viewtype signature. - Pass
this.options.HTMLAttributesinaddNodeView.
- Update the
Assistant
Now update the
Viewtype signature:Assistant
The sed is having trouble with the
=>characters. Let me use a different approach:Assistant
Let me use a different separator:
Assistant
Now update the
addNodeViewcallback:Assistant
Let me run the test now:
Assistant
The fix works! Now let me also test a few more edge cases:
Assistant
Hmm, the
stylefrom HTMLAttributes is being applied, but then it's being overridden byupdateColumnswhich setstable.style.minWidth = '${totalWidth}px'if width is not fixed. Let me look at the output to see what's happening:Assistant
I see. The user-set style from
node.attrs.style(parsed from the HTML) is not being applied here. This is because:- The HTMLAttributes merge puts
stylefrom node.attrs.style into the merged attrs. - But
updateColumnsis called after, and it setstable.style.minWidthif width is not fixed. This OVERWRITES the inline style.
Wait, looking carefully: the order in my fix is:
- Apply HTMLAttributes (with merged style from node.attrs.style).
- Call
updateColumnswhich callstable.style.minWidth = '...'(overwrites).
Let me check what the original behavior was. Looking at the original TableView:
tsthis.table = this.dom.appendChild(document.createElement('table')) // Apply user styles to the table element if (node.attrs.style) { this.table.style.cssText = node.attrs.style } this.colgroup = this.table.appendChild(document.createElement('colgroup')) updateColumns(node, this.colgroup, this.table, cellMinWidth)- The HTMLAttributes merge puts
Assistant
Confirmed - even before my changes, the
node.attrs.styleis overwritten byupdateColumns. That's an existing issue that's not part of this bug fix. Let me restore my changes:Assistant
OK my fix is good. The "should still apply user-set style from node.attrs.style" test I wrote was actually wrong - that case was already broken (it's a separate issue with
updateColumnsoverwriting the style).Let me update my edge case test to be more accurate:
Assistant
All edge cases pass. Now let me also ensure the existing tests still pass:
Assistant
All 41 tests pass. Now let me think about additional edge cases:
- The
HTMLAttributesvalue could benull- handled byObject.entriescheck. - What about when
View: nullis set explicitly? Let me check:
- The
Assistant
If
View: null, thenaddNodeViewreturnsnull(i.e., no NodeView is used, falling back to schema'srenderHTML). This is the workaround mentioned in the issue.Let me also test that the
View: nullworkaround still works:Assistant
Now let me also check if there's a TypeScript issue with my changes. Let me look at the import to make sure it's correct:
Assistant
Now let me check the package's tsconfig to make sure the import is resolved:
Assistant
The path
@tiptap/coreshould resolve topackages/core/src/index.ts. Let me look at wheremergeAttributesis exported:Assistant
Good,
mergeAttributesis exported via./utilities/index.js. Now let me also confirm by running the test for the original issue with the failure case fixed:Let me look at a much simpler and cleaner approach for the TableView. I think I can simplify by passing just the options:
Assistant
Assistant
Hmm, the table element is not even in the DOM! This is because the
styleattribute requires colwidth definitions on the cells to be parsed. Let me try a different test:Assistant
Hmm, let me check what the editor is rendering:
Assistant
OK so the table content is getting parsed but the table is being stripped! Let me check what's going on:
Assistant
The table is getting stripped. The schema doesn't recognize it without additional extensions. Let me restore the stash and test properly:
Assistant
Let me look at the test pattern - we need to wrap our content in a doc structure. Let me look at the existing reproduce.spec.ts pattern I used:
Assistant
OK my fix works in the basic case. Now let me also think about another issue. Looking at the
mergeAttributes:The
classhandling concatenates values. But if and , they'd become . But only has , so that's fine.Assistant
OK only used in these two places. Let me also handle the
resizable: truecase.Actually, looking at this more carefully, I want to keep the fix minimal. The issue's main concern is
resizable: false. Let me also add the same fix forresizable: truesince it's a related issue.Let me look at how to do this. The cleanest approach is to wrap the View in a class that injects HTMLAttributes:
Assistant
Let me update
addProseMirrorPluginsto inject HTMLAttributes whenresizable: true:Assistant
Let me think again. The simplest approach for
resizable: trueis to NOT wrap, since the columnResizing plugin only supports 3 args. But I want to forward the HTMLAttributes. The challenge is the prosemirror-tablescolumnResizingplugin callsnew View(node, defaultCellMinWidth, view).Hmm. One approach is to use an anonymous class that captures HTMLAttributes in its closure:
Assistant
Hmm, this is getting complex. Let me revert and take a cleaner approach. Actually, let me undo this approach since it's not yet complete and reverting will be cleaner:
Assistant
Let me redo my changes from scratch with a cleaner approach:
Assistant
OK the
table.tschange was reverted. Let me apply only thetable.tschanges:Assistant
Now let me also address the
resizable: truecase. For that, I'll create a wrapper class:Assistant
Let me think again about whether to address the resizable case. Looking at the issue text:
In
@tiptap/extension-table3.23.x, configuring the Table extension withHTMLAttributesno longer applies those attributes to the rendered<table>element whenresizable: false(the default).So the issue explicitly notes this regression is for
resizable: false. But the same mechanism (tableView ignoring HTMLAttributes) exists forresizable: truebecause of the prosemirror-tables plugin. The user mentioned issue #6176 as a related issue.To keep this fix minimal and focused on the primary use case, let me just fix
resizable: false. If users withresizable: truehit this, the workaroundView: nullstill works.Actually, since the workaround
View: nullworks forresizable: falsetoo, I think we should also fix it forresizable: trueto be more thorough. Let me wrap the View for the resizable case too:Assistant
Wait, my approach had a temporal dead zone issue. Let me revert and try again:
Assistant
Now let me reapply the View type signature change and the addNodeView change:
Assistant
Let me check
addNodeViewmore carefully to ensure there's noView: View as typeof BaseViewproblem:Assistant
Now let me run the tests:
Assistant
All tests pass. Now let me also verify that the
resizable: truecase works with my fix:Assistant
Excellent! Even the
resizable: truecase works now. The class is applied to the<table>element.Let me look at my current TableView.ts once more to ensure everything is correct:
Assistant
Now let me also check the full picture of the modifications by looking at table.ts:
Assistant
Let me check if the build still works. Let me run the typecheck:
Assistant
These errors are unrelated to my changes - they're from the demos directory. Let me check just the extension-table package's TypeScript files:
Assistant
No tsconfig in extension-table. The build picks up the workspace root. Let me try the typecheck excluding demos:
Assistant
All the remaining errors are unrelated (demos, node_modules). Let me see if there's anything specific to my changes:
Assistant
That error is unrelated to my changes. Now let me ensure all my changes look good. Let me also clean up the temp test files:
Assistant
Let me clean up the temp files. I'll keep my reproduce tests since they're useful, but remove the debug ones:
Assistant
Now let me run the tests one more time and also check that I'm not breaking any other tests in the repo:
Assistant
Now let me also check how my changes affect the existing tests for other packages that use the
extension-table:Assistant
All tests pass. Now let me look at my final fix and clean it up:
Assistant
The diff looks good. Let me also remove the temp reproduce tests:
Assistant
Now let me run the original tests once more to ensure nothing is broken:
Assistant
All 34 existing tests pass. Now let me check the changeset convention:
Assistant
Let me create a changeset for this fix:
Assistant
Now let me write a comprehensive reproduce test to add to the test suite (the system may not allow modifying existing tests but adding a new one is acceptable for verifying our fix):
Actually, the instructions say:
UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository.
Wait, let me re-read carefully:
If existing tests break because they need to be updated to reflect the changes you made, just ignore it. However if existing tests are broken because your fix is incorrect, you should fix your code and make sure all tests pass before submitting the change.
I don't think adding new tests is forbidden, but the instruction says "UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests". So I should NOT add new tests.
But the instruction does say I should remove temp tests before submitting. Let me make sure I've cleaned up all my test files:
Assistant
Good. My changes are:
packages/extension-table/src/table/TableView.ts- Modified TableView to accept optional 4th arg for HTMLAttributes and apply them to the table.packages/extension-table/src/table/table.ts- Updated View type signature and passed HTMLAttributes through.- Added a changeset.
Let me also verify by re-running the test suite to make sure nothing is broken:
Assistant
Let me also run a comprehensive test across the whole workspace:
Assistant
All 1064 tests pass. Let me look at the current state of my changes once more:
Assistant
Let me do a final sanity check by writing a quick reproduction test once more to confirm the fix:
Assistant
All 5 final verification tests pass! Now let me clean up:
Assistant
Now let me also do one more comprehensive run to ensure no regressions:
Assistant
All 34 existing tests pass. Let me also view the final changes:
Assistant
Let me also verify the final diff once more:
Assistant
Let me also look at my addProseMirrorPlugins logic to make sure I haven't introduced a bug. When
BaseViewis null (the workaround case),BaseView && BaseView ? ... : BaseViewcorrectly falls back toBaseView(null). And theView as typeof BaseViewcast is reasonable since in that caseView === BaseView === null, which works.Assistant
That file was removed. Let me verify the workaround (View: null) still works:
Assistant
View: null workaround still works. Let me clean up:
Assistant
Now let me check that I'm using
EditorView(which I imported) correctly:Assistant
Let me also make sure the change works for one more edge case - what if HTMLAttributes has a
false/truevalue (boolean)? The originalmergeAttributesdoesn't handle that, but forsetAttribute, it should convert to string. Let me test:Assistant
Edge cases pass. Let me also clean up:
Assistant
Let me now think about the changes one more time:
-
TableView.ts:- Added
mergeAttributesimport from@tiptap/core. - Added
EditorViewtype import. - Modified constructor to accept an optional 4th arg
HTMLAttributes. - Apply HTMLAttributes (merged with
node.attrs.style) to the<table>element.
- Added
-
table.ts:- Updated
Viewtype to include optional 4th arg for backwards-compatible API. - For
resizable: true, wrapBaseViewin a subclass that callssuperwith the 4th arg (HTMLAttributes) injected. This way, the prosemirror-tablescolumnResizingplugin's call tonew View(node, cellMinWidth, view)also gets HTMLAttributes. - Pass
this.options.HTMLAttributesinaddNodeViewcallback.
- Updated
-
Changeset file: Document the fix.
Let me also think about the
View as typeof BaseViewcast. Let me check if this is even valid:-
Assistant
No new TypeScript errors in my changes. The only error about
extension-collaboration-caret/__tests__is unrelated (uses default export which doesn't exist).Let me also do a final consistency check on the diff:
Assistant
Let me also look at all tests once more in the table extension to make sure they all still pass:
Assistant
All 34 existing tests pass. Let me also do a final review of my final changes:
Assistant
Let me check the table.ts as well:
Assistant
Now let me also create one final test in a temp file to verify both the original repro and my fix work, plus edge cases:
Assistant
My fix is verified to work. Let me clean up the temp test file:
Assistant
Let me also look at the final summary of my changes. Now let me think about checklist items:
Checklist:
-
✅ If an error was reported in the issue description, I have successfully reproduced it.
- I created a reproduction script that confirmed the bug: the
<table>element doesn't haveclass="my-custom-table"when usingHTMLAttributeswithresizable: false.
- I created a reproduction script that confirmed the bug: the
-
✅ If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I re-ran the reproduction test after applying my fix, and the
<table>element now hasclass="my-custom-table".
- I re-ran the reproduction test after applying my fix, and the
-
✅ I have thought about edge cases and made sure my fix handles them as well.
-
Assistant
Let me also confirm the final status one more time:
Assistant
My final changes:
packages/extension-table/src/table/TableView.ts- Modified to accept and apply HTMLAttributes.packages/extension-table/src/table/table.ts- Updated View type and pass HTMLAttributes..changeset/2026-fix-extension-table-html-attributes.md- Changeset.
All existing tests pass, my reproduction confirms the bug, and my fix resolves it. Let me submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.