Fix onPaste handling in link extension in rc.4 #4072
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe your changes
The link extension mistakenly inserted pasted content at wrong position in rc-4
tiptap/packages/extension-link/src/helpers/pasteHandler.ts
Line 74 in 0e2df9d
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
<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