diff --git a/src/vue-froala.js b/src/vue-froala.js index b5ca8d0..5135bf6 100644 --- a/src/vue-froala.js +++ b/src/vue-froala.js @@ -97,9 +97,6 @@ export default (Vue, Options = {}) => { this.initListeners(); this._editor = new FroalaEditor(this.$el, this.currentConfig) - - this.editorInitialized = true; - }, setContent: function (firstTime) { @@ -126,12 +123,19 @@ export default (Vue, Options = {}) => { function htmlSet() { - self._editor.html.set(self.model || ''); + // Check if editor not null + if (self._editor == null) + return; + + if (self._editor.html != undefined) + self._editor.html.set(self.model || ''); //This will reset the undo stack everytime the model changes externally. Can we fix this? - self._editor.undo.saveStep(); - self._editor.undo.reset(); + if (self._editor.undo != undefined) { + self._editor.undo.saveStep(); + self._editor.undo.reset(); + } } @@ -168,6 +172,7 @@ export default (Vue, Options = {}) => { if (this._editor) { + this.initEvents = []; this._editor.destroy(); this.editorInitialized = false; this._editor = null; @@ -227,7 +232,12 @@ export default (Vue, Options = {}) => { var self = this; this.registerEvent('initialized', function () { - if (self._editor.events) { + + // Editor initialized + self.editorInitialized = true; + + // Check if editor not null and editor has events + if (self._editor != null && self._editor.events) { // bind contentChange and keyup event to froalaModel self._editor.events.on('contentChanged', function () { self.updateModel();