Issue #488Opened November 7, 2017by richieteh944 reactions

editor.setComponents auto generate unwanted css

Question

I'm used the html and css editor that mention in #324 . After I edited the html and css it will generate a CSS where I suspect caused by editor.setComponents() Not sure this is a bug or normal behavior.

grapesjs version - 0.12.8 grapesjs preset - gjs-preset-newsletter 0.2.15

Answers (3)

thecodefishNovember 13, 20173 reactions

In my use case I am constantly getting & setting the html/css inside the editor, and what I found is that it would end up duplicating the 'default' styles (see the * and body styles in the image above - they appear twice).

I managed to solve that by making sure to clear the css before I (re)set it - something like the following:

editor.CssComposer.getAll().reset();
editor.setComponents(components);
editor.setStyle(css);
thecodefishJanuary 29, 20181 reactions

@chiqui3d I think whenever you need to modify the css from some external source, you'll probably want to reset the css composer first. So if you have something like editor.setStyle(css); in your code, you may need to call editor.CssComposer.getAll().reset(); first.

artfNovember 7, 20170 reactions

First of all, update your grapesjs version, then be more specific about your changes. What did you change? What do you mean with unwanted css?

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.