Skip to content
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

Floating link editor for AutoLinkNode and conversion to LinkNode once modified. #5536

Merged
merged 11 commits into from
Jan 25, 2024

Conversation

HarrySIV
Copy link
Contributor

This PR fixes #4202 as well as satisfies @zurfyx request in #4203 to have the AutoLinkNode be converted to a LinkNode once modified in the floating link editor toolbar.
I saw multiple closed PR's for this and it looked like it was still an issue no one was currently working on.
Please let me know if there's anything I need to change, I know the conversion logic is kind of ugly.

Copy link

vercel bot commented Jan 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2024 4:01pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2024 4:01pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 24, 2024
Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Added a minor comment, seems like there's a merge conflict as well if you can look at this before we merge

Comment on lines 200 to 202
}).append($createTextNode(parent.getURL()));
parent.getParent()?.append(linkNode);
parent.remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use replace instead, guarantees the correct position with the best performance.

  1. Replace the parent: parent.replace(linkNode)
  2. Move the children: traverse all the children in parent and append them into linkNode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using .replace() and it kept crashing my browser but I'll try again

@HarrySIV
Copy link
Contributor Author

Sorry about that @zurfyx, ran into some weird issues after having to rebase the branch due to the changes to main. Should work perfectly fine and as intended now.

@zurfyx
Copy link
Member

zurfyx commented Jan 25, 2024

LGTM, thanks Harry!

@zurfyx zurfyx merged commit ba901cc into facebook:main Jan 25, 2024
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Floating link editor doesn't show up for AutoLinkNode
3 participants