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

Inline link tool, open in new window option #1057

Open
sietseveenman opened this issue Mar 12, 2020 · 11 comments
Open

Inline link tool, open in new window option #1057

sietseveenman opened this issue Mar 12, 2020 · 11 comments

Comments

@sietseveenman
Copy link

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.

@arpadgabor
Copy link

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)')
}

@khaydarov
Copy link
Member

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

@sietseveenman
Copy link
Author

@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

@neSpecc neSpecc reopened this Mar 16, 2020
@neSpecc
Copy link
Member

neSpecc commented Mar 16, 2020

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

@sietseveenman
Copy link
Author

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.

@natterstefan
Copy link
Contributor

natterstefan commented Mar 16, 2020

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

@sietseveenman
Copy link
Author

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

@natterstefan
Copy link
Contributor

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.

@MichaelGr3
Copy link

+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

@bettysteger
Copy link
Contributor

bettysteger commented Feb 5, 2024

@neSpecc would it be possible to set a default target for all links? i would like all links to have target="_blank"

@conradfr
Copy link

It would be great to be able to set custom default attributes.

For example with TipTap you can do:

Link.configure({ HTMLAttributes: { target: '_blank', }, })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants