Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check null or undefined properties, Clear initEvents on editor destroy #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/vue-froala.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ export default (Vue, Options = {}) => {
this.initListeners();

this._editor = new FroalaEditor(this.$el, this.currentConfig)

this.editorInitialized = true;

},

setContent: function (firstTime) {
Expand All @@ -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();
}

}

Expand Down Expand Up @@ -168,6 +172,7 @@ export default (Vue, Options = {}) => {

if (this._editor) {

this.initEvents = [];
this._editor.destroy();
this.editorInitialized = false;
this._editor = null;
Expand Down Expand Up @@ -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();
Expand Down