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
Let me start by exploring the repository structure to understand the codebase and locate the relevant files for the Table extension.
Assistant
Let me look at the main files related to the issue - the TableView and the table extension.
Assistant
Let me look at the table/index.ts file which likely contains the extension definition with addNodeView.
Assistant
Let me see the table.ts file which should contain the main Table extension definition.
Assistant
Now let me see the TableView.ts file to understand how it renders the table and how HTMLAttributes should be applied:
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/extension-table/src/table/TableView.ts </tool_call>
Assistant
The previous command failed because I used the wrong tool. Let me use bash_terminal to see the TableView.ts file.
Assistant
Now I understand the issue:
- In
Tableextension'saddNodeView()method, whenresizableis false (the default), it returns a NodeView that usesTableView. TableViewconstructor creates the DOM manually and only appliesnode.attrs.styleto the table element, but it never appliesthis.options.HTMLAttributesfrom the extension configuration.- In contrast, the
renderHTMLmethod in the same Table extension correctly appliesthis.options.HTMLAttributesusingmergeAttributes.
The fix should be to:
- Update the class to accept option.
- In
Assistant
I need to fix the command syntax - I forgot to use the bash_terminal tool properly. Let me try again with the proper tool.
Assistant
Let me check if there are existing tests for the table extension to understand how to test my changes.
<tool_call> <function=bash_terminal> <parameter=command> ls -la /tiptap/packages/extension-table/tests/ </tool_call>
Assistant
Let me try a different approach - just run the bash_terminal command without any special syntax.
Assistant
Now I understand the issue. Let me look at the TableView class more carefully. The problem is:
TableViewis created withnew View(node, this.options.cellMinWidth, view)TableViewconstructor doesn't receiveHTMLAttributesoption- The constructor only applies
node.attrs.stylebut never appliesthis.options.HTMLAttributes
The fix needs to:
- Pass
this.options.HTMLAttributesto theTableViewconstructor - Apply those attributes to the table element
Let me look at how the NodeView factory is called in ProseMirror:
Assistant
Now let me see the full
addNodeViewmethod implementation:<tool_call> <function=bash_terminal> <parameter=command> sed -n '/addNodeView/,/^ },/p' /tiptap/packages/extension-table/src/table/table.ts </tool_call>
Assistant
The issue is that my command isn't being executed properly. Let me try a simpler command to verify the terminal is working.
Assistant
Now I understand the issue clearly. Let me implement the fix. I need to:
- Modify the
TableViewconstructor to acceptHTMLAttributes - Apply those attributes to the table element
- Pass
this.options.HTMLAttributeswhen creating theTableViewinstance inaddNodeView
Let me first apply the fix to
TableView.ts:- Modify the
Assistant
Let me look at the original TableView.ts again and make the fix properly:
Assistant
The temporary file shows the changes I made. Now I need to apply these changes to the actual file and also update the
addNodeViewmethod intable.tsto pass the HTMLAttributes to the TableView.Assistant
The command still isn't working. Let me check if there's something wrong with how I'm formatting the command.
Assistant
The command worked this time. Now let me verify the file was updated correctly.
Assistant
Good, the TableView.ts file has been updated. Now I need to update the
addNodeViewmethod intable.tsto pass theHTMLAttributesto theTableViewconstructor.Assistant
Now I need to update the
addNodeViewmethod intable.tsto passHTMLAttributesto theTableViewconstructor.Assistant
The sed command completed successfully. Let me verify the change was applied correctly.
Assistant
Good, the change was applied correctly. Now let me verify the whole table.ts file is correct and check if there are any TypeScript issues. First, let me check if there's a build process for the extension-table package.
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/extension-table/package.json </tool_call>
Assistant
Let me use the correct command to view the package.json file.
Assistant
Let me now try to build the extension-table package to check if there are any TypeScript errors.
<tool_call> <function=bash_terminal> <parameter=command> cd /tiptap/packages/extension-table && npm run build </tool_call>
Assistant
The command is not being executed properly. Let me try again with the correct syntax.
Assistant
I see two issues:
-
src/table/TableView.ts(2,15): error TS2724: '"@tiptap/core"' has no exported member named 'HTMLAttributes'. Did you mean 'Attributes'?- I used the wrong import name. It should be
Attributesinstead ofHTMLAttributes
- I used the wrong import name. It should be
-
src/table/table.ts(534,80): error TS2554: Expected 3 arguments, but got 4.- The TableView constructor is defined with 3 parameters, but I'm passing 4
Let me fix these issues. First, let me check what's the correct type to import from @tiptap/core.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "HTMLAttributes" /tiptap/packages/core/src/ | head -20 </tool_call>
-
Assistant
I need to find the correct export from @tiptap/core. Let me search for it.
Assistant
Let me check the types.ts file to see what's exported:
Assistant
I see that
HTMLAttributesis a type defined in the extension config, but it's not directly exported from@tiptap/core. Let me check how other files handle this:Assistant
Let me check the NodeView.ts file more thoroughly:
Assistant
I see. The
HTMLAttributesis defined as a type property within the NodeViewRendererProps, not as a standalone exported type. Let me look at the types.ts file to understand the structure better.Assistant
I see that
HTMLAttributesis actuallyRecord<string, any>in the type definition, not a standalone export. Let me fix both issues - the type import and verify the constructor signature.Assistant
I need to fix the import.
HTMLAttributesis not exported from@tiptap/core, but the type isRecord<string, any>. Let me update the file.Assistant
Now let me check the constructor and update the type parameter:
Assistant
Now I need to change the type of
htmlAttributestoRecord<string, any>instead ofHTMLAttributes.I'll use the sed command to replace the type. The current line has
htmlAttributes: HTMLAttributes = {}, and I need to change it tohtmlAttributes: Record<string, any> = {}.Assistant
Now let me rebuild to check if the TypeScript errors are fixed.
Assistant
Good progress! The HTMLAttributes import error is fixed. Now there's still the error about the constructor expecting 3 arguments but getting 4. This is because the TypeScript definition file (.d.ts) that was previously generated still has the old constructor signature (3 parameters).
The issue is that when I added the 4th parameter to the constructor, TypeScript is generating type declarations that expect 3 arguments in some cases (probably from the NodeView interface or some other source).
Let me look at the generated .d.ts file to understand what's happening:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 10 "constructor" /tiptap/packages/extension-table/dist/table/index.d.ts | head -30 </tool_call>
Assistant
The command still seems to have issues. Let me try running it directly.
Assistant
The file wasn't generated because of the build error. Let me check the current source code to see if the constructor signature is correctly updated:
Assistant
Let me check the NodeView interface to see if there's a constraint on the constructor signature:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 30 "interface NodeView" /tiptap/packages/extension-table/node_modules/@tiptap/pm/view/dist/index.d.ts </tool_call>
Assistant
The command is not working properly. Let me try a different approach - checking the NodeView interface from prosemirror-view.
Assistant
Let me find the correct path for the prosemirror view package:
Assistant
Let me check the NodeView interface in the extension-table package's pm/view:
Assistant
Let me check what's in the index.ts file.
Assistant
This means the NodeView type is coming from the prosemirror-view package. The interface doesn't specify constructor parameters - it just specifies the methods that should be implemented.
The TypeScript error is likely happening because tsup is generating d.ts files and the TypeScript compiler is checking the code again. Let me check the exact error location more carefully.
The error says
src/table/table.ts(534,80). Let me look at that line.Assistant
The error indicates TypeScript is expecting 3 arguments but getting 4. This might be because of the way tsup is building the type definitions - it may be checking against the old signature before my changes.
Actually, I think the issue might be that the TableView class implements NodeView interface which might have a specific structure. Let me check what interface TableView is implementing and whether there's any constraint.
Actually, looking at the error more carefully - it says
Expected 3 arguments, but got 4intable.tswhere we callnew View(). This is odd because the TableView constructor now has 4 parameters with the last one being optional.Wait, I think I see the issue. The error could be happening because the generated
.d.tsfiles from a previous build are being checked. Let me clean the dist folder and rebuild.Assistant
Let me try the build again after cleaning the dist folder.
Assistant
I see the issue now. The
Viewtype in theTableOptionsinterface is defined with 3 parameters, but I changed the constructor to accept 4 parameters. Let me update the type definition.Assistant
I need to update the
Viewtype definition in theTableOptionsinterface to include the newhtmlAttributesparameter:Assistant
Now let me rebuild to verify the fix.
Assistant
Now the error is on the opposite side - the TableOptions interface has a
Viewtype that extends a base type somewhere, and the base type only has 3 parameters. The error message says:codeType '(new (node: Node, cellMinWidth: number, view: EditorView, htmlAttributes: Record<string, any>) => NodeView) | null' is not assignable to type '(new (node: Node, cellMinWidth: number, view: EditorView) => NodeView) | null | undefined'.This suggests that the
Viewtype is constrained by an external type definition. Let me search for where this type comes from and see if I can find the base type definition.The error says "Target signature provides too few arguments. Expected 4 or more, but got 3." This is because the base type defines 3 parameters, but my new type has 4.
Let me check where the TableOptions interface is defined and if there's an extending base interface:
<tool_call> <function=bash_terminal> <parameter=command> grep -B5 "View:" /tiptap/packages/extension-table/src/table/table.ts | head -20 </tool_call>
Assistant
The command is not being invoked correctly. Let me try a simpler approach to find where the View type is constrained.
Assistant
I see that the View type is defined as
(new (node: ProseMirrorNode, cellMinWidth: number, view: EditorView, htmlAttributes: Record<string, any>) => NodeView) | null. The error is that TypeScript expects only 3 parameters (withouthtmlAttributes).This issue is happening because the
TableOptionsinterface is extending a baseNodeConfigtype somewhere which definesViewwith only 3 parameters. Let me look at how the Table extension is defined:Assistant
The issue is that
TableOptionsinterface extends from a base type that definesViewwith only 3 parameters. TheNode.create<TableOptions>is checking against the parent interface constraints.Looking at the error more carefully:
codeType '(new (node: Node, cellMinWidth: number, view: EditorView, htmlAttributes: Record<string, any>) => NodeView) | null' is not assignable to type '(new (node: Node, cellMinWidth: number, view: EditorView) => NodeView) | null | undefined'.Assistant
Let me use the correct command to edit the file and make the htmlAttributes parameter optional.
Assistant
Now let me rebuild to verify if the change fixed the issue.
<tool_call> <function=bash_terminal> <parameter=command> rm -rf /tiptap/packages/extension-table/dist && cd /tiptap/packages/extension-table && npm run build </tool_call>
Assistant
The command is not being invoked properly. Let me try running it again.
Assistant
The build succeeded! Now let me verify that the changes are correct by looking at the built files and also checking if there are any edge cases I might have missed.
Let me first verify the changes to the source files:
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/extension-table/src/table/TableView.ts | head -120 </tool_call>
Assistant
Let me try the command again to check the TableView.ts file.
Assistant
Good, the TableView.ts file looks correct. Now let me also check the table.ts file to verify the changes there:
Assistant
Good. Now let me also check the addNodeView method to confirm it's passing the HTMLAttributes correctly:
Assistant
Good! The changes look correct. Now let me run the existing tests to make sure I haven't broken anything.
Assistant
The build succeeded for all packages, including
@tiptap/extension-table. The test command failed due to incorrect flag syntax. Let me run the table extension tests correctly:Assistant
All 44 tests passed. Now let me verify the changes I made are correct and create a summary of what was done.
Let me check the final state of the modified files:
<tool_call> <function=bash_terminal> <parameter=command> cat /tiptap/packages/extension-table/src/table/TableView.ts </tool_call>
Assistant
The command is not being executed. Let me use the bash_terminal tool with the proper syntax.
Assistant
Now let me check the table.ts file to verify the changes there:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 15 "addNodeView" /tiptap/packages/extension-table/src/table/table.ts </tool_call>
Assistant
I need to use the correct tool syntax to run the command.
Let me try again with the bash_terminal command:
Assistant
Great, the changes look correct. Let me also verify the View type definition was updated:
<tool_call> <function=bash_terminal> <parameter=command> grep "View:" /tiptap/packages/extension-table/src/table/table.ts </tool_call>
Assistant
I need to use the correct command syntax to run this command.
Assistant
The changes have been applied correctly. Let me now provide a summary of what was done and submit.
Summary of changes made to fix the bug:
-
/tiptap/packages/extension-table/src/table/TableView.ts:- Added a 4th parameter
htmlAttributes: Record<string, any> = {}to theconstructormethod - Added code in the constructor to apply the
htmlAttributesfromTable.configure()to the<table>element - The implementation properly handles:
classattribute: merges with any existing classesdata-*andaria-*attributes: set directlystyleattribute: merged with existing styles- Other attributes: set directly using
setAttribute
- Added a 4th parameter
-
/tiptap/packages/extension-table/src/table/table.ts:
-
Assistant
I need to use the correct syntax to run git diff command. Let me try again with the bash_terminal tool.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.