diff --git a/index.html b/index.html index 7fd9545af3..57d7d47735 100755 --- a/index.html +++ b/index.html @@ -806,7 +806,7 @@

The team

clearOnRender: 0, storageManager:{ - autoload: 0, + autoload: 1, storeComponents: 1, storeStyles: 1, }, @@ -1173,6 +1173,16 @@

The team

}, }); + /* + // Store and load events + editor.on('storage:load', function(e) { + console.log('LOAD ', e); + }) + editor.on('storage:store', function(e) { + console.log('STORE ', e); + }) + */ + editor.render(); diff --git a/src/dom_components/index.js b/src/dom_components/index.js index 7cd4c01bbd..7e6d4de788 100644 --- a/src/dom_components/index.js +++ b/src/dom_components/index.js @@ -216,10 +216,10 @@ module.exports = () => { }catch(err){} }else if(d.html) obj = d.html; - if (obj) { this.clear(); - this.getComponents().reset(obj); + this.getComponents().reset(); + this.getComponents().add(obj); } return obj; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index b351cb3c3f..ff4dd09f69 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -161,18 +161,21 @@ module.exports = Backbone.Model.extend({ * @private * */ componentsUpdated(model, val, opt) { - var count = this.get('changesCount') + 1; - var avoidStore = opt ? opt.avoidStore : 0; - var stm = this.get('StorageManager'); - this.set('changesCount', count); - - if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) { - return; - } - - if (!avoidStore) { - this.store(); - } + timedInterval && clearInterval(timedInterval); + timedInterval = setTimeout(() => { + var count = this.get('changesCount') + 1; + var avoidStore = opt ? opt.avoidStore : 0; + var stm = this.get('StorageManager'); + this.set('changesCount', count); + + if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) { + return; + } + + if (!avoidStore) { + this.store(); + } + }, 0); }, /** diff --git a/src/editor/view/EditorView.js b/src/editor/view/EditorView.js index 165a58879c..08fffc1985 100644 --- a/src/editor/view/EditorView.js +++ b/src/editor/view/EditorView.js @@ -24,8 +24,8 @@ module.exports = Backbone.View.extend({ dComps.clear(); } dComps.getComponents().reset(config.components); - um.clear(); model.loadOnStart(); + um.clear(); // This will init loaded components dComps.onLoad(); }