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 inspect the table extension’s source, tests, and package scripts to locate the NodeView implementation and understand the repository’s testing conventions. Then I’ll reproduce the missing attributes with the narrowest existing test setup, patch the source without changing tests, and run the relevant checks.
- Assistant
ripgrepis unavailable, so I’ll usegrep/find. I found the package at version 3.24.0; next I’ll inspect its source and nearby test configuration, especially how DOM tests instantiate editors and whether attribute helpers already exist. - Assistant
The source has evolved beyond the report (including a
renderWrapperoption), so I’ll read the exact option types,renderHTML, NodeView construction, andTableView.updatebehavior before deciding where attributes belong. This is important because static configured attributes and dynamic node attributes may need different handling. - Assistant
The root cause is confirmed in current source:
renderHTMLmerges configured attributes, whileaddNodeViewconstructsTableViewwithout them. I’ll now inspect all ofTableViewand the test helper setup. I also want to check git history/diff context for the recent NodeView change, which may indicate the intended API-compatible fix. - Assistant
The default
TableViewconstructor currently has only(node, cellMinWidth), while custom views are typed for ProseMirror’s(node, cellMinWidth, view)contract. Simply changing that contract would risk customViewcompatibility, and the resizing plugin itself controls construction when enabled. I’ll inspect the relevant commit and ProseMirror plugin API to determine whether we can pass configured attributes in both paths without breaking custom views. - Assistant
This regression was introduced exactly by the recent colgroup-sync commit. I’ll inspect
columnResizing’sViewoption and repository conventions for DOM attribute application. The likely safe strategy is to enhance the built-inTableViewwith an optional fourth argument and pass it only from Tiptap’s non-resizable factory; for resizable mode, a wrapper constructor may be needed, but only when using the built-in view so custom constructors retain their existing contract. - Assistant
columnResizingaccepts a constructor and invokes it with three arguments, so Tiptap can supply a small subclass/adapter for the built-in view in resizable mode while leaving custom views untouched. Before implementing, I’ll compare established NodeView attribute semantics (null handling, class/style behavior) andmergeAttributes, then create a temporary reproduction script or targeted Vitest invocation that proves the current failure without modifying repository tests. - Assistant
The established rendering semantics are: merge static and rendered attributes (deduplicating classes and merging CSS declarations), omit nullish values, then set attributes. For this regression, the safest focused fix is to preserve the three-argument custom
Viewcontract and add an optional fourthHTMLAttributesargument to the built-in-compatible constructor. The non-resizable factory can pass configured attributes; the built-in view will merge them with node styles exactly asrenderHTMLdoes. I’ll implement that first, reproduce before/after via a temporary external Vitest file, and then assess whether the resizable path should be adapted in this patch. - Assistant
The edits were applied, but invoking
pnpmtriggered Corepack’s interactive download prompt and timed out (the environment cannot answer prompts). I’ll use the already-installed local binaries directly, inspect the result, and run Vitest the same way to avoid package-manager interaction. - Assistant
Unexpectedly, no diff was printed. I’ll verify whether the timeout killed the shell before Python’s buffered edits persisted or whether the formatter restored content, then reapply with the repository’s
editutility if needed. - Assistant
The timed-out process was terminated before changes persisted. I’ll reapply the focused edits in a short command, verify them immediately, then format separately.
- Assistant
Python is not available in this shell despite the earlier compound command not surfacing that error. I’ll use Node (which the repository requires) for the same deterministic replacements.
- Assistant
The patch is now present. I’ll format it and run a temporary test located outside the repository. The test will instantiate the reported editor configuration twice: once with a “legacy” view that drops the new optional attribute argument (reproducing the pre-fix missing class), and once with the fixed default view (confirming class, arbitrary data attributes, merged styles, and omission of nullish attributes).
- Assistant
The external test was discovered correctly, but its minimal config omitted the monorepo’s
@tiptap/pm/*aliases. I’ll compose the temporary config with the repository config so all source imports resolve, while keeping the test itself outside the repository. - Assistant
The temporary run successfully reproduced the missing class with the legacy constructor and confirmed the fixed default view applies the class/data/null semantics. Its extra background-style assertion was invalid because this table schema does not parse arbitrary inline style into node attributes; importantly, the configured style and reported class assertions passed. The accidental config merge also ran all 117 repository test files successfully; only that invalid temporary assertion failed.
I’ll now run the extension-table suite alone with the normal repository config, then build/type-check the package. I’ll keep the patch scoped to the reported 3.23 non-resizable regression: resizable tables are created by the upstream ProseMirror plugin through a separate mechanism, explicitly noted as a related but different issue.
- Assistant
All 34 extension-table tests pass, and the package builds successfully including declaration generation. I’ll make one small type-quality refinement: type the preserved third constructor argument as
EditorViewrather thanunknown, matching the documented/custom view contract. Then I’ll run formatting/lint checks, inspect the final diff and repository status, and remove the temporary external files. - Assistant
The final diff is clean, formatted, and lint-free, with only the two intended source files modified. I’ll perform one last exact reproduction test using the reported configuration and a temporary config that reuses monorepo aliases but replaces (rather than merges) the test include list, ensuring only this external test runs. Then I’ll rerun the key colgroup test after the final type refinement and submit.
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 →