Browse Source

Merge branch 'dev' of https://github.com/artf/grapesjs into dev

pull/4144/head
Artur Arseniev 4 years ago
parent
commit
aa79465513
  1. 17
      src/code_manager/model/JsGenerator.js
  2. 4
      yarn.lock

17
src/code_manager/model/JsGenerator.js

@ -39,7 +39,7 @@ export default Backbone.Model.extend({
}
}
comps.each(function(model) {
comps.each(function (model) {
code += this.mapModel(model);
}, this);
@ -54,7 +54,20 @@ export default Backbone.Model.extend({
for (let type in this.mapJs) {
const mapType = this.mapJs[type];
if (!mapType.code) {
continue;
}
if (mapType.props) {
function isFunctionEmpty(fn) {
const content = fn.toString().match(/\{([\s\S]*)\}/m)[1]; // content between first and last { }
return content.replace(/^\s*\/\/.*$/gm, '').trim().length === 0; // remove comments
}
if (isFunctionEmpty(mapType.code)) {
continue;
}
code += `
var props = ${JSON.stringify(mapType.props)};
var ids = Object.keys(props).map(function(id) { return '#'+id }).join(',');
@ -75,5 +88,5 @@ export default Backbone.Model.extend({
}
return code;
}
},
});

4
yarn.lock

@ -4982,8 +4982,8 @@ fn-name@~2.0.1:
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
follow-redirects@^1.0.0:
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
version "1.14.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
for-each@^0.3.3:
version "0.3.3"

Loading…
Cancel
Save