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); }When
resizableis false (default) andViewis the defaultTableView, this returns a NodeView.TableViewbuilds the DOM manually:constructor(node, cellMinWidth) { this.dom = document.createElement("div"); this.dom.className = "tableWrapper"; this.table = this.dom.appendChild(document.createElement("table")); 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); this.contentDOM = this.table.appendChild(document.createElement("tbody")); }TableViewnever readsthis.options.HTMLAttributes. The schema-levelrenderHTML(which does callmergeAttributes(this.options.HTMLAttributes, HTMLAttributes, ...)) is bypassed whenever the NodeView is active.Workaround
Table.configure({ HTMLAttributes: { class: 'my-custom-table' }, View: null })This disables the NodeView and falls back to the schema's
renderHTML. Side effect: losesTableView's in-placeupdate(node)column-width sync; a full re-render happens on attribute changes instead. Acceptable for most read-only or non-resizable use cases.Related
#6176 reports a similar symptom on Tiptap 2.11.5 with
resizable: true. Different mechanism (noaddNodeViewin 2.x), same user-facing impact.Dependency Updates
- Yes, I've updated all my dependencies.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /tiptap, current file: none) bash-$
Assistant
Let me start by understanding the repository structure and the issue. The bug is about
@tiptap/extension-tablewhereHTMLAttributesconfigured on the Table extension are not applied to the rendered<table>element whenresizable: false(default). The fix should be inTableViewto applythis.options.HTMLAttributesto the inner<table>element.Let me explore the repository structure first.
Assistant
Let's find the extension-table package and look at the relevant files.
Assistant
Let's look at the structure of the extension-table package.
Assistant
Let me look at the table directory and the TableView file.
Assistant
Let me read the key files.
Assistant
Let me read them one at a time.
Assistant
Now let's look at the table.ts file:
Assistant
Now let me look at the dist files to confirm the issue and understand the build output
Assistant
Let me check the index file and understand the exports:
Assistant
Let me find and check any test files for the table extension
Assistant
Let me check the test files to understand the testing patterns
Assistant
Let me first try to reproduce the issue by creating a test script.
Assistant
Let me check how to run the tests:
Assistant
Let me see the full
table.tsfile, especially therenderHTMLpartAssistant
Let me see the relevant section of
table.tsaroundrenderHTMLand `addNodeAssistant
Let me check how
columnResizinguses theViewoptionAssistant
Let me look at the node_modules for the pm tables package
Assistant
Let me check if there's a source for pm in the packages directory.
Assistant
Let me check the pm tables source
Assistant
Now I have a clear understanding. Let me create a reproduction script to confirm the bug:
Assistant
Now let me run it:
Assistant
We need a DOM environment. Let me use vitest directly to run a quick
Assistant
Let me create a simple reproduction test and run it with vitest:
Assistant
Now let's run this test.
Assistant
Let me put the test inside the extension-table test
Assistant
Now let me run this specific test to confirm the bug:
Assistant
The bug is confirmed. Now let me fix it. The issue is clear:
TableViewconstructor builds the DOM manually but never appliesHTMLAttributes. Let me fix both filesAssistant
Let me use the correct format for the open command.
Assistant
Let me see the rest of the file
Assistant
Now I understand the full picture. Let me fix both files. First, let me edit the
TableView.tsto accept and applyHTMLAttributes:Assistant
Now let me edit
table.tsto passHTMLAttributesto theViewconstructor:Assistant
Let me go to the `addNodeView
Assistant
Now let me edit the
addNodeViewmethod to passHTMLAttributes:Assistant
Now let me run the reproduction test to confirm the fix works:
Assistant
The fix works. Now let me run the existing tests to make sure I didn't break anything:
Assistant
All 35 tests pass (including the new reproduction test). Now let me remove the test file I added (since the instructions say not to add new tests) and verify the final state:
Assistant
Let me verify the existing tests still pass after removing the repro test:
Assistant
All 34 existing tests pass. Let me review the final state of both changed files to make sure everything looks correct:
Assistant
Let me also verify whether the resizable case might need similar treatment. Let me check how
prosemirror-tablescolumnResizinguses theView:Assistant
Let me search for the specific columnResizing plugin implementation:
Assistant
Let me see how
columnResizingcreates the NodeView:Assistant
Let me check if prosemirror-tables has its own TableView:
Assistant
Good. The
prosemirror-tableshas its own built-inTableViewfor the resizable case. The tiptap extension defaults itsViewoption to@tiptap/extension-table'sTableView. My fix addresses the non-resizable case (whereaddNodeViewcreates the NodeView), which is the reported issue.Let me do a final review of the changes:
Assistant
The changes look clean. Let me run the tests one final time:
Assistant
All 34 tests pass. The fix is complete. Let me now go through the checklist:
Checklist
-
[x] If an error was reported in the issue description, I have successfully reproduced it.
- I created a reproduction test that confirmed the
<table>element was missing theclass="my-custom-table"attribute whenTable.configure({ HTMLAttributes: { class: 'my-custom-table' } })was used withresizable: false(the default).
- I created a reproduction test that confirmed the
-
[x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- After the fix, the same reproduction test passes — the
class="my-custom-table"is now correctly applied to the<table>element.
- After the fix, the same reproduction test passes — the
-
[x] I have thought about edge cases and made sure my fix handles them as well.
styleattribute in HTMLAttributes: Merged with node-levelstyle, with node-level taking precedence (matchingmergeAttributesbehavior).classattribute: Added viaclassList.add()to avoid overwriting any existing classes.- Other attributes (e.g.,
id,data-*): Applied viasetAttribute. View: null:addNodeView()returnsnull, falls back torenderHTMLwhich already handles HTMLAttributes correctly.resizable: true:addNodeView()returnsnull(thecolumnResizingplugin handles the NodeView); this is a separate issue inprosemirror-tables.- Custom
Viewimplementations: The 4th argument (HTMLAttributes) is safely ignored by JavaScript if the custom constructor only expects 3 parameters. - Backward compatibility: All 34 existing tests pass unchanged.
-
[x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
- All 34 tests across 5 test files in
packages/extension-table/__tests__/pass.
- All 34 tests across 5 test files in
Summary of Changes
Two files were modified:
-
packages/extension-table/src/table/TableView.ts: Added an optional 4th parameterHTMLAttributesto theTableViewconstructor. When provided, the HTML attributes (class, style, id, data-*, etc.) are applied to the inner<table>element. Thestyleattribute is merged with node-level styles (node takes precedence),classis added viaclassList.add, and all other attributes are set viasetAttribute. -
packages/extension-table/src/table/table.ts: ModifiedaddNodeView()to passthis.options.HTMLAttributesas the 4th argument to theViewconstructor when creating the NodeView.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →