Hello Ido,
I can confirm that the described behavior is a bug. You can track the status of the logged item by following
this feedback portal item, in which you can also vote or comment.
As appreciation for this report I am updating your Telerik points.
The encountered problem is because of the
onParentNodeChanged() method, it appears that in order to calculate correctly the layout of the editor, it adds a BR element to initialize the first row and resise correctly the content height.
A possible workaround is using a custom filter, the logic of which removes the additional BR elements. Additionally note that you can trigger the filters automatically by using this line of code:
You can examine this example, which is made accordingly to the provided setup:
<table id=
"tbl"
border=
"1"
>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
<div id=
"editorTextFile"
>
<telerik:RadEditor ID=
"RadEditor1"
runat=
"server"
OnClientLoad=
"OnClientLoad"
>
</telerik:RadEditor>
</div>
<script type=
"text/javascript"
>
$telerik.$(
function
() {
$telerik.$(
"#tbl tr td"
).click(
function
() {
var
editor = $find(
"<%=RadEditor1.ClientID%>"
);
var
content = $(
this
).html();
//copy cell info
$(
this
).html(
""
);
//clear cell
editor.set_html(content);
//copy cell info
$telerik.$(
this
).append($telerik.$(
"#editorTextFile"
));
var
editor = $find(
"<%= RadEditor1.ClientID %>"
);
// Fix visual issues with the editor along with the
// workaround for the BR elements
repaintAndremoveBrs(editor);
});
});
function
repaintAndremoveBrs(editor) {
editor.onParentNodeChanged();
// With this line of code all the content filters are
// being invoked and forced to clean the content
editor.set_html(editor.get_html(
true
));
}
/* Custom content filter that strips the additional BR elements */
function
OnClientLoad(editor, args) {
if
(!$telerik.isIE)
// Register the filter if the browser is not IE
editor.get_filtersManager().add(
new
RemoveBrs());
}
RemoveBrs =
function
() {
RemoveBrs.initializeBase(
this
);
this
.set_isDom(
true
);
this
.set_enabled(
true
);
this
.set_name(
"Remove Brs"
);
this
.set_description(
"Removes all additional Br elements from the content."
);
}
RemoveBrs.prototype = {
getHtmlContent:
function
(content) {
var
newContent = content;
var
lastBr = content.lastChild
while
(lastBr && lastBr.tagName ===
"BR"
) {
content.removeChild(lastBr);
lastBr = content.lastChild
}
return
newContent;
},
}
RemoveBrs.registerClass(
'RemoveBrs'
, Telerik.Web.UI.Editor.Filter);
</script>
Let me know if you need further information about this matter.
Regards,
Ianko
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the
blog feed now.