* Sets the selection after the last direct children of the editor.
*/
selectionEndOfEditor: function() {
+ this.focus.setEnd();
+
var $lastChild = this.$editor.children(':last')[0];
if ($lastChild.tagName === 'P') {
// sometimes the last <p> is just empty, causing the method to fail
if ($lastChild.innerHTML === '') {
- $lastChild = $($lastChild).replaceWith($(this.opts.emptyHtml));
- this.caret.setEnd($lastChild[0]);
+ $lastChild.remove();
+ $lastChild = $(this.opts.emptyHtml).appendTo(this.$editor);
}
+
+ this.caret.setEnd($lastChild[0]);
}
else {
this.wutil.setCaretAfter($lastChild);
this._messageField.redactor('focus.setEnd');
this._messageField.redactor('wutil.insertDynamic', $html, data.returnValues.template);
- this._messageField.redactor('focus.setEnd');
+ this._messageField.redactor('wutil.selectionEndOfEditor');
this._messageField.redactor('wbbcode._observeQuotes');
}
else {