Editor.js: Inline link tool, open in new window option

Created on 12 Mar 2020  路  9Comments  路  Source: codex-team/editor.js

I would like to add a 'open in new window' checkbox to the inline link tool.
this would add target="_blank" to the element.
How can I overwrite the default inline link tool?
I think this would be a very useful standard feature for the inline link tool.

Most helpful comment

Hi @neSpecc, hi @sietseveenman.

We had the same issue and created our own Inline "Link" Tool based on the current implementation (https://github.com/codex-team/editor.js/blob/master/src/components/inline-tools/inline-tool-link.ts).

It looks like this now:

image

I share the code with anyone interested: https://gist.github.com/natterstefan/0e6c22ed7af59c221b8a80e68b5cdb22

All 9 comments

Also faced this issue but quickly managed to fix it with JS. Built in would be nice though.

const links = document.getElementsByTagName('a');
for (let link of links) {
  link.setAttribute('target', '_blank')
  link.setAttribute('rel', 'noopener')
  link.setAttribute('aria-label', 'External link (opens in new tab)')
}

@sietseveenman hi! it will be added in the next 2.17 release

@khaydarov awesome new release!
But I think my issue was misunderstood.
I would like to add a checkbox input to the Inline tool (see screenshot).
It would be great to have an option to add target="_blank" to the link created in the text

Screenshot 2020-03-16 at 14 01 27

In 2.17 we have resolved #1028, not this issue.

In 2.17 we have resolved #1028, not this issue.

Thanks neSpecc. I am working an a custom inline toolbar button to add the target="_blank".
That will be fine for now but it would be great to have this functionality baked in to the inline link tool.

Hi @neSpecc, hi @sietseveenman.

We had the same issue and created our own Inline "Link" Tool based on the current implementation (https://github.com/codex-team/editor.js/blob/master/src/components/inline-tools/inline-tool-link.ts).

It looks like this now:

image

I share the code with anyone interested: https://gist.github.com/natterstefan/0e6c22ed7af59c221b8a80e68b5cdb22

Hey @natterstefan
That is exactly what I meant, looks good!
Do you intent to use the 'title' input to add a title="yadadoodle" to the link for when the user hovers the link?

@neSpecc This would be a great standard feature imho

Hi @sietseveenman,

thank you very much.

Do you intent to use the 'title' input to add a title="yadadoodle" to the link for when the user hovers the link?

Yes, exactly.

@neSpecc, let me know, if I can be of help. Check out the gist for more details.

+1 for this feature request :)
I've currently fixed this by explicitly adding the '_blank' property to all links. At the moment I'm usually linking to pdfs so thats fine. But obviously it would be better to make the blank property optional with some kind of checkbox as proposed by @natterstefan

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chouglesaud picture chouglesaud  路  3Comments

oknoorap picture oknoorap  路  4Comments

zizther picture zizther  路  4Comments

Yakumo-Yukari picture Yakumo-Yukari  路  5Comments

guillaumepn picture guillaumepn  路  4Comments