humhub-prosemirror icon indicating copy to clipboard operation
humhub-prosemirror copied to clipboard

Rich Text Editor - Link target attribute required

Open parys-github opened this issue 3 years ago • 5 comments

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

parys-github avatar Jul 12 '21 03:07 parys-github

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 
 } 

ArchBlood avatar Jul 12 '21 10:07 ArchBlood

@luke- PR here: https://github.com/humhub/humhub-prosemirror/pull/78 Thanks @ArchBlood for indicating which file it was!

marc-farre avatar Sep 05 '22 05:09 marc-farre

@luke- PR here: https://github.com/humhub/humhub-prosemirror/pull/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

ArchBlood avatar Sep 05 '22 13:09 ArchBlood

@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

marc-farre avatar Feb 15 '23 17:02 marc-farre

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

miro-ku avatar Aug 21 '24 18:08 miro-ku