BUG: setStyle/getCss() produces duplicated css
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome Latest
Reproducible demo link
https://codesandbox.io/s/silent-river-ifczcv
Describe the bug
How to reproduce the bug?
- Visit the site
- See console. Pay attention to the
*andbodyselector
Expected result Should not be duplicated
If is necessary to execute some code in order to reproduce the bug, paste it here below:
editor = grapesjs.init({
storageManager: false
// ...
})
editor.on("update", () => {
// save to backend
console.log("editor getCSs", editor.getCss());
});
editor.on("load", () => {
// this will come from backend
const style = "* { box-sizing: border-box; } body {margin: 0;}";
editor.setStyle(style);
// const html = backendHtml (<body><div></div></body>)
// editor.setComponents(html)
});
Description
I do this because the new storageManager mechanism/schema destroys my entire app, especially the backend stuff.
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (1)
There are default styles applied that you can simply disable (pass an empty string) https://github.com/GrapesJS/grapesjs/blob/a83847b1b35e69e5a5810ccf1eb1e1384bf0aab1/src/editor/config/config.ts#L143-L147
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5207
BUG: Duplicated CSS while multi page creation
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome latest Reproducible demo link https...
Issue #6365
BUG: Style Manager Fails to Interpret Descendant Selectors Correctly
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 131.0.6778.205 Reproducible...
Issue #6180
BUG: Trait's `setValue()` method not called when value changes
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome latest Reproducible demo link https...
Issue #6685
BUG: Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
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.