Open GermanJablo opened 2 months ago
- Create a new ElementNode called TableWrapper or something like that.
- Use DecoratorElementNode if this PR ends up being approved: https://github.com/facebook/lexical/pull/5981
- Use a DecoratorNode. Inside, you could use a nested lexicalEditor that only contains a table,
I have no faith that option 2 will ever materialize, and even then I don't think it would be the best option.
A DecoratorNode would introduce quite a bit of complexity (nested editors, new boundaries in the selection, problems with the undo manager, etc.).
I think the best thing to do would be to add a TableWrapperNode
of type ElementNode which renders as a div
.
We could easily force the schema in a backwards-compatible way using lexical transforms.
If the Lexical team agrees with the solution and is interested, I will implement it in their repository, if not, I will do it in ours.
What do you think, @AlessioGr?
Should we close this @GermanJablo ?
not yet. The linked PR is a temporary solution. But I'm campaigning to finish this soon
Link to reproduction
https://github.com/payloadcms/payload
Environment Info
Describe the Bug
Incorrect behaviors
Having tables overflow is a mistake, as their content can conflict with other elements of the interface, as is now happening in Payload.
Another incorrect behavior is the one that occurs in the Lexical Playground, where if the table is too large, the entire editor becomes larger. The horizontal scroll bar is not placed over the table, but over the entire content.
A half-way solution
A super quick way to fix overflow is to add a max-width of 100% to the table.
The problem is, as this user noted, that this creates conflicts with the column width property.
This is what OneNote does and I've always hated it. Sometimes columns resize in a magical or hard-to-understand way. It's better to give the user the flexibility to adjust column widths to their liking and to have overflow if needed.
The correct solution
The correct solution to this is for tables to have an overflow scroll independent of the rest of the editor, similar to what Notion does:
The problem is that the
<table>
tag doesn't support overflow: scroll. A div is needed to wrap it.There is an issue opened on Lexical with recent movement about this Issue: https://github.com/facebook/lexical/issues/6480
The solution will have to be:
Reproduction Steps
It can be reproduced anywhere with a Lexical editor. But the problem is more evident when there is a field with a sidebar position as in the image, since the elements overlap.
Adapters and Plugins
No response