[lexical-table][lexical-playground] Feature: nested tables resize themselves if hasFitNestedTables: true#8183
Conversation
…sform instead of recursion
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| * @returns The horizontal insets of the cell, in pixels. | ||
| */ | ||
| function $calculateCellInsets(cell: TableCellNode) { | ||
| function $calculateCellHorizontalInsets(cell: TableCellNode) { |
There was a problem hiding this comment.
I was thinking of exporting this, and $getCellWidth, so that a similar pattern could be used for things like ImageNodes (basically, any node that can be resized)?
There was a problem hiding this comment.
Adding exports is fine as long as the functions are suitable for being maintained as public API, or marked as @internal
There was a problem hiding this comment.
Updated to expose $getCellWidth. This specific function ($calculateCellHorizontalInsets) is now a user-specified callback and no longer needs to be exported.
|
Haven’t looked at the code but node transforms run before the DOM is updated so layout can’t be (correctly) calculated at that time. At best you can read the previously rendered DOM, but there are some big edge cases when you are working with a different version of the document. |
…provided as a prop
|
I've gone ahead and added a property to the extension I don't love that you need to provide both properties for this to work, so it might make sense to pull this out to another plugin. |


Description
#8097 implemented nested table fitting when inserting tables. However, beyond the initial insertion, it didn't handle the nested table itself changing width (1), or the surrounding cell changing width (2).
This PR changes the original implementation to a Node Transform, which handles (1).
To handle (2), the simplest approach is to mark all child tables as dirty when a column resize event occurs, so that the transform fires. I tried to do this with a Transform as well, but had issues getting it to terminate. Open to alternative ideas.
Test plan
Before
Screen.Recording.2026-02-27.at.6.16.29.pm.mov
After
Screen.Recording.2026-02-27.at.6.10.55.pm.mov