diff --git a/views/wysiwyg_editor_view.js b/views/wysiwyg_editor_view.js index 18c759a..9cb8d86 100644 --- a/views/wysiwyg_editor_view.js +++ b/views/wysiwyg_editor_view.js @@ -302,7 +302,12 @@ SC.WYSIWYGEditorView = SC.View.extend({ _doUpdateValue: function() { var value = this.get('value') || ''; - this.$inner.html(value); + try { + this.$inner.html(value); + } + catch(e) { + SC.Logger.error('Error while updating the rich text editor content: '+e.message); + } this.resetUndoStack(); this.updateFrameHeight(); }, @@ -552,6 +557,12 @@ SC.WYSIWYGEditorView = SC.View.extend({ var sel = this.getSelection(), range; + // If there is no range, we add the html at the end of the editor. + // This may be usefull when inserting images. + if (!sel.rangeCount) { + this.setCaretAtEditorEnd(); + } + if (sel.getRangeAt && sel.rangeCount) { // If any text is selected, remove it. range = sel.getRangeAt(0);