grapesjs-preset-newsletter icon indicating copy to clipboard operation
grapesjs-preset-newsletter copied to clipboard

Background color does not get apply in Mozilla

Open sarveshTagremTech opened this issue 6 years ago • 1 comments

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.

sarveshTagremTech avatar Aug 16 '18 11:08 sarveshTagremTech

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.

heavensloop avatar Jan 22 '19 05:01 heavensloop