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 understand the issue:
-
In
@tiptap/extension-table3.23.x, whenTable.configure({ HTMLAttributes: { class: 'my-custom-table' } })is used, the attributes don't appear on the rendered<table>element whenresizable: false(default). -
The root cause is that 3.23 introduced
addNodeView()in the Table extension, which returns aTableViewNodeView. TheTableViewbuilds the DOM manually in its constructor but never readsthis.options.HTMLAttributes. The schema-levelrenderHTML(which does apply HTMLAttributes) is bypassed when the NodeView is active. -
A minimal fix would be to have
TableViewapplythis.options.HTMLAttributesto the inner<table>element in its constructor.
Let me explore the repository structure and find the relevant files.
-
Assistant
Let me find the extension-table package specifically.
Assistant
Let me look at the extension-table package structure.
Assistant
Now let me examine the key files:
TableView.tsand `table.tsAssistant
Let me just read the files using cat.
Assistant
Now let me look at the
table.tsfile to see theaddNodeViewmethod:Assistant
Let me also check the types file
Assistant
Let me look at how
mergeAttributesworks in the core:Assistant
Let me look at mergeAttributes.
Assistant
Now I have a clear understanding of the issue. Let me also look at the
getRenderedAttributeshelper:Assistant
Now I have a clear understanding of the issue. Let me implement the fix.
Plan:
- Modify
TableView.tsconstructor to acceptHTMLAttributesas a 4th optional parameter and apply them tothis.table - Modify
table.tsaddNodeViewto passthis.options.HTMLAttributesto the View constructor
Let me start with
TableView.ts:- Modify
Assistant
Now let me edit
TableView.tsto accept and applyHTMLAttributesAssistant
Let me use the
replacecommand insteadAssistant
Now let me replace the constructor. Let me use
replaceto update the constructor signature and body:Assistant
Let me use the correct format with SEARCH and REPLACE
Assistant
Let me scroll to line 90 and then try the replace.
Assistant
Now let me use
editto replace lines 90-105Assistant
TableView.tsupdated. Now let me modifytable.tsto passHTMLAttributesto the View constructorAssistant
Let me find the
addNodeViewmethod in table.tsAssistant
Let me see the full
addNodeViewmethodAssistant
Let me open table.ts
Assistant
Now let me edit line 534 to pass
HTMLAttributesAssistant
Now let me verify the changes look correct
Assistant
Let me check if there are built dist files that also need updating
Assistant
Good, no dist files. Now let me run the existing tests for the extension-table package
Assistant
Let me check how tests are run in this repo
Assistant
Let me run the existing tests for the extension-table package
Assistant
All tests pass. Let me also verify the changes are complete and look at the test file for any related tests
Assistant
Let me verify there are no TypeScript issues by checking the types
Assistant
Let me check the TypeScript configuration
Assistant
Let me check the central tsconfig
Assistant
The TypeScript errors are only from demos, not from our changed files. Let me verify the final diff of our changes
Assistant
The diff looks correct. Let me run the tests one more time to confirm everything still passes
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 →