Browse Source

Fix regressions

pull/281/head
Artur Arseniev 9 years ago
parent
commit
ab7ffe19db
  1. 19
      src/asset_manager/index.js
  2. 1
      src/editor/model/Editor.js
  3. 1
      src/parser/model/ParserCss.js
  4. 2
      test/specs/asset_manager/index.js
  5. 5
      test/specs/grapesjs/index.js
  6. 11
      test/specs/storage_manager/index.js
  7. 2
      webpack.config.js

19
src/asset_manager/index.js

@ -202,30 +202,23 @@ module.exports = () => {
}, },
/** /**
* Load data from the passed object, if the object is empty will try to fetch them * Load data from the passed object.
* autonomously from the storage manager. * The fetched data will be added to the collection.
* The fetched data will be added to the collection
* @param {Object} data Object of data to load * @param {Object} data Object of data to load
* @return {Object} Loaded assets * @return {Object} Loaded assets
* @example * @example
* var assets = assetManager.load();
* // The format below will be used by the editor model
* // to load automatically all the stuff
* var assets = assetManager.load({ * var assets = assetManager.load({
* assets: [...] * assets: [...]
* }) * })
* *
*/ */
load(data) { load(data = {}) {
var d = data || ''; const name = this.storageKey;
var name = this.storageKey; let assets = data[name] || [];
if(!d && c.stm)
d = c.stm.load(name);
var assets = d[name] || [];
if (typeof assets == 'string') { if (typeof assets == 'string') {
try { try {
assets = JSON.parse(d[name]); assets = JSON.parse(data[name]);
} catch(err) {} } catch(err) {}
} }

1
src/editor/model/Editor.js

@ -496,7 +496,6 @@ module.exports = Backbone.Model.extend({
*/ */
load(clb = null) { load(clb = null) {
this.getCacheLoad(1, (res) => { this.getCacheLoad(1, (res) => {
console.log('LOADED in em.load', res);
this.get('storables').forEach(module => module.load(res)); this.get('storables').forEach(module => module.load(res));
clb && clb(res); clb && clb(res);
}); });

1
src/parser/model/ParserCss.js

@ -74,6 +74,7 @@ module.exports = config => ({
var style = {}; var style = {};
for (var j = 0, len2 = stl.length; j < len2; j++) { for (var j = 0, len2 = stl.length; j < len2; j++) {
var propName = stl[j]; var propName = stl[j];
//console.log('Style', stl, propName, ': ', stl.getPropertyValue(propName));
var important = stl.getPropertyPriority(propName); var important = stl.getPropertyPriority(propName);
style[propName] = stl[propName] + style[propName] = stl[propName] +
(important ? ' !' + important : ''); (important ? ' !' + important : '');

2
test/specs/asset_manager/index.js

@ -106,7 +106,7 @@ describe('Asset Manager', () => {
obj.add(imgObj); obj.add(imgObj);
obj.store(); obj.store();
obj.remove(imgObj.src); obj.remove(imgObj.src);
obj.load(); obj.load({assets: storage['gjs-assets']});
var asset = obj.get(imgObj.src); var asset = obj.get(imgObj.src);
expect(asset.get('width')).toEqual(imgObj.width); expect(asset.get('width')).toEqual(imgObj.width);
expect(asset.get('height')).toEqual(imgObj.height); expect(asset.get('height')).toEqual(imgObj.height);

5
test/specs/grapesjs/index.js

@ -151,8 +151,9 @@ describe('GrapesJS', () => {
var editor = obj.init(config); var editor = obj.init(config);
editor.setComponents(htmlString); editor.setComponents(htmlString);
editor.store(); editor.store();
var data = editor.load(); editor.load((data) => {
expect(data.html).toEqual(htmlString); expect(data.html).toEqual(htmlString);
});
}); });
it('Execute plugins with custom options', () => { it('Execute plugins with custom options', () => {

11
test/specs/storage_manager/index.js

@ -60,7 +60,9 @@ describe('Storage Manager', () => {
}); });
it('Load do not execute if empty', () => { it('Load do not execute if empty', () => {
expect(obj.load(['item'])).toEqual({}); obj.load(['item'], (res) => {
expect(res).toEqual({});
});
}); });
it('Load default storages ', () => { it('Load default storages ', () => {
@ -106,9 +108,10 @@ describe('Storage Manager', () => {
data2[id + 'item2'] = 'testData2'; data2[id + 'item2'] = 'testData2';
obj.store(data); obj.store(data);
var load = obj.load(['item', 'item2']); obj.load(['item', 'item2'], (res) => {
expect(storeValue).toEqual(data2); expect(storeValue).toEqual(data2);
expect(load).toEqual(data); expect(res).toEqual(data);
});
}); });
}); });

2
webpack.config.js

@ -1,5 +1,3 @@
//webpack --display-reasons
//Remove jquery https://github.com/webpack/webpack/issues/1275
var webpack = require('webpack'); var webpack = require('webpack');
var pkg = require('./package.json'); var pkg = require('./package.json');
var env = process.env.WEBPACK_ENV; var env = process.env.WEBPACK_ENV;

Loading…
Cancel
Save