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

Support mailto: URL schema #6

Open
alexanderjulmer opened this issue Jan 4, 2022 · 0 comments · Fixed by nickolasjadams/link-autocomplete#1 · May be fixed by #9 or #11
Open

Support mailto: URL schema #6

alexanderjulmer opened this issue Jan 4, 2022 · 0 comments · Fixed by nickolasjadams/link-autocomplete#1 · May be fixed by #9 or #11

Comments

@alexanderjulmer
Copy link

Expected behaviour

Pasting or typing a link such as mailto:[email protected] is inserted as a link

Actual behaviour

Error message "Link URL is invalid" is shown.

nickolasjadams added a commit to nickolasjadams/link-autocomplete that referenced this issue Sep 4, 2022
Url checking

I noticed that when you don't add a protocol to a url like this
www.hello.world
the url added to the editor attempts to reference a file
file:///path/to/project/www.hello.world

So I took a look at how to require http or https and noticed
Utils.isUrl() is not working properly in another way
due to the regex.

This is passing the regex
www.0.♪┏(・o・)┛♪

This is failing
http://wwwuzzzuppp.com

I've updated the regex to fix the regex issue and require the protocol.
Adding links should be done through the api or absolute urls.

---

closes editor-js#8
Impossible to disable server search Issue editor-js#8
editor-js#8

isServerEnabled method calls lacked parenthesis in index.js. It's
now possible to disable the server calls by removing the endpoint
in the config.

---

closes editor-js#6
Support mailto: URL schema editor-js#6
editor-js#6

I've found myself wishing to to add different tyes of hrefs and
noticed this issue.

I've added 3 URI schemes to check against in Utils.isUrl()

view-source:
mailto:
tel:

It now checks for a URI Scheme and then applies an appropriate
regex to test the remaining url.

The email regex uses control characters so disabled no-control-regex in .eslintrc

---

Url fragments not recongnized as urls.

Utils.isUrl() now also checks if your string starts with "#"

so you can do this `<a href="#lower_in_the_document">`

Which will work great with this plugin.
https://github.com/Aleksst95/header-with-anchor

---

Can't open links in a new tab.

A checkbox has been added to provide the user an option to open the url in a new tab.
You can tab and shift-tab back and forth between the 2 inputs when adding urls.
Clicking the datawrapper will let you know if the link opens in a new tab or the same tab.

---

Finally, I've fixed a couple warnings that were shown when running the linter.
nickolasjadams added a commit to nickolasjadams/link-autocomplete that referenced this issue Oct 14, 2023
I'm breaking up my large pull request into smaller ones to make it easier
to test the changes.

These are only the changes in how URLs are handled.

First, there was a bug in the regex used in Utils.isUrl().
It allowed
- www.hello.world (without a protocol, resulting in www.hello.world appended relatively)
It didn't allow
- http://wwwuzzzuppp.com

Since relative links are likely being autocompleted through an API, it makes sense
that the URL regex should be expecting absolute URLs. It's been updated to do that.
It also requires the protocol, since absolute URLs should specify a protocol.

TESTING URL REGEX:
In the editor add these links.
-[ ] https://editorjs.io/ | Link should be added successfully
-[ ] auto | Clicking an autocompleted link should be work
-[ ] http://wwwuzzzuppp.com | Links that didn't work before should work
-[ ] relative-link | This should show the Invalid URL error message
-[ ] www.hello.world | Pressing enter should show the Invalid URL error message

Support for 2 URI Schemes and URL Fragments
closes editor-js#6 | mailto link support

In the same method as the URL regex - Utils.isUrl(), we also check if the url starts with
'mailto:'
'tel:'
or '#'

and then applies an appropriate regex to test the remaining URL.

The email regex uses control characters so I had to disable no-control-regex in .eslintrc

TESTING URI SCHEMES
In the editor add these links
-[ ] mailto:[email protected] | Pressing enter should add the mailto link
-[ ] tel:5555555555 | Pressing enter should add the tel link
-[ ] #hello | Pressing enter should add the url fragment to the link

The fragments should work really well with this plugin.
https://github.com/Aleksst95/header-with-anchor
nickolasjadams added a commit to nickolasjadams/link-autocomplete that referenced this issue Oct 14, 2023
I'm breaking up my large pull request into smaller ones to make it easier
to test the changes.

These are only the changes in how URLs are handled.

First, there was a bug in the regex used in Utils.isUrl().
It allowed
- www.hello.world (without a protocol, resulting in www.hello.world appended relatively)
It didn't allow
- http://wwwuzzzuppp.com

Since relative links are likely being autocompleted through an API, it makes sense
that the URL regex should be expecting absolute URLs. It's been updated to do that.
It also requires the protocol, since absolute URLs should specify a protocol.

TESTING URL REGEX:
In the editor add these links.
-[ ] https://editorjs.io/ | Link should be added successfully
-[ ] auto | Clicking an autocompleted link should be work
-[ ] http://wwwuzzzuppp.com | Links that didn't work before should work
-[ ] relative-link | This should show the Invalid URL error message
-[ ] www.hello.world | Pressing enter should show the Invalid URL error message

Support for 2 URI Schemes and URL Fragments
closes editor-js#6 | mailto link support

In the same method as the URL regex - Utils.isUrl(), we also check if the url starts with
'mailto:'
'tel:'
or '#'

and then applies an appropriate regex to test the remaining URL.

The email regex uses control characters so I had to disable no-control-regex in .eslintrc

TESTING URI SCHEMES
In the editor add these links
-[ ] mailto:[email protected] | Pressing enter should add the mailto link
-[ ] tel:5555555555 | Pressing enter should add the tel link
-[ ] #hello | Pressing enter should add the url fragment to the link

The fragments should work really well with this plugin.
https://github.com/Aleksst95/header-with-anchor
@nickolasjadams nickolasjadams linked a pull request Oct 14, 2023 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment