Inserting a table is causing the user to switch to HTML mode and insert manually a br element, so that he could start typing in the next line.
Possible solution is attaching this Client-side method on the OnClientCommandExecuted event of the RadEditor control:
<telerik:RadEditor runat="server" ID="RadEditor1"
OnClientCommandExecuted="OnClientCommandExecuted"></telerik:RadEditor>
<script type="text/javascript">
function OnClientCommandExecuted(editor, args) {
var command = args.get_commandName();
if (command = "InsertTable") {
var selection = editor.getSelection();
var range = selection.getRange();
if (range.pasteHTML) {
range.pasteHTML("<br />");
}
else {
editor.pasteHtml("<br/>");
}
}
}
</script>
The following workaround entirely changes the behavior by modifying the selection and selects the first TD
<telerik:RadEditor runat="server" ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml">
</telerik:RadEditor>
<script type="text/javascript">
var identifierID = "RadEditor_AfterTable";
function OnClientPasteHtml(editor, args) {
var commandName = args.get_commandName();
if (commandName === "InsertTable" || commandName === "TableWizard" ) {
var currValue = args.get_value();
currValue = currValue.replace(/<\/table>/gi, "</table><div id=" + identifierID + ">​</div>");
//currValue = currValue + "<div id=" + identifierID + ">​</div>";
args.set_value(currValue);
setTimeout(function () {
selectFirstTD(editor)
}, 0);
}
}
function selectFirstTD(editor) {
var $ = $telerik.$;
var contBody = editor.get_contentArea();
var identifier = $(contBody).find("#" + identifierID);
var table = identifier.prev();
var elmToSelect = table.find("th")[0] || table.find("td")[0];
if (elmToSelect.childNodes && !$telerik.isIE) {
elmToSelect = elmToSelect.childNodes[0].nodeName === "#text" && elmToSelect.childNodes[0];
}
var hasNextElement = identifier.next()[0];
while (hasNextElement && $(hasNextElement).is("style")) {
hasNextElement = $(hasNextElement).next()[0];
}
editor.selectElement(elmToSelect);
if (!hasNextElement) {
table.after("<br/>");
}
identifier.remove();
}
</script>