-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: inserting a table from external resources lead Lexical crash #5871
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I think I can avoid the Lexical crash by wrapping Paragraph around elements other than paragraphs
This is correct, text should never be a top-level element, which does apply in this case because TableCell is a ShadowRoot. However, instead of adding a custom table cell, which will be hard to replicate by others, I would explore why this happens and whether insertNodes can do this for us as it doesn't happen for the RootNode.
const CustomTableCell = 'customTableCell'; | ||
const PIXEL_VALUE_REG_EXP = /^(\d+(?:\.\d+)?)px$/; | ||
|
||
export class CustomTableCellNode extends TableCellNode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this file be named CustomTableCellNode instead of TableCellNode?
i wonder what html is being copied onto the clipboard. i would be curious to know what (or if theres any) dom element wrapping the text node that results in it being a top level element to table cell. do u mind sharing what html is being copied to clipboard? u may inspect that by downloading pasteboard: https://github.com/sindresorhus/Pasteboard-Viewer (i learnt this from @zurfyx , thanks for sharing this useful tool!) lastly good job debugging and finding the root cause! |
Thanks for the review and for suggesting a better solution. I'll give it a try. |
@potatowagon of course here the html
|
#5857 may fix this as tgat PR would wrap inline text nodes in a paragraph if theres nothing between the inline node and the root (or shadow root in this case for will be testing your case on that pr |
just realised this is the copied html of the table in lexical editor, could u share instead the copied html after copy from the external app? |
You're right, what I got before was the html after saving on lexical, I think the following is the original pasted html.
|
I wonder if the crash is fixed by #6139 since the example here all have TBODY tag, which we didn't respect in the TableObserver. Thoughts @potatowagon @zurfyx ? |
afaik this issue is solved already what could have fixed the crash was text nodes inside of a |
closing since this issue is solved |
Fix #5812

Before:
see #5812
After:

reason for crash: When press Enter the program gets stuck in a dead loop while checking for INTERNAL_$isBlock(node).
I haven't thought of a suitable way to fix the problem in lexical or lexical/table, but I think I can avoid the Lexical crash by wrapping Paragraph around elements other than paragraphs, lists, code blocks, Quote in the playground.
Please let me know if there have a better solution.