2

Following on from a previous question on how to make customisations of the RTE upgrade safe, we have:

1) Customised the LinkManager.ascx to add a new property for the 'rel' attribute on the link. This works, and the rel attribute is appended to the anchor tag. I used this article on Customizing Sitecores Rich Text Editor Dialogs for that.

2) Added a new Configuration Type item under your Rich Text Editor profile in the core database with the following value:

MyNamespace.CustomEditorConfig,MyProject

3) Created a CustomEditorConfig class with the following code:

   public class CustomEditorConfig : Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration
        {
            public CustomEditorConfig(Item profile) : base(profile)
            {
            }

            protected override void SetupEditor()
            {
                Editor.ExternalDialogsPath = "~/sitecore/shell/override/controls/rich text editor/Dialogs/";
                base.SetupEditor();
            }
        }

When you subsequently:

  • Go to 'Content Editor'
  • Find a rich text field
  • Click 'Show editor'
  • Select some text
  • Click the 'Hyperlink Manager' icon
  • Select a value from the 'Target' dropdown
  • Hit OK
  • Click the 'Hyperlink Manager' icon again

Then the selected dropdown value does not display in the 'Target' combo box field. That's what I'm trying to resolve. The correct selected option is still selected if you click on the dropdown.

Link Target is always set to 'None'

The selected target combo value appears to automatically get set to the 0th entry of the array from the localization.

If I copy the original LinkManager.ascx file to my override folder, the problem still occurs even though my new 'rel' property is not shown in the Hyperlink Manager, so the problem only seems to occur when Configuration Type is set to use my CustomEditorConfig class, which in turn sets the ExternalDialogsPath.

I also have a patched configuration for HtmlEditor.DefaultConfigurationType to use my new class.

I found that there is a setting:

<!--
PROTECT FROM EXTERNAL LINK WITH BLANK TARGET Protects your website from a security vulnerability that exists when an external link contains target="_blank". See https://dev.to/ben/the-targetblank-vulnerability-by-example If set to true, sitecore adds the rel="noopener noreferrer" attribute to the link. Default: true 
-->
<setting name="ProtectExternalLinksWithBlankTarget" value="true"/>

but I'm not sure that has anything to do with it, as I haven't seen the rel="noopener noreferrer" get appended to the anchor even if I select 'New Window' (_blank) for the Target.

0

1 Answer 1

0

We've managed to work around this inside of the _loadLinkTarget function in LinkManager.ascx, by getting the element:

var rfdSelectText = document.getElementsByClassName("rfdSelectText");

and then setting the innerHtml property:

rfdSelectText[0].innerHTML = "Something";

This still doesn't explain why the problem occurred to begin with, but allows us to work around the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.