Issue #383Opened October 5, 2017by daniel-farina1 reactions

Best way to load element's css into the properties panel.

Question

Hi Again everyone,

GrapeJS is too much fun once you get deep into it. I have a simple question:

What's the best way to load the css from a newly created element to the properties panel.

For example I have the following box which has a black background:

image

The black background comes from the style in the element

...
 content: `
              <div class="col-8" style="background-color: rgba(0,0,0,0.70); padding:40px;" 
...

The editor converts the style tag into a class as shown here:

image

yet the properties panel does not have a background set: image

Now I change the color to dark orange: image

it will create a new class for it that will overwrite the previous one:

image

Thank you in advanced for any thoughts!

Answers (3)

daniel-farinaOctober 6, 20171 reactions

@artf I undertand now image

I completely missed the checkbox next to each selector. Setting the forceClass to false solves all my problems! I dont really need that as I'm keeping the source code extremely lean with as little divs as possible. Thank you very much for that!

Dan

daniel-farinaOctober 5, 20170 reactions

I discovered that if the div has no class and just style then a single class is created and the background is applied to the properties panel:

image

image

so that would be a partial solution for now but still looking for a better alternative.

artfOctober 5, 20170 reactions

Hi @daniel-farina you don't see .c1019's background because your component has two classes so, by default, the Style Manager select the CSS rule where the selector is a combination of all its classes, in your case .col-8.c1019. If you want to see .c1019's styles you can just deselect .col-8 schermata 2017-10-05 alle 13 11 54

You can also avoid automatic class generation if you want

grapesjs.init({
     ...
     forceClass: false
})

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.