-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Bug]: Wrong link on paste with hard break #5679
[Bug]: Wrong link on paste with hard break #5679
Comments
Same issue. Reproduce issue on: https://templates.tiptap.dev/cqgCzK9LLr Video: Screen.Recording.2024-11-19.at.16.49.00.mov |
It's likely this bit of code here which is trying to get all of the pasted content as a string to see what can be linked: tiptap/packages/extension-link/src/helpers/pasteHandler.ts Lines 24 to 29 in ff6e00a
I would be happy to accept a contribution here. I think that all that needs to be done is to append a newline to each node.textContent added, so that when we look for links, it will not try to include the next word as the link. I just don't have time to work on this at the moment & validate it. Would appreciate your help here @iropolo & @Ste35 |
Huh I spend some time I take a look into these files -> tiptap/packages/extension-link/src/link.ts Lines 346 to 349 in 86250c6
-> tiptap/packages/core/src/PasteRule.ts Line 180 in 86250c6
-> tiptap/packages/core/src/pasteRules/markPasteRule.ts Lines 22 to 26 in f8961a9
Somewhere in Process:
At the beginning, the node looks like: (in Then, it starts the process of: tiptap/packages/core/src/PasteRule.ts Lines 122 to 124 in 86250c6
This will be run twice, 1 for each node: These are the console.logs of tiptap/packages/extension-link/src/link.ts Lines 346 to 349 in 86250c6
First return: -> Second return: -> Finally the second node content seems to be unifed: 2 nodes. I managed to ->
I update tiptap/packages/extension-link/src/helpers/pasteHandler.ts Lines 25 to 29 in 86250c6
To include a newline and this is the result (console.log of Seems to looks ok in console.log() but the final result get transformed... seems the process go further. Sorry if I get confused with the process or misunderstand it. |
Hey @Ste35 we have identified the root cause of this issue and will be fixed with the next release of the |
I believe this problem has not been resolved eu.-.Chat.-.Google.Chrome.2024-12-02.22-43-36.mp4 |
Hey @GiuseppeFantoni we haven't released the fix yet, we will do it soon as we're gathering more fixes so we batch some of them :) We have upstreamed this to Linkify and they will fix it on their end so in the meantime we will have the fix applied on our end |
@alexvcasillas Hi, Good morning, do we have any expectation of when this issue will be fixed? |
Affected Packages
extension-link
Version(s)
2.6.6
Bug Description
Hi, I'd like to report a possibile bug that occurs when pasting a link with a new line separated by an hard break (I hope it's not a duplicate!).
When coping and pasting together:
br
)the pasted link "extends" to the first word of the following line and the link pasted is incorrect:
(in this case, the pasted link will be
https://google.comThis
)The problem doesn't show up if the two lines are in different paragraphs:
You can also see the same issue in the Tiptap public demo: https://templates.tiptap.dev/
Is this an actual issue or am I missing something?
Thank you for your work!
Browser Used
Chrome
Code Example URL
https://stackblitz.com/edit/react-xqt1gu?file=src%2FApp.js
Expected Behavior
The copied link and the following line should be kept as in the original source.
Additional Context (Optional)
No response
Dependency Updates
The text was updated successfully, but these errors were encountered: