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 pasting #4700

Merged
merged 9 commits into from
Jan 8, 2024
Merged

Fix/link pasting #4700

merged 9 commits into from
Jan 8, 2024

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Dec 15, 2023

Please describe your changes

This PR fixes issues with paste handling and autolinking with the current version of the Link extension. I refactored the pasting and autolink plugins, reverted my changes from a few months ago to the one before and updated this to support all cases I wanted to fix back then.

To make my changes happen I had to add the clipboard event to the PasteRule handlers. I think this could also be benefitial for other users in the future.

How did you accomplish your changes

  1. Update the PasteHandler to pass through the clipboard event
  2. Use the clipboard event to get pasted link data via DOMParser
  3. Insert pasted links including their original URLs into the specific positions of the editor
  4. Updated autolink to work with this new approach

How have you tested your changes

I added necessary tests - but you can also check the feature on the Link preview

How can we verify your changes

I added necessary tests - but you can also check the feature on the Link preview

Checklist

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

Related issues

closes #4627
closes #4541
closes #4484
closes #3634

@bdbch bdbch self-assigned this Dec 15, 2023
Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 8ba30f3
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/659bdcbaad3efb0008554272
😎 Deploy Preview https://deploy-preview-4700--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 configuration.

@duhaime
Copy link

duhaime commented Dec 18, 2023

@bdbch looks like there are some failing tests, have you looked into those?

@bdbch
Copy link
Contributor Author

bdbch commented Jan 2, 2024

Just figured out that there a few small bugs with link pasting and validation when using the validate option. I now work on this and will probably get this out too tomorrow.

@C-Hess
Copy link
Contributor

C-Hess commented Jan 3, 2024

Looking at this, it looks like it would resolve the need for #4587 as well?

@bdbch
Copy link
Contributor Author

bdbch commented Jan 8, 2024

@C-Hess I think it does. I'll check again afterwards

@bdbch bdbch merged commit eaee9c7 into main Jan 8, 2024
14 checks passed
@bdbch bdbch deleted the fix/link-pasting branch January 8, 2024 11:50
Copy link
Contributor

@stevobm stevobm left a comment

Choose a reason for hiding this comment

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

Wish to fix the bug caused from here.

@@ -26,6 +26,10 @@ export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode):
})
} else {
doc.nodesBetween(from, to, (node, pos) => {
if (!node || node.nodeSize === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change caused a bug: #4785

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

Successfully merging this pull request may close these issues.

4 participants