Automatically add rel="noopener" to target="_blank" in new TinyMCE editor

Goaral
Member since: 2010
 

Hi All 

Anyone have hints hot to add rel="noopener to all new links created that have target="_blank" in the XHtmlstring with TinyMCE? 


thanks for any input 

#197523 Edited, Oct 05, 2018 11:37
  • Goaral
    Member since: 2010
     

    my thought is that i have to hook on epi-link somehow.. 

    Website\modules\_protected\EPiServer.Cms.TinyMce\EPiServer.Cms.TinyMce.zip\2.6.3\ClientResources\epi-addon-tinymce\plugins\epi-link

    or maybe we can add something in the TinyMCEInitializer... example,  .AddSettingsTransform but im not quite sure what to do.. 

    #197544 Oct 05, 2018 15:26
  • Johan Kronberg
    Member since: 2005
     

    I would put it in one of the server side events (OnContentSaving or similiar) or if you already have masses of pages; when rendering.

    #197549 Oct 06, 2018 7:45
  • Linh Nguyen
    Member since: 2009
     

    @Goaral: which version of EPiServer TinyMCE are you using? I think you should not get that issue from EPiServer TinyMCE 2.0

    #197644 Oct 09, 2018 12:53
  • Jacob Pretorius
    Member since: 2016
     

    Had to do something similar a while ago, although in our case we couldn't keep it specific to the Episerver/TinyMCE rendering as the client had hardcoded links in their FE that they also wanted all updated in one sweep (and not having to worry about it in the future is a bonus).

    First I did it with an Attribute Filter on the base page controller which worked, but the way they have custom cookies meant it didn't work that well with A/B Testing, so v2 of the implementation uses an HTTP Module.

    You can find the full info here (as well as code samples): https://jcpretorius.com/post/2018/replace-all-occurrences-of-something-in-the-http-response

    Jacob.

    #197722 Oct 11, 2018 13:18