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

Rich Text Editor - Link target attribute required #61

Open
parys-github opened this issue Jul 12, 2021 · 5 comments
Open

Rich Text Editor - Link target attribute required #61

parys-github opened this issue Jul 12, 2021 · 5 comments

Comments

@parys-github
Copy link

Rich Text Editor - Link TARGET issue

This is the problem and the same time feature request.
I register that the Rich Text Editor a specially the LINK tool has the wrong label [Link target] and this is very confusing.
Actually the field with this label is responsible for the URL not for the target attribute.
Right now all a:href elements int the posts sections are rendered with the target="_blank" attribute.

It seems that from a User Experience perspective it would be very desirable to change the label:
[Link target] => [Link URL]
and adding the new field
[Link target] with dropdown which allows users to conditionally select options for the target attribute:
_blank or _self

I think this is a very common situation that when writing a post, we want to refer to articles in the area of the parent (local) domain without the need to open a new window or a separate tab.

I must admit that I am aware that this is not a tiny update but a major improvement but from the user's perspective it will be a very helpful and undeniably useful feature.

Thank you very much for your great work and an almost perfect script. I keep my fingers crossed for new improvements.

Cheers
Marek

@ArchBlood
Copy link

Seems that this is done here and a few other places

https://github.com/humhub/humhub-prosemirror/blob/master/src/editor/core/plugins/link/index.js#L38-L45

 // If you are sure other plugins can't add `target` - drop check below 
 var aIndex = tokens[idx].attrIndex('target'); 
  
 if (aIndex < 0) { 
     tokens[idx].attrPush(['target', '_blank']); // add new attribute 
 } else if(!tokens[idx].attrs[aIndex][1]) { 
     tokens[idx].attrs[aIndex][1] = '_blank';    // replace value of existing attr 
 } 

@marc-farre
Copy link
Contributor

@luke- PR here: #78
Thanks @ArchBlood for indicating which file it was!

@ArchBlood
Copy link

@luke- PR here: #78
Thanks @ArchBlood for indicating which file it was!

I would also like to note the following lines as well;
https://github.com/humhub/humhub-prosemirror/blob/master/src/editor/core/util/linkUtil.js#L21-L38

luke- added a commit that referenced this issue Sep 6, 2022
…-richtext-links

Enh #61: Only use _blank on external richtext links
@marc-farre
Copy link
Contributor

marc-farre commented Feb 15, 2023

@luke- Should we close this issue?
However, the fix has not been released yet: https://github.com/humhub/humhub-prosemirror/blob/develop/docs/CHANGELOG.md -> Enh #61

@miro-ku
Copy link

miro-ku commented Aug 21, 2024

Btw there is another type of internal links, for example ?test=value or #test=value which will add query or hash to the current url

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

4 participants