Skip to content

Commit

Permalink
Fix getModelToStyle in StyleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Dec 19, 2017
1 parent 76019a4 commit 58da6b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.12.53",
"version": "0.12.54",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",
Expand Down
18 changes: 7 additions & 11 deletions src/style_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,18 @@ module.exports = () => {
if (em) {
const config = em.getConfig();
const cssC = em.get('CssComposer');
const avoidInline = config.avoidInlineStyle;
const state = !config.devicePreviewMode ? model.get('state') : '';
const valid = classes.getStyleable();
const hasClasses = valid.length;
const opts = { state };

// If true the model will be always a rule
if (avoidInline) {
const rule = cssC.getIdRule(id, opts);
return rule ? rule : cssC.setIdRule(id, {}, opts);
} else if (classes && classes.length) {
if (hasClasses) {
const deviceW = em.getCurrentMedia();
const valid = classes.getStyleable();
const CssRule = cssC.get(valid, state, deviceW);

if (CssRule && valid.length) {
return CssRule;
}
if (CssRule) return CssRule;
} else if (config.avoidInlineStyle) {
const rule = cssC.getIdRule(id, opts);
return rule ? rule : cssC.setIdRule(id, {}, opts);
}
}

Expand Down

0 comments on commit 58da6b1

Please sign in to comment.