flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Linkify urls in text

Open JoepHeijnen opened this issue 9 months ago • 6 comments

Is there an existing issue for this?

The question

It seems that not all variants of urls are linkified in the text only the urls with a prefix like http or https. I see support for regex, but only for QuillToolbarImageButton and other kinds of buttons. What I want is that when I add one of the urls below that the editor automatically detects that it's an url.

Urls that are linkified http://google.com https://google.com https://www.google.com

Urls that aren't linkified www.google.com google.com

I can remember that this used to work, but at the moment it isn't.

JoepHeijnen avatar May 13 '24 09:05 JoepHeijnen

In QuillToolbar > QuillToolbarImageButton, you can update regex of the link for all cases that you know image

hoangsang17th avatar May 13 '24 10:05 hoangsang17th

Isn't this just the regex for adding an image with an url? I meant the urls in the text.

JoepHeijnen avatar May 13 '24 11:05 JoepHeijnen

Sorry, my mistake. You can update linkPrefixes at here. image

// this is default
const linkPrefixes = [
  'mailto:', // email
  'tel:', // telephone
  'sms:', // SMS
  'callto:',
  'wtai:',
  'market:',
  'geopoint:',
  'ymsgr:',
  'msnim:',
  'gtalk:', // Google Talk
  'skype:',
  'sip:', // Lync
  'whatsapp:',
  'http'
];

hoangsang17th avatar May 15 '24 08:05 hoangsang17th

Thanks for the response. This is really nice if you want a prefix, but in my use case I don't want the prefix. For example, www.google.com and google.com are links without an prefix, but are still a link.

JoepHeijnen avatar May 15 '24 11:05 JoepHeijnen

You can fork, update and make a PR

hoangsang17th avatar May 16 '24 04:05 hoangsang17th

Basically, before, the package supported regex determination, but no one really made a regex to support a text like google.com. You know what? Because of typographical errors, a lot of text will be automatically marked as a link

hoangsang17th avatar May 16 '24 08:05 hoangsang17th

I think this is fixed

singerdmx avatar Jun 21 '24 18:06 singerdmx