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.
Interface
No new interfaces are introduced.
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
I’ll first locate the table extension, its NodeView implementation, and nearby tests/package scripts. Then I’ll reproduce the missing attributes with the existing test setup, update the NodeView API/wiring so configured attributes reach the actual
<table>, and run the focused test suite plus relevant type checks. - Assistant
ripgrepis unavailable, so I’ll usegrep/findto inspect the implementation and existing table tests without installing unnecessary tooling. - Assistant
I found the newly active
TableViewpath. I’ll now inspect its constructor and the extension’s attribute/rendering logic, then compare other NodeViews for the repository’s standard way of applying static HTML attributes (especially handling class/style and non-string values). - Assistant
The key design issue is that
HTMLAttributesare extension options, whilenode.attrs.stylecan change over time. Passing options into the default/custom View constructor is the smallest compatible extension, but custom Views currently declare a 3-argument constructor and JavaScript safely ignores a fourth argument. I’ll inspect the schema/render method and attribute utility semantics before choosing whether to apply raw options or merged node/render attributes. - Assistant
renderHTMLmerges configured attributes with rendered node attributes and computed width styles. For parity, the NodeView should receive the already mergedHTMLAttributessupplied by Tiptap’s NodeView renderer rather than only reading the node’sstyle; this preserves classes and extension-added attributes. However, the resizable plugin constructs the View itself, so I’ll inspect that API and tests to ensure the fix covers both default and resizable modes without breaking custom View constructors. - Assistant
The ProseMirror resizing plugin only passes
(node, cellMinWidth, view), so merely adding an attributes argument at the normal call site would still fail in resizable mode. I’ll first run a temporary focused Vitest spec to document the regression. Then I’ll add an optional fourth constructor argument (backward-compatible for custom Views), pass merged attributes from Tiptap’s non-resizable renderer, and provide a small configured subclass to the resizing plugin so it can inject the same options despite its fixed three-argument API. - Assistant
The first test command hit Corepack’s interactive download prompt (which this environment cannot answer), leaving the temporary spec in place. Dependencies are already installed, so I’ll invoke the local Vitest binary directly to complete the reproduction, then remove the temporary test.
- Assistant
The temporary test initially failed during schema construction because table rows reference
tableHeader; that is a reproduction setup error rather than the reported bug. I’ll rerun with the complete table schema to establish the expected assertion failure before editing source. - Assistant
The corrected reproduction now fails exactly as reported (
classisnull). I’ll implement attribute application on the inner table, preserving the existing node-level style precedence viamergeAttributes. I’ll also update the View constructor type and both creation paths: non-resizable gets the fully merged renderer attributes, while resizable gets a wrapper View that supplies configured attributes through ProseMirror’s fixed constructor contract. - Assistant
Python is not installed in this environment, so no files were changed. I’ll perform the same targeted edits with the available Node.js runtime and immediately inspect the diff for formatting and type correctness.
- Assistant
The diff now applies all non-null configured attributes to the inner
<table>and merges styles rather than replacing configured declarations. I’ll rerun the same temporary test for bothresizable: falseandresizable: true, including class, data, and style assertions, to verify both NodeView creation mechanisms. - Assistant
The regression test now passes in both modes, including non-class attributes and configured styles. Next I’ll run the existing extension-table tests and package build/type declaration generation. This should expose any behavior regressions, constructor compatibility issues, or formatting/type errors from the dynamic resizable View subclass.
- Assistant
All 34 existing table tests pass. The build command was invoked from the repository root, but this package’s tsup config uses package-relative entry paths, so it reported
Cannot find src/table/index.ts; that is an invocation issue. I’ll rerun frompackages/extension-table, then run the repository formatter/checker on the two changed files and inspect generated/untracked changes. - Assistant
The package build, including declaration generation, passes. No generated
distfiles are tracked as changes. This repository does not install aprettierbinary, so I’ll inspect its declared lint/format tooling and use the appropriate local checker; I’ll also consider simplifying duplicate type imports if the linter enforces import consolidation. - Assistant
The repository uses
oxfmtandoxlint;git diff --checkis already clean. I’ll run both tools against the changed files, applying only formatter-generated source changes if needed, then recheck the diff. - Assistant
Formatting and linting both pass with zero findings. Before submission, I’ll do a final source/diff review and verify there are no temporary tests or build artifacts in the patch. I’ll specifically check that custom three-argument View constructors remain structurally assignable and that null attributes are skipped consistently with DOM serialization.
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →