When I want to clear a class in the RadEditor the class is cleared in the hyperlink manager, but not in the area in the footer of the RadEditor.
If 'clear class' is selected nothing happens.
The code may error out if the editor js object is still not created. To ensure that it is add this if check:
<script>
if (typeof Telerik !== "undefined") {
Telerik.Web.UI.Editor.AttributeCommand.prototype.execute = function () {
var attr = this._attribName;
var classAttr = this._classAttr;
var attrLower = attr.toLowerCase();
var element = this._nodeBookmark.select();
if (!element) { return false; }
if (!this._isExecuted) {
if (attr == 'style') { this._oldValue = element.style.cssText; } else { this._oldValue = element.getAttribute(this._classAttr || attr); }
}
if (attr && attrLower == 'name' && this.isIE) {
element.name = this._newValue;
element.removeAttribute('name');
element.removeAttribute('NAME');
if ($telerik.isIE9Mode) {
var nodeName = element.nodeName;
if (nodeName == 'INPUT' || nodeName == 'TEXTAREA' || nodeName == 'BUTTON') {
element.removeAttribute('submitName');
element.setAttribute('name', this._newValue);
}
}
}
var newVal = this._newValue.trim();
if ('' == newVal) {
if (attr == "className") {
element.removeAttribute(classAttr, 0);
}
else {
element.removeAttribute(attr, 0);
}
}
else if (attr == 'style') {
element.style.cssText = this._newValue;
} else {
element[attr] = this._newValue;
if (attrLower == 'nowrap' || attr == 'borderColor' || attr === 'value')
{
element.setAttribute(attr, this._newValue);
}
}
this._isExecuted = true;
return true;
}
}
</script>
<telerik:RadEditor runat="server" ID="RadEditor1" Height="600px">
<Content>This is a <a href="http://test.com" class="redText">link</a> test.</Content>
<Modules>
<telerik:EditorModule Name="RadEditorStatistics" Visible="true" />
<telerik:EditorModule Name="RadEditorDomInspector" Visible="true" />
<telerik:EditorModule Name="RadEditorNodeInspector" Visible="true" />
<telerik:EditorModule Name="RadEditorHtmlInspector" Visible="true" />
</Modules>
</telerik:RadEditor>
Alternatively you can also check for
if (typeof ($telerik) != "undefined") { ... }
Regards,
Rumen
Progress Telerik
Hi Reinout,
Thank you for your report!
My research shows that this is a glitch in the RadEditor. The solution that I came up with is the following JS override of the execute function. The highlight shows the new check that I added to it:
<style>
.redText { color: red; }
.blueText { color: blue; }
</style>
<script>
Telerik.Web.UI.Editor.AttributeCommand.prototype.execute = function () {
var attr = this._attribName;
var classAttr = this._classAttr;
var attrLower = attr.toLowerCase();
var element = this._nodeBookmark.select();
if (!element) { return false; }
if (!this._isExecuted) {
if (attr == 'style') { this._oldValue = element.style.cssText; } else { this._oldValue = element.getAttribute(this._classAttr || attr); }
}
if (attr && attrLower == 'name' && this.isIE) {
element.name = this._newValue;
element.removeAttribute('name');
element.removeAttribute('NAME');
if ($telerik.isIE9Mode) {
var nodeName = element.nodeName;
if (nodeName == 'INPUT' || nodeName == 'TEXTAREA' || nodeName == 'BUTTON') {
element.removeAttribute('submitName');
element.setAttribute('name', this._newValue);
}
}
}
var newVal = this._newValue.trim();
if ('' == newVal) {
if (attr == "className") {
element.removeAttribute(classAttr, 0); //or just -> element.removeAttribute("class", 0);
}
else {
element.removeAttribute(attr, 0);
}
}
else if (attr == 'style') {
element.style.cssText = this._newValue;
} else {
element[attr] = this._newValue;
if (attrLower == 'nowrap' || attr == 'borderColor' || attr === 'value')
{
element.setAttribute(attr, this._newValue);
}
}
this._isExecuted = true;
return true;
}
</script>
<telerik:RadEditor runat="server" ID="RadEditor1" Height="600px">
<Content>This is a <a href="http://test.com" class="redText">link</a> test.</Content>
<Modules>
<telerik:EditorModule Name="RadEditorStatistics" Visible="true" />
<telerik:EditorModule Name="RadEditorDomInspector" Visible="true" />
<telerik:EditorModule Name="RadEditorNodeInspector" Visible="true" />
<telerik:EditorModule Name="RadEditorHtmlInspector" Visible="true" />
</Modules>
</telerik:RadEditor>
Can you please try it and let me know the result so that I can check it into the source code? Thank you!
As a small note of gratitude, I also updated your Telerik points.
Regards,
Rumen
Progress Telerik