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(link): fix links autolinking when not needed #3989

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Apr 27, 2023

Please describe your changes

This PR changes the autolink behavior. Before links were always autolinked, even when the autolinked text was already a link. This is weird behavior - as a manually / already set link should always have priority over automatically linked content.

Example:

You have a link that has the textContent mysite.com but a link mark with a href attr to https://mysite.com?ref=my-referral-id the autolink prior to this PR would still autolink to mysite.com completely removing any manually set attributes.

How did you accomplish your changes

Right before the autolink would set the link mark on words with spaces/breaks I added a check to see if the link.from and link.to already has a link mark inbetween. If so we just avoid autolinking to keep the already existing link.

How have you tested your changes

  • Local link demo

How can we verify your changes

  1. Check out this PR
  2. Open the Link demo
  3. Paste links / set links manually with urls as a textcontent and run autolinking on them.

Checklist

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

@bdbch bdbch requested a review from svenadlung April 27, 2023 09:24
@bdbch bdbch self-assigned this Apr 27, 2023
@netlify
Copy link

netlify bot commented Apr 27, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 25ae4ee
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/644a3f4bcb4dd800082a1700
😎 Deploy Preview https://deploy-preview-3989--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.

@bdbch bdbch merged commit 71946c1 into develop Apr 27, 2023
14 checks passed
@bdbch bdbch deleted the feature/link-autolink-fix branch April 27, 2023 10:02
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.

None yet

2 participants