Browse Source

Start tracking rules in undo manager

pull/663/head
Artur Arseniev 9 years ago
parent
commit
c7ff050a99
  1. 22
      src/css_composer/index.js
  2. 6
      src/editor/model/Editor.js

22
src/css_composer/index.js

@ -91,15 +91,35 @@ module.exports = () => {
rules.add(c.rules);
},
/**
* Do stuff after load
* @param {Editor} em
* @private
*/
postLoad(em) {
em.listenRules(this.getAll());
const ev = 'add remove';
const rules = this.getAll();
const um = em.get('UndoManager');
um && um.add(rules);
em.stopListening(rules, ev, this.handleChange);
em.listenTo(rules, ev, this.handleChange);
rules.each(rule => this.handleChange(rule));
},
/**
* Handle rule changes
* @private
*/
handleChange(model) {
const ev = 'change:style';
const handleUpdates = em.handleUpdates.bind(em);
em.stopListening(model, ev, handleUpdates);
em.listenTo(model, ev, handleUpdates);
},
/**
* Load data from the passed object, if the object is empty will try to fetch them
* autonomously from the storage manager.

6
src/editor/model/Editor.js

@ -186,7 +186,7 @@ module.exports = Backbone.Model.extend({
* Listen for new rules
* @param {Object} collection
* @private
*/
*
listenRules(collection) {
this.stopListening(collection, 'add remove', this.listenRule);
this.listenTo(collection, 'add remove', this.listenRule);
@ -199,11 +199,11 @@ module.exports = Backbone.Model.extend({
* Listen for rule changes
* @param {Object} model
* @private
*/
*
listenRule(model) {
this.stopListening(model, 'change:style', this.handleUpdates);
this.listenTo(model, 'change:style', this.handleUpdates);
},
},*/
/**
* This method handles updates on the editor and tries to store them

Loading…
Cancel
Save