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 onPaste handling in link extension in rc.4 #4072

Merged
merged 3 commits into from
May 25, 2023

Conversation

svenadlung
Copy link
Contributor

@svenadlung svenadlung commented May 24, 2023

Please describe your changes

The link extension mistakenly inserted pasted content at wrong position in rc-4

tr.insert(currentPos - 1, node)

This handling was originally reserved for links and not for other types.
A check has been introduced that dispatches the transaction only for pasting links.

It also prevents processing links in onPaste in code blocks.

How did you accomplish your changes

Added a condition to only dispatch insert transaction if pasted content is a link fragment.

How have you tested your changes

  • Copy and paste any type of content (e.g. text). In RC-4 it got inserted at position -1. This should be fixed now.
  • Paste this into a code block: <a href="https://www.google.com">Google</a>

How can we verify your changes

See above and below.

Before:
https://github.com/ueberdosis/tiptap/assets/11420688/6bcc45a6-c226-4859-a1b4-74387d271692

After:
https://github.com/ueberdosis/tiptap/assets/11420688/7da50487-7f54-4d19-b0a3-00c2bb29a5be

Remarks

Still feels like there is some room for optimizations regarding pasting links.

Checklist

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

@netlify
Copy link

netlify bot commented May 24, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 6d6f271
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/646f42724cb3790008806e86
😎 Deploy Preview https://deploy-preview-4072--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.

@svenadlung svenadlung requested a review from bdbch May 24, 2023 18:13
@svenadlung svenadlung self-assigned this May 24, 2023
@svenadlung svenadlung marked this pull request as draft May 24, 2023 18:24
@svenadlung svenadlung marked this pull request as ready for review May 24, 2023 19:25
@svenadlung svenadlung merged commit d19267e into develop May 25, 2023
@nperez0111 nperez0111 deleted the feature/fix-pasting-links branch August 14, 2024 16:27
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