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 inspect the table extension’s source, tests, and package scripts first. Then I’ll reproduce the missing attributes with the closest existing test setup, implement the fix in the established API style, and run the focused tests plus relevant type/build checks.
- Assistant
ripgrepis unavailable, so I’ll usegrep/find. I’m locating the NodeView implementation and nearby test conventions, especially DOM rendering tests that can validate configured attributes without adding repository tests. - Assistant
The configured attributes are currently only merged by
renderHTML, whileaddNodeViewconstructsTableViewwithout them. I’ll read both implementations and the column-update tests to determine constructor compatibility requirements—particularly because users can supply a customView. - Assistant
A key compatibility constraint is that
Viewis public and its third constructor argument is the ProseMirrorEditorView. Replacing that argument with attributes would break custom views. I’ll inspect git history and attribute utilities before choosing between a backward-compatible fourth argument and post-construction handling. I’ll also run the existing focused test once as a baseline. - Assistant
The baseline test command was blocked because Corepack wants interactive confirmation to download the pinned pnpm version. Since dependencies and Vitest are already installed, I’ll invoke the local binary directly. The history confirms the non-resizable NodeView was recently introduced; I’ll inspect that commit and
mergeAttributessemantics, then create a temporary (non-repository) reproduction script/test. - Assistant
The focused baseline passes, isolating the regression to DOM attributes rather than column synchronization. To reproduce the report exactly without modifying tests, I’ll place a temporary Vitest file under
/tmpor generate it briefly in the package and remove it afterward; because Vitest’s include rules may require repository placement, I’ll use a temporary file in the existing test directory and ensure it is deleted before submission. The reproduction will check class, generic data attributes, and style precedence. - Assistant
The temporary reproduction fails exactly as reported (
classisnull) and has been removed. The fix should mirror ProseMirror DOM serialization semantics rather than blindly stringifying null values. I’ll locate existing Tiptap helpers for applying rendered attributes and inspect how schema attributes (notablystyle) are defined, so configured styles still combine correctly with column width logic. - Assistant
There is no table-specific
addAttributes;stylearrives via extension/global schema attributes and is already handled byTableView. The safest narrow fix is therefore to let the built-inTableViewaccept configured HTML attributes while preserving the customView(node, cellMinWidth, view)contract. I’ll use an optional fourth constructor argument passed only byaddNodeView, apply non-null attributes as ProseMirror does, and then apply nodestyleafterward so dynamic node styles retain the same precedence asrenderHTML. This also avoids assuming a custom NodeView’s DOM structure. - Assistant
A better match to
renderHTMLis available: Tiptap’s NodeView renderer props include the node’s already-renderedHTMLAttributes. I’ll verify that callback type and existing usages. If confirmed,addNodeViewcan merge configured and dynamic attributes exactly as schema rendering does, pass the merged result as an optional fourth argument, andTableView.updatemay need to synchronize dynamic attributes on node changes rather than only applying them at construction. - Assistant
The callback does expose
HTMLAttributes. I’ll inspect how core refreshes NodeViews: ProseMirror’supdate(node)does not re-run the NodeView factory, so the built-in view should retain configured static attributes and reconcile node-derived style itself. Since the reported configuration is static, constructor application is essential; update behavior should at minimum avoid deleting column sizing while preserving style precedence. - Assistant
Core computes node-derived HTML attributes only when the NodeView is created. For this regression, merging
this.options.HTMLAttributeswith that callback value is the exact analogue of the first two arguments torenderHTML’smergeAttributes. I’ll implement:- an optional fourth
HTMLAttributesparameter on the publicViewconstructor type (backward-compatible for custom views), - passing merged attributes from
addNodeView, - applying all non-null attributes in built-in
TableViewbefore column sizing. Nodestyleis already included in the merged callback attributes, so the old direct style assignment can be replaced rather than duplicated.
- an optional fourth
- Assistant
Python is unavailable, so no changes were made. I’ll apply the same targeted edits using the repository’s
edit/replacecommands, then inspect the resulting diff before testing. - Assistant
The import and constructor type changed, but multiline replacements did not match (and the import replacement introduced one extra blank line). I’ll fix the exact line ranges directly and then apply the
addNodeViewchange by its current line numbers. - Assistant
The direct line edit revealed a one-line offset and left the old constructor declaration in place; I’ll remove that duplicate and restore the conventional blank line between external and local imports. Then I’ll replace the single return line in
addNodeView. - Assistant
The constructor is now clean. The special
replacecommand still declines the exactaddNodeViewline despite finding it, so I’ll use a direct line-range edit at line 541 and immediately inspect the surrounding code. - Assistant
Before broadening behavior, I’ll run the exact reproduction and focused suite plus the package build. This will reveal constructor-type compatibility with
columnResizing. I’ll also include configured style in the temporary check; generic styles should survive, while width is a special case because column synchronization intentionally manages width/min-width. - Assistant
The exact regression and generic/style attributes now pass alongside all nine column-update tests. The initial build invocation used the repository root, but the package’s tsup config expects package-relative paths; I’ll rerun it from
packages/extension-table. I’ll also run formatting/lint checks on the changed files. If types pass, I’ll assess whether width-style handling needs a narrow follow-up or would improperly alter existing column-sizing semantics. - Assistant
The package build, declaration generation, formatter, and linter all pass. I spotted one compatibility edge case before finalizing: the resizable plugin still constructs
TableViewwith three arguments, so replacing the old directnode.attrs.stylehandling would regress node styles in resizable mode. I’ll restore it as a fallback only when the fourth-argument attributes do not already containstyle; this preserves old behavior without overriding the correctly merged non-resizable style. - Assistant
The fallback is in place and formatted. I’ll now run the complete extension-table unit test directory, repeat the exact temporary regression test after the final code, and rerun package build/type generation. Then I’ll review the final diff and repository status for accidental files.
- Assistant
All 34 extension-table tests pass, the final exact reproduction passes, and the package build/declaration generation succeeds. I’ll perform the final diff review now, checking API compatibility, formatting, and ensuring the temporary test/build artifacts are absent or ignored.
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 →