Skip to content
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

fix(extension-link): fix link not being kept when pasting url with link #3975

Merged
merged 8 commits into from
Apr 26, 2023

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Apr 19, 2023

Please describe your changes

This PR fixes an issue where for example a link gets copied from another richtext (for example Google Docs). When the copied text is a URL (for example https://github.com/) but this URL text is already a link (for example https://github.com/ == LINKS TO ==> https://github.com/my/repo) the link gets dismissed and the text gets pasted as a URL.

How did you accomplish your changes

I removed the default pasteHandler as the paste handler will always trigger before any custom logic. The paster handler itself also doesn't know about any marks of the pasted content but only the content text so it wasn't possible to handle the check if a pasted content is already a link in there.

I moved the logic into it's own plugin that will handle said behavior.

How have you tested your changes

I created a Google Docs file with two lines. The document looked like this:

When copying the first line, the pasted content was:

tiptap.dev (linking correctly to https://tiptap.dev/hello as defined in the Google Doc)

When copying the second line, the pasted content was:

https://tiptap.dev (linking to https://tiptap.dev - this was done via the autolink paste handler)

How can we verify your changes

Clone and checkout this branch, then create a demo (or use the existing Marks/Link demo) and paste in content as I described above.

Remarks

Nothing to remark here

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Related issues

  • No relating issues

@bdbch bdbch requested a review from svenadlung April 19, 2023 08:25
@bdbch bdbch self-assigned this Apr 19, 2023
@netlify
Copy link

netlify bot commented Apr 19, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 7084cd2
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/6448ed36ca85570008ae1784
😎 Deploy Preview https://deploy-preview-3975--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@svenadlung svenadlung left a comment

Choose a reason for hiding this comment

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

Was testing some cases. Worked out well for me. Good work 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants