Enhance URL Replacement Functionality to Update Display Text When Pasted Over a Link
Description
There is an unexpected behavior when trying to replace a link whose display text matches the URL. Currently, if a user pastes a new URL into a link where the display text is identical to the original URL, only the URL is updated while the display text remains unchanged. This causes confusion and seems counterintuitive to the expected behavior.
Steps to Reproduce
- Create a link where the display text is equal to the URL (e.g., display text and URL both are "http://example.com").
- Highlight the link.
- Paste a different URL using Ctrl + V (e.g., "http://newlink.com").
Expected Behavior
The display text should be updated to the new URL (e.g., display text becomes "http://newlink.com").
Actual Behavior
The display text remains as the old URL (e.g., display text stays "http://example.com"), while the URL changes to the new one.
Proposal
Implement a check that updates the display text to match the pasted URL if the original display text was the same as the original URL. This will align user expectations with the behavior of the editor.