From 58da6b128e053fe99d61e86e2be028ba35cce886 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 20 Dec 2017 00:30:56 +0100 Subject: [PATCH] Fix `getModelToStyle` in StyleManager --- package.json | 2 +- src/style_manager/index.js | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index fd22d66152..c57b5ca4c8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 6392414299..135bd6c88e 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -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); } }