grapesjs-preset-newsletter
grapesjs-preset-newsletter copied to clipboard
Background color does not get apply in Mozilla
this issue also exists in newsletter demo, open demo url in any latest version of Mozila then select any container, from right decoration section try to change background color, it does not work, same scenario working fine in Chrome. https://grapesjs.com/demo-newsletter-editor.html
this scenario works with older version of grapesjs i.e. 0.10.7 but not with newer version.
I fixed this by applying the following function to the css generated:
function formatCss(css) {
const rule = /body{background-color:(rgb\([\d\s,]+\)|#[\w]+);}/g;
const matches = css.match(rule);
const first = matches[0];
let formatted = css.replace(rule, "");
return `${formatted}${first}`;
}
It removes all other background-color css added to the rule and applies the first one in the stack.