-
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
Basic External Copy + Paste for Tables #1579
Conversation
This pull request is being automatically deployed with Vercel (learn more). lexical – ./packages/lexical-website🔍 Inspect: https://vercel.com/fbopensource/lexical/6pTh45uXhr24RYGFowvTBoAncNtG lexical-playground – ./packages/lexical-playground🔍 Inspect: https://vercel.com/fbopensource/lexical-playground/8YLo3nwh4G4HURnxXww3jJzBXFEA lexical-website-new – ./packages/lexical-website-new🔍 Inspect: https://vercel.com/fbopensource/lexical-website-new/ANwraFA6zwXE2G4LBnPZxvXHis7J |
lexicalNodes.push(currentLexicalNode); | ||
for (const [, forChildFunction] of forChildMap) { | ||
forChildFunction(currentLexicalNode); | ||
const mapChildFunc = parentNode && forChildMap.get(parentNode.nodeName); |
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.
I think it needs to run for all children because of things like <strong> where you want to apply some mutation to evert text node descendant (i.e., make them bold).
27f8859
to
198c459
Compare
forChildFunction(currentLexicalNode); | ||
currentLexicalNode = forChildFunction( | ||
currentLexicalNode, | ||
parentLexicalNode, |
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.
You need this because you can't derive the parent from the currentNode because it hasn't been appended yet?
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.
Yeah, exactly. Do you think that's too confusing?
currentLexicalNode.getParent()
evaluates to null, so there's no way to derive the hierarchy.
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.
Maybe we should have a special type for DetachedLexicalNode
? That way you know certain methods won't work.
…nt rendered instead
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.
This looks good to me. Thanks!
* Basic External Copy + Paste * Fix paste CodeBlock * Handle CodeBlock TableRows with noop conversion so core TableRows arent rendered instead
This PR adds Copy + Paste support for Tables coming from Google Docs, Quip, and Google Sheets. There are tests to back it up.
The
forChild
function now returns a node which gives the developer the control to skip a child, replace the node, modify the node, or do nothing, for each child. This is useful for TableCells which should have all text wrapped in inner paragraph block, but some external sources (such as Quip) do not nest text in paragraphs.There was also a small bug (?) where the forChild function would run for all children of the parent, not just immediate children. I changed the API to only run the forChild function from it's direct parent.