Skip to content

Commit

Permalink
Open in new tab option, fragments, uri schemes, and fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nickolasjadams committed Sep 4, 2022
1 parent c9c8187 commit 4a39cc6
Show file tree
Hide file tree
Showing 10 changed files with 14,096 additions and 3,288 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"codex"
],
"rules": {
"jsdoc/no-undefined-types": "off"
"jsdoc/no-undefined-types": "off",
"no-control-regex": 0
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ By default, shortcut `CMD (CTRL) + K` is used for pasting links as usual.

## I18n

There is a few phrases to be translated.
There are a few phrases to be translated.

UI items:

- `Paste or search` — placeholder for an input field if server endpoint passed.
- `Paste a link` — placeholder for the same field if server endpoint is missing.
- `Open in new tab` - label for checkbox field that changes link target.
- `Opens in a new tab` - Descriptive text for existing links that open in a new tab.
- `Opens in same tab` - Descriptive text for existing links that open in the same tab.

Error messages:

Expand All @@ -132,6 +135,9 @@ i18n: {
LinkAutocomplete: {
'Paste or search': '...',
'Paste a link': '...',
'Open in new tab': '...',
'Opens in a new tab': '...',
'Opens in same tab': '...',
'Cannot process search request because of': '...',
'Server responded with invalid data': '...',
'Link URL is invalid': '...'
Expand Down
4 changes: 4 additions & 0 deletions icons/newtab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4a39cc6

Please sign in to comment.