Sitecore Rich Text Editor Adds Extra <a> Tag to the HTML

The Setup:

Our content editors alerted me to an interesting problem that was causing them some headaches.

The Problem:

When the Insert Sitecore Link command is used in the rich text editor, the link that gets created is enclosed in an extra <a> tag, which can cause the page not to render. The content editors had to manually fix this in HTML view after inserting any Sitecore link in the content.

To replicate the issue follow these steps:

1. Open any Rich Text Editor, clear all the content.
2. Click the Insert Sitecore Link button in the tool bar.

3. Select an item from media library.

4. Inspect the resulting HTML. You will see an extra <a> tag enclosing your link, which obviously isn't going to work.

The Solution:

With a little help from Sitecore Support, we found a rather simple fix. Follow these steps:

1. Back up the “\Website\sitecore\shell\Controls\Rich Text Editor\RTEfixes.js” file.
2. Open this file, and comment out the last block as follows:

/*(function () {
if (!window.Telerik) return;
var $T = Telerik.Web.UI;
var Editor = $T.Editor;
Editor.UnlinkCommand = function (editor, options) {
var settings = {
tag: "a",
altTags: []
Editor.UnlinkCommand.initializeBase(this, [editor, settings, options]);
Editor.UnlinkCommand.prototype = {
getState: function (wnd, editor, range) {
var states = Editor.CommandStates;
var result = Editor.UnlinkCommand.callBaseMethod(this, "getState", [wnd, editor, range]);
return result === states.Off ? states.Disabled : states.Off;
Editor.UnlinkCommand.registerClass("Telerik.Web.UI.Editor.UnlinkCommand", Editor.InlineCommand);
Editor.UpdateCommandsArray.Unlink = new Editor.UnlinkCommand();

3. Clear the browser cache.

Now the Insert Sitecore Link function will work properly again. I tested this on Sitecore 8.2 Update 2, but I expect it will fix other versions as well.


Add comment