Issue #1079Opened May 1, 2018by Coyote62 reactions

Improper Bg Repeat CSS Being Set

Question

When importing components and initializing grapesjs, the css background-repeat property is being changed to background-repeat-x and background-repeat-y, which breaks on iOS.

Import components:

<div id="izmt">Test Begin<br />
<br />
<br />
<br />
Test End</div>
<style type="text/css">#izmt{background-image:url("/path/to/img.jpg");background-repeat:repeat-x;}
</style>

This is how it looks before:

Mobile mobile-before

Desktop desktop-before

Initialize GrapesJs, select an element, and then get the output code, and it comes back:

<div id="izmt">Test Begin<br />
<br />
<br />
<br />
Test End</div><style>* { box-sizing: border-box; } #izmt{background-image:url("/path/to/img.jpg");background-repeat-x:repeat;background-repeat-y:no-repeat;}</style>

This is how it is rendered after:

Mobile mobile-after

Desktop desktop-after

Answers (3)

Coyote6May 7, 20182 reactions

Thanks. I added this to my storage manager function... I think it patches the problem for the time being... I am not quite awake yet, so please let me know if I messed something up.

var css = editor.getCss();

// Fix the JavaScript Parser for the background repeat.
var noRepeat = /background-repeat-x:no-repeat;background-repeat-y:no-repeat;/g;
var repeat = /background-repeat-x:repeat;background-repeat-y:repeat;/g;
var repeatX = /background-repeat-x:repeat;background-repeat-y:no-repeat;/g;
var repeatY = /background-repeat-x:no-repeat;background-repeat-y:repeat;/g;
css = css.replace(noRepeat, 'background-repeat:no-repeat;');
css = css.replace(repeat, 'background-repeat:repeat;');
css = css.replace(repeatX, 'background-repeat:repeat-x;');
css = css.replace(repeatY, 'background-repeat:repeat-y;');
artfMay 4, 20180 reactions

Thanks @Coyote6 we're already aware of this issue. This happens due to the browser's CSS parser and I can't do much about until there will be a possibility to attach custom CSS parsers, hope to implement it soon.

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.