[lexical-link] Feature: Merging two identical links into one node#8168
Open
Jynx2004 wants to merge 17 commits intofacebook:mainfrom
Open
[lexical-link] Feature: Merging two identical links into one node#8168Jynx2004 wants to merge 17 commits intofacebook:mainfrom
Jynx2004 wants to merge 17 commits intofacebook:mainfrom
Conversation
…e $createParagraphNode
Removed unnecessary checks and code related to text node styles.
…exical into table_selection_issue
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Feb 25, 2026
Collaborator
etrepum
left a comment
There was a problem hiding this comment.
I don't think this code will work correctly and it has no tests
Comment on lines
+257
to
+260
| return ( | ||
| parentElementAfter.getType() === 'link' && | ||
| parentElementAfter.getType() === parentElementBefore.getType() | ||
| ); |
Collaborator
There was a problem hiding this comment.
This isn't an acceptable approach. @lexical/clipboard can't depend on @lexical/link, and you can't use getType to check the type of a node since nodes can be subclasses with a different type.
Comment on lines
+271
to
+281
| const textNodes = nodes.filter((node) => $isTextNode(node)); | ||
|
|
||
| if (textNodes.length > 0) { | ||
| const firstText = textNodes[0]; | ||
| selection.insertText(firstText.getTextContent()); | ||
| $updateSelectionOnInsert(selection); | ||
| } | ||
| } else { | ||
| selection.insertNodes(nodes); | ||
| $updateSelectionOnInsert(selection); | ||
| } |
Collaborator
There was a problem hiding this comment.
This doesn't look correct since all other nodes will be discarded if one TextNode exists. It also ignores any formatting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In this approach when a user tries to paste any text inside the link , then the text gets injected inside the text of the link directly instead of creation of new TextNode in between the link thus dividing the text of the same link into 2 halfs . This prevents creation of 2 same links .
Closes #8150
Test plan
Before
After