-
Notifications
You must be signed in to change notification settings - Fork 0
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
[lexical-link] Fix bug when can't remove link formatting from autolink #31
base: main
Are you sure you want to change the base?
[lexical-link] Fix bug when can't remove link formatting from autolink #31
Conversation
Clone of the PR facebook/lexical#6306 |
My review is in progress 📖 - I will have feedback for you in a few minutes! |
Warning Rate limit exceeded@furwellness has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 56 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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 have reviewed your code and found 1 potential issue.
editor.registerCommand( | ||
TOGGLE_LINK_COMMAND, | ||
(payload) => { | ||
const selection = $getSelection(); | ||
if (payload !== null || !$isRangeSelection(selection)) { | ||
return false; | ||
} | ||
const nodes = selection.extract(); | ||
nodes.forEach((node) => { | ||
const parent = node.getParent(); | ||
|
||
if ($isAutoLinkNode(parent)) { | ||
// invert the value | ||
parent.setIsUnlinked(!parent.getIsUnlinked()); | ||
parent.markDirty(); | ||
return true; | ||
} | ||
}); | ||
return false; | ||
}, | ||
COMMAND_PRIORITY_LOW, | ||
), |
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.
The TOGGLE_LINK_COMMAND handler should return true after successfully toggling an AutoLinkNode's unlinked state. Currently, it returns true inside the forEach loop, which doesn't actually return from the command handler. Consider moving the return statement outside the loop to properly indicate that the command was handled.
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
/review |
PR Reviewer Guide 🔍(Review updated until commit 45d9931)
|
Persistent review updated to latest commit 45d9931 |
@coderabbitai review |
Actions performedReview triggered.
|
@coderabbitai review |
Actions performedReview triggered.
|
@coderabbitai full review |
Actions performedFull review triggered. |
No comment from coderabbit |
This PR fixes a bug where a user cannot remove link formatting (unlink) from links created by AutoLinkNode. However, it works for links created by LinkNode. The proposal is to add a flag property in AutoLinkNode to indicate if the link was unlinked. If so, render the link as regular text, keeping styles. The hidden auto-link can become a link again via the Toolbar Link button.
Closes #5607
Test plan
Before
Screen.Recording.2024-06-13.at.15.18.13.mov
After
Screen.Recording.2024-06-13.at.15.20.36.mov
Description by Korbit AI
What change is being made?
Fix the bug that prevents removing link formatting from autolinks by adding support for an
isUnlinked
attribute in theAutoLinkNode
class and updating related logic and tests.Why are these changes being made?
The changes address an issue where users could not remove link formatting from autolinks. By introducing the
isUnlinked
attribute, the system can now handle unlinked autolinks correctly, ensuring that the link formatting can be toggled on and off as needed. This approach maintains backward compatibility and enhances the flexibility of link management within the editor.