humhub / humhub-prosemirror

Other
17 stars 8 forks source link

Rich Text Editor - Link target attribute required #61

Open parys-github opened 3 years ago

parys-github commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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

ArchBlood commented 2 years ago

@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

marc-farre commented 1 year ago

@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 commented 3 months ago

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