Skip to content

[lexical-link] Feature: Enable Selective Removal Within Linked Text#7944

Merged
etrepum merged 4 commits intofacebook:mainfrom
normtronics:7943-enable-selective-removal-within-linked-text
Oct 25, 2025
Merged

[lexical-link] Feature: Enable Selective Removal Within Linked Text#7944
etrepum merged 4 commits intofacebook:mainfrom
normtronics:7943-enable-selective-removal-within-linked-text

Conversation

@normtronics
Copy link
Copy Markdown
Contributor

Description

This PR allows for specific highlighted text to be be unlinked. This fixes when attempting to remove part of a linked word, lexical will remove the link from the entire text rather than just the selected portion. This forces the user to reapply the link to the intended text.

Closes #7943

Test plan

  1. Write some text and select it.
  2. Apply a link to the text.
  3. Select a portion of that.
  4. Try to unlink a portion of the text.
  5. The selected text should be unlinked, not the entire text.

Before

Trying to unlink a portion of the text would cause the entire text to become unlinked.

After

When selecting a portion of the text to unlink, only that portion will become unlinked.

@meta-cla meta-cla 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 Oct 23, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 23, 2025 9:46pm
lexical-playground Ready Ready Preview Comment Oct 23, 2025 9:46pm

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Oct 24, 2025
@etrepum etrepum changed the title [lexical-code] Bug Fix: Enable Selective Removal Within Linked Text [lexical-code] Feature: Enable Selective Removal Within Linked Text Oct 24, 2025
@etrepum etrepum changed the title [lexical-code] Feature: Enable Selective Removal Within Linked Text [lexical-link] Feature: Enable Selective Removal Within Linked Text Oct 24, 2025
Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

This seems fine, it's nice that it doesn't break any existing test expectations and the new behavior has new ones.

Is there some specific editor(s) that this change is inspired by? It seems that most other editors we have looked at don't really have this behavior.

@normtronics
Copy link
Copy Markdown
Contributor Author

@etrepum After switching to Lexical for some clients, they noticed an issue with unlinking portions of text. It became cumbersome when they accidentally linked spaces at the end of a selection because when they tried to unlink just the space, it would remove the link from the entire text instead.

What should have been a one-step process turned into two.

@etrepum etrepum added this pull request to the merge queue Oct 25, 2025
Merged via the queue into facebook:main with commit 9f6c7b3 Oct 25, 2025
42 checks passed
@efjacobson
Copy link
Copy Markdown

Is there some specific editor(s) that this change is inspired by? It seems that most other editors we have looked at don't really have this behavior.

@etrepum thanks for the quick merge. you can see this behavior in ProseMirror, Quill, CKEditor, and the (3rd party, i know) DraftJS link/anchor plugin. the DraftJs plugin being the reason our clients are used to having that functionality

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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Fix: Enable Selective Removal Within Linked Text

3 participants