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

Autolink #1209

Closed
maccman opened this issue Apr 24, 2021 · 13 comments · Fixed by #2226
Closed

Autolink #1209

maccman opened this issue Apr 24, 2021 · 13 comments · Fixed by #2226
Assignees
Labels
sponsor 💖 This issue or pull request was created by a Tiptap sponsor Type: Feature The issue or pullrequest is a new feature

Comments

@maccman
Copy link

maccman commented Apr 24, 2021

It would be great to have some kind of autolinking support for the link component. In other words typing google.com automatically turns it into a url.

You can see how Remirror does that here:
https://github.com/remirror/remirror/blob/beta/packages/remirror__extension-link/src/link-extension.ts#L356

Regexwise, I suggest using this package which has hard-coded TLDs.
https://www.npmjs.com/package/url-regex-safe

@maccman maccman added Type: Feature The issue or pullrequest is a new feature v2 labels Apr 24, 2021
@philippkuehn
Copy link
Contributor

Yes, this is already on our list and I think it will land in stable 2.0 ✌️

@maccman
Copy link
Author

maccman commented Oct 11, 2021

Not make it into v2? :)

@philippkuehn
Copy link
Contributor

Hey, it’s coming. Last week I merged a massive PR for inputrules and pasterules. This also included the integration of linkify (on paste). After some research, this seems to be the most stable library for the best URL detection.

This is the basis for writing a method to set attributes live as you type. The same technique will also be necessary for a hashtag extension. So sorry it’s probably going to take a little longer. But it will come!

@rfgamaral
Copy link
Contributor

This is the basis for writing a method to set attributes live as you type. The same technique will also be necessary for a hashtag extension.

I'm curious, why does a hashtag extension need to "set attributes live as you type"? I mean, I've always imagined a hashtag extension very similar to the mentions extension, but with a different trigger character. What am I missing?

@philippkuehn
Copy link
Contributor

philippkuehn commented Oct 13, 2021

@rfgamaral In my eyes, a mention extension should work with unique user names. This can also be an unique id instead of an user name. So we are rendering an atom node where you can’t change the user name after creating the mention.

A hashtag is a simple way to highlight a string that starts with a #. So we have to update the bounding of the node if its text changes (putting a space within the hashtag should split the node for example)

@rfgamaral
Copy link
Contributor

@philippkuehn In my mind, I had a different use case, similar to mentions, but with a different trigger character. But I think I see what you mean, similar to how Twitter works, right?

@philippkuehn
Copy link
Contributor

@rfgamaral yeah maybe we’ll provide an option for the mention and hashtag extensions to render as text or atom node.

@rfgamaral
Copy link
Contributor

@philippkuehn Just wondering, what's missing for this to be possible with Tiptap?

@philippkuehn
Copy link
Contributor

Nothing is missing. I just need to find time and build it 😅 On a feature basis, it's definitely a high priority.

@philippkuehn
Copy link
Contributor

There is an open PR for it now: #2226
Happy to get any feedback!

@lfantone
Copy link

lfantone commented Jan 7, 2022

Nice to have the auto-link feature!
I noticed that the automatically created links are not possible to be removed with the unsetLink command.
Looks like when the editor is updated without the link, this feature runs again and keeps adding them.

@philippkuehn
Copy link
Contributor

@lfantone oh, you are right. this patch should help.

@peihk2
Copy link

peihk2 commented Nov 10, 2023

Hi @philippkuehn, I noticed your comment regarding the hashtag extension. I'm currently in need of this feature for my project, but I couldn't find it in the Tiptap documentation. Could you please point me in the right direction, or provide an example of how I can customize a hashtag extension for my project? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsor 💖 This issue or pull request was created by a Tiptap sponsor Type: Feature The issue or pullrequest is a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants