contentful / field-editors

React components and extensions for building Contentful entry editor
https://contentful-field-editors.netlify.app/
MIT License
150 stars 114 forks source link

fix: rich text link copy to google docs [TOL-1647] #1544

Closed YvesRijckaert closed 7 months ago

YvesRijckaert commented 7 months ago

Description

After merging https://github.com/contentful/field-editors/pull/1542 , copy pasting rich text content with links behaved differently. Before, a link would get copied over successfully. Afterwards, a link would not get copied anymore and it would include the link separately. This PR fixes that.

Screenshot 2023-11-17 at 12 39 03

Ticket: https://contentful.atlassian.net/browse/TOL-1647

How?

I render the edit link popover component with a portal. This introduces some issues with positioning. First of all, we have to now check when the popover component should be displayed. It will only display when the editor is focussed and the caret is inside a link OR when the mouse interacts with the popover. I've also changed the Text to TextLink in the rich text editor, which will make sure that when an editor copies over the content, it will be copied over as a link.