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
tsimport { 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 element in its constructor. Assistant
I'll start by exploring the repository structure to understand the codebase and find the relevant files.
Assistant
Let me see the full table.ts file, particularly the parts that were truncated.
Assistant
Now let me look at how the table node attributes are defined, and check the types file.
Assistant
I need to make single tool calls. Let me be careful.
Assistant
Interesting, the table.ts doesn't have an
addAttributesmethod, but it does referencenode.attrs.stylein TableView.ts. Let me check where thestyleattribute is defined for the table node. It seems the table node inherits from a base table node. Let me look at the deprecated extension-table package to understand the original behavior, and also check whereattrs.stylecomes from.Actually, the table.ts doesn't define
addAttributesfor the table node itself. Thenode.attrs.styleis referenced in TableView.ts. So there must be a defaultstyleattribute. Let me search more broadly.Assistant
I'll make single tool calls only.
Assistant
Now I understand the structure. Let me look at the existing tests to understand how the codebase is tested, especially the colgroupUpdate test which likely tests TableView.
Assistant
Now I understand the test setup uses jsdom. Let me check the vitest config to confirm jsdom is used.
Assistant
Tests use happy-dom. Now let me understand the issue fully. The
renderHTMLmethod mergesthis.options.HTMLAttributesinto the table element, butTableView(used byaddNodeView) doesn't apply these attributes.Let me write a reproduction test first.
Assistant
I've reproduced the bug. The
<table>element has no class. Now let me fix theTableViewto apply theHTMLAttributes.The key challenge:
TableViewconstructor currently takes(node, cellMinWidth), butaddNodeViewcalls it with(node, this.options.cellMinWidth, view). ThecolumnResizingplugin also uses theViewoption. I need to passHTMLAttributesto theTableView.Let me look at how the
Viewoption is typed and howcolumnResizinguses it, to make sure I don't break the resizable path.Assistant
Let me look at how the
columnResizingplugin (prosemirror-tables) instantiates the View, to understand the resizable path.Assistant
So the
columnResizingplugin callsnew View(node, defaultCellMinWidth, view)with 3 args. The resizable path uses this View directly and it's the same defaultTableView. So the resizable path would ALSO not apply HTMLAttributes.But the issue specifically mentions the regression for resizable: false. Let me check what 3.22.4 did - in 3.22.4 there was no addNodeView, so for resizable: false it fell back to renderHTML. For resizable: true, it used the columnResizing plugin's View (TableView), which never applied HTMLAttributes in either version. So the resizable: true case was always broken for HTMLAttributes? Actually, let me re-read the issue.
The issue is specifically about resizable: false. The expected behavior says "regardless of the resizable setting". But the regression is specifically the non-resizable case since resizable: true always used the TableView via columnResizing.
Let me focus on fixing the non-resizable case primarily (the regression), but ideally also make the resizable case work. However, modifying the resizable case is harder because the columnResizing plugin instantiates the View with only 3 args.
Assistant
Let me check the git history to understand the regression.
Assistant
Let me check where the table node's
styleattribute is defined, sincenode.attrs.styleis referenced in TableView.Assistant
Let me check if there's an existing helper in @tiptap/core for applying attributes to DOM elements.
Assistant
Let me check if there's an existing utility to apply attributes to a DOM element in core.
Assistant
Let me look at how the columnResizing plugin uses the View result, to ensure a wrapper function approach is safe.
Assistant
Let me test whether the resizable case also has the issue, by adding a resizable test to my repro.
Assistant
Both resizable false and true are broken. Now let me implement the fix. First, the TableView.ts.
Assistant
Now let me edit the TableView.ts to add a helper and modify the constructor.
Assistant
Now let me apply the changes to TableView.ts using the editor. First, the imports.
Assistant
Now let me edit the imports and add the helper function:
Assistant
Now let me update the constructor. Let me view the constructor lines now.
Assistant
There's a missing blank line after the constructor (line 193-194). Let me fix the formatting.
Assistant
Now let me update table.ts. First the View type signature:
Assistant
Now let me update
addProseMirrorPluginsandaddNodeView. Let me view those sections.Assistant
Let me check the type that
columnResizingexpects for theViewoption.Assistant
Now let me add a module-level helper function and update the two methods. First, let me add the helper before the
Tableexport.Assistant
I see a duplicated comment block. Let me fix lines 294-299.
Assistant
Let me check the spacing between the
declare moduleblock and the helper function.Assistant
I need a blank line between line 255
}and the/**comment. Let me fix.Assistant
There's a duplicate comment line (258-259). Let me fix.
Assistant
Now let me update
addProseMirrorPluginsandaddNodeView. Let me view their current line numbers.Assistant
Now let me update the
addNodeViewreturn to pass HTMLAttributes:Assistant
Let me check the lint configuration to ensure the
_viewunused param won't cause issues.Assistant
Let me run the repro tests first to verify the fix works.
Assistant
Both cases now work — the
<table>hasclass="my-custom-table"andstyle="min-width: 50px;". Now let me test edge cases: a customstylein HTMLAttributes and theView: nullworkaround. Let me expand the repro test.Assistant
All edge cases pass. Now let me run the existing extension-table tests to make sure I didn't break anything.
Assistant
All existing tests pass. Now let me remove my repro test file before submitting, and run the linter on the changed files.
Assistant
Lint passes with 0 errors. Now let me check the type-checking for the package.
Assistant
No typecheck script for the package. Let me run a TypeScript check via the root tsconfig on the file, or build. Let me try running tsc --noEmit on the package to verify types. Actually, let me check the root typecheck command.
Assistant
Two TypeScript errors to fix in the
withHTMLAttributeshelper. Let me fix the closure narrowing and the cast.Assistant
The edit corrupted the function structure. Let me fix it by replacing the broken section.
Assistant
Need a blank line between line 295
}and the comment.Assistant
Now let me re-run the TypeScript check to confirm the errors are resolved.
Assistant
TypeScript errors are resolved. Let me run the full typecheck to make sure nothing else broke elsewhere.
Assistant
The remaining errors are all in unrelated test files and
vitest.config.ts(pre-existing), none in my changed files. Let me run the extension-table tests once more to confirm everything still passes without the repro file.Assistant
All tests pass. Let me also run the lint on the changed files once more and check the formatting with oxfmt.
Assistant
There are formatting issues. Let me run oxfmt to fix them.
Assistant
Formatting is fixed. Let me verify the final state of both files and confirm tests still pass after formatting.
Assistant
Let me check the
_viewparam — oxfmt kept it as_view. The lint passed. Good. Let me also verify the full helper function and addNodeView after formatting.Assistant
Let me run the extension-table tests once more after the formatting changes to be sure.
Assistant
Let me check the changeset convention and add one, as the repo uses changesets.
Assistant
Now let me do a final review of the complete diff.
Assistant
Let me refine the edge case for boolean
falseattribute values (should be skipped, matching typical DOM attribute semantics). Let me view the current helper.Assistant
The file shown is table.ts, not TableView.ts. The replace command edits the currently open file (table.ts). Let me open TableView.ts first, then use the edit command.
Assistant
Now let me re-run formatting, lint, typecheck, and tests to confirm everything is still good.
Assistant
There's a TS error in
extension-collaboration-caret's test about no default export from extension-table. Let me check if this is pre-existing (unrelated to my change) by stashing.Assistant
This test imports
Tableas a default import from@tiptap/extension-table, but the package only has named exports. Let me confirm this is pre-existing and unrelated to my change by stashing my changes.Assistant
Confirmed — that error is pre-existing and unrelated to my changes. Let me check the TableKit to ensure it doesn't override
addNodeView/Viewin a way that bypasses my fix.Assistant
Let me quickly check the deprecated table packages to see if they have the same
addNodeViewpattern that might also need fixing.Assistant
Only the
@tiptap/extension-tablepackage hasaddNodeViewfor the table. The deprecated packages don't have addNodeView (they use the old approach via columnResizing View only, or renderHTML). So my fix is complete for the affected package.Let me double-check the deprecated table packages to understand if they have a separate TableView that uses HTMLAttributes. Actually, the issue is specifically about
@tiptap/extension-table3.23.x. The deprecated packages (extension-table-row, extension-table-cell, etc.) are the old split packages. There's no deprecatedextension-tablewith addNodeView. Let me verify there isn't a deprecated extension-table with the bug.Assistant
Let me write one final verification matching the exact issue reproduction (using
contentwith a table HTML string) to be thorough, then clean up.Assistant
The exact issue scenario (initial content with a table) now works for both resizable settings. Let me clean up the temporary test file.
Assistant
Let me do a final review of the complete diff and run the full extension-table test suite one last time.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.