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

[Bug]: The linkOnPaste option on extension-link doesn't behave has expected #4414

Open
2 tasks done
rfgamaral opened this issue Sep 5, 2023 · 0 comments
Open
2 tasks done
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

Comments

@rfgamaral
Copy link
Contributor

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:

Adds a link to the current selection if the pasted content only contains an url.

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 that https://tiptap.dev will be converted into a link, but the pasted content does not only contain a URL, it contains more than that:

firefox_paI0aAJ33T

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:

firefox_oa8cLw6arn

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 a validate function, where we could add RegExp based validation, and fix this issue. However, there's also a bug on Linkify's find 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?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@rfgamaral rfgamaral added 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 labels Sep 5, 2023
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
No open projects
Status: Triage open
Development

No branches or pull requests

3 participants