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)
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);
@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.
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.
Issue #1059
[Question]: Load html content from a file dynamically
Hi, I need to load content from a html file from server onto editor after or while initializing editor. How this can be implemented? HTML w...
Issue #1047
[BUG] Model not able to change after changing value in custom Select dropdown menu.
Hey, I'm using CDN link for grapes js from unpkg.com In my project, I've used custom trait as a drop-down select menu which changes HTML us...
Issue #1092
[BUG]traits and storage trigger
Hey, maybe it's not bug, i'm not sure. I have traits with changeProp: true field. When I change the value of trait by UI, model is changed...
Issue #843
[QUESTION] - CssComposer - removes unused classes
hi @artf , I import a html , using import from grapesjs-preset-newsletter, with some css classes inside the <style> tag. After the import,...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.