Browse Source

Fix storage loading

pull/187/head
Artur Arseniev 9 years ago
parent
commit
63e0fd072c
  1. 12
      index.html
  2. 4
      src/dom_components/index.js
  3. 27
      src/editor/model/Editor.js
  4. 2
      src/editor/view/EditorView.js

12
index.html

@ -806,7 +806,7 @@
clearOnRender: 0,
storageManager:{
autoload: 0,
autoload: 1,
storeComponents: 1,
storeStyles: 1,
},
@ -1173,6 +1173,16 @@
},
});
/*
// 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();
</script>
</body>

4
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;

27
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);
},
/**

2
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();
}

Loading…
Cancel
Save