A common function of many plugins is inserting new content into the editor, however, this seems to be always done at the current insertion point, which may not be valid. For example, I want to be able to insert a tr element, but obviously the WYSIWYG context will never let me enter content anywhere other than inside a td or th, which is an invalid location for a tr. So what I'd like to be able to do is backtrack up the DOM until I find an appropriate location for the insert. For example, I'm in this situation:
<body>
<table>
<tr>
<td>[[current insert point]]</td>
</tr>
<table>
</body>
And I'm inserting a snippet like this:
<tr><td>Some default content</td></tr>
I want to be able to automatically adjust the insert point to just before the most recent tr (or possibly after the next /tr), or just after the most recent tbody or table tag, so that it results in valid markup. After insertion, it would be necessary to adjust the insert point again to a suitable location within the injected content (e.g. inside the first inserted child td). Is this something that a plugin would have to do itself, or does CKEditor handle this automatically, or provide some facility to help with it?
Incidentally, could we have a basic code formatting option in this forum?