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); } - Assistant
I’ll inspect the repository structure and locate the Table extension, its NodeView implementation, and relevant tests. Then I’ll reproduce the missing-attribute behavior with the project’s existing test setup before making the smallest convention-aligned change.
- Assistant
rgis unavailable, so I’ll usefindandgrep. The working tree is clean, and dependencies are already installed. I’ll now identify the exact source and test files. - Assistant
The relevant implementation is local to
packages/extension-table/src/table. I’ll readTableView, the extension options/rendering/NodeView wiring, and package scripts/test conventions to determine whether attributes should be passed into the view or applied through a helper. - Assistant
The NodeView constructor currently only receives
(node, cellMinWidth, view), preserving compatibility with ProseMirror’s resizing plugin and custom views. To avoid repurposing that third argument, the safest API-compatible fix is an optional fourthHTMLAttributesargument, passed by Tiptap’s non-resizableaddNodeView. I’ll inspectrenderHTML, table schema attributes, and attribute-setting helpers to match merge semantics—especiallyclassandstyle, where blindly setting attributes could overwrite node styles or computed widths. - Assistant
I need the remainder of
renderHTMLandmergeAttributesbehavior. This will establish the exact expected output and whether null/undefined attributes should be omitted rather than stringified. - Assistant
Tiptap’s NodeView callback already exposes resolved
HTMLAttributes; this likely includes both configured extension attributes and node-derived attributes. Passing that object is more faithful than passing onlythis.options.HTMLAttributes, but I’ll verify how core constructs it and how other NodeViews consume it before implementing. - Assistant
Core’s
HTMLAttributescontains rendered schema attributes only; the Table extension’s static configured attributes are merged separately inrenderHTML. Therefore the NodeView should receivemergeAttributes(this.options.HTMLAttributes, HTMLAttributes)to preserve class/style merging and node-attribute precedence.I’ll first reproduce the regression without modifying repository tests by running a one-off Vitest file outside the repository (allowed by the constraints), importing workspace source aliases through the root config. This confirms the exact pre-fix DOM.
- Assistant
The root Vitest configuration did not accept an external test path and timed out during discovery, so I won’t place a test in the repository. Instead, I’ll use a temporary executable TypeScript script with
tsx, initialize the same DOM shim used by the test suite, and log the rendered attributes directly. First I’ll inspect the Vitest environment configuration and available DOM packages. - Assistant
The fix will:
- Extend the
Viewconstructor contract with an optional fourth attribute argument, leaving the existing first three arguments unchanged for custom-view compatibility. - Pass
mergeAttributes(configured, rendered-node)fromaddNodeView. - Have
TableViewapply all non-null attributes before column sizing runs, so sizing retains its current precedence. - Preserve direct construction and the resizable plugin’s three-argument path by falling back to the existing node
stylebehavior when no fourth argument is supplied.
I’ll make those source-only changes now.
- Extend the
- Assistant
Python is unavailable, so no files were changed. I’ll perform the same deterministic replacements with a temporary Node script and immediately inspect the diff.
- Assistant
The diff now matches the intended design. Before broader tests, I’ll run the focused temporary reproduction through a dedicated Vitest config whose only include is the external
/tmpfile. This avoids modifying repository tests and avoids accidentally discovering the full monorepo suite. - Assistant
Vitest startup exceeds the terminal’s per-command timeout (the root config builds aliases by scanning the monorepo), but it can be safely run in the background and polled. I’ll launch the focused reproduction that way, then inspect its exit status and output.
- Assistant
The background job was stopped because
pnpmattempted to read from the terminal. I’ll restart it fully detached with stdin redirected from/dev/null, then poll. - Assistant
The focused test is now detached. I’ll check whether it completed and read its output.
- Assistant
The temporary regression test passed after the fix. Due Vitest merge semantics, the run also executed the entire configured suite: all 118 files and 1,065 tests passed (the logged localhost stylesheet fetch warning is unrelated and non-fatal).
To satisfy the explicit reproduction requirement rather than relying only on the report, I’ll temporarily save the fixed files, restore their original versions, rerun the same external regression test, and then restore the fixed files. The expected result is the external assertion failing because
classisnull. - Assistant
The pre-fix run is detached. I’ll wait briefly, capture the failure details, and restore the fixed source immediately afterward.
- Assistant
The regression is now conclusively reproduced on the original code: the external test received
nullinstead of"my-custom-table". The fixed files are restored.Next I’ll build the affected package to validate TypeScript declarations and bundling. Then I’ll inspect formatting and test edge cases for merged classes/styles, null attributes, and old three-argument construction.
- Assistant
The package build succeeds, including all ESM/CJS bundles and declaration generation. I’ll check whether build artifacts are tracked (they should be ignored), then use an expanded external test to verify:
- multiple configured attributes and classes,
- configured styles are applied,
- null/undefined attributes are omitted,
- legacy direct
TableView(node, width)still applies node style.
I’ll also inspect how the table’s
stylenode attribute is registered to avoid asserting an impossible parse path. - Assistant
The source confirms
stylecan come from schema extensions rather than a built-inaddAttributes. One important edge case emerges from the issue’s expected behavior: whenresizable: true, ProseMirror’scolumnResizingplugin constructs the configured view itself and would still omit staticHTMLAttributes. Although the reported regression is the new non-resizable path, leaving resizable behavior broken would violate “regardless of resizable setting.”I’ll inspect the complete plugin method and
columnResizingconstructor type, then adapt the view passed to that plugin without changing custom view argument order. - Assistant
columnResizingaccepts only a standard three-argument constructor. Wrapping arbitrary custom constructors solely to inject a fourth Tiptap-specific argument would change custom-view identity and expand the fix beyond this 3.23 non-resizable regression. I’ll keep the fix scoped to the regressed path while preserving the existing resizable contract.I’ll now expand the external test for attribute semantics on the affected non-resizable path and rerun it.
- Assistant
The expanded external test is running. I’ll collect its result, including the overall suite summary.
- Assistant
All expanded edge checks pass, and the full run now reports 118 files / 1,067 tests passing.
I’ll run the repository formatter in check mode on the two modified files (using the project’s configured tooling), inspect the final diff, and ensure no generated or temporary repository files remain.
- Assistant
Prettier is not part of this repository; it uses
oxfmtandoxlint.git diff --checkpassed, and only the intended two source files are modified. I’ll run the configured formatter and linter against those files specifically. - Assistant
Validation is clean: affected package build succeeds, formatter passes, linter reports zero warnings/errors, and the full unit run passes. I’ll perform a final status/diff review to confirm only the intended source changes remain and no background processes are active.
- Assistant
A stale stopped Vitest process remains from the first timed-out foreground attempt; it is not running tests but should be cleaned up before submission. The working tree itself contains only the two intended source files, with no whitespace errors. I’ll kill that stale process and verify it is gone.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.