[Bug]: The linkOnPaste
option on extension-link
doesn't behave has expected
#4414
Labels
Category: Open Source
The issue or pull reuqest is related to the open source packages of Tiptap.
Type: Bug
The issue or pullrequest is related to a bug
Which packages did you experience the bug in?
extension-link
What Tiptap version are you using?
2.1.7
What’s the bug you are facing?
The docs for the
linkOnPaste
option state:But I don't think this is quite true...
Take the link editor example and paste something like
[tiptap](https://tiptap.dev)
. You can see thathttps://tiptap.dev
will be converted into a link, but the pasted content does not only contain a URL, it contains more than that:This became a huge problem for us because we have Markdown support on our Typist editor, and we have our own paste rules to handle the Markdown syntax. However, this new
linkOnPaste
option (default:true
) caused us an issue by auto-linking when it shouldn't (based on my interpretation of the documentation).Although Tiptap does not support Markdown, I don't think the link found in
[tiptap](https://tiptap.dev)
should be auto-linked.Here's another example of a similar situation where auto-linking shouldn't have worked:
What browser are you using?
Firefox
Code example
No response
What did you expect to happen?
Only valid links/URLs should be auto-linked, and something like both examples above are not valid. The URLs are not isolated, they have text before/after, which makes them invalid links, so they shouldn't be autolinked.
Anything to add? (optional)
I believe this issue was introduced in #3975, with the addition of the
linkOnPaste
plugin, more specifically in this line, which is not doing any link validation.The
find
function from Linkify does allow avalidate
function, where we could add RegExp based validation, and fix this issue. However, there's also a bug on Linkify'sfind
function that prevent us from doing that (see this).Not sure if there are any other possible workarounds, but this turned out to be a major issue for us, cause this is such an amazing feature that we dearly miss.
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: