Issue #2184Opened August 6, 2019by D33Funky0 reactions

[QUESTION] Losing predefined media queries

Question

Hi. I have a predefined json of a template which contains a set of html elements and styles which are parsed into the set of components upon grapesjs load. The css contains some of the default media query rules which I'd like to keep for the template. Commands editor.getHTML() and editor.getCSS() return correct values when the page is loaded. I want to have the possibility to modify the html and css code separately and rebuild the components. If I try to use the same html and css code to save the template, my predefined media queries are lost after the components are reset at the canvas:

In short, I'm doing the following:

let initialHtml = editor.getHtml(); // returns the correct html
let initialCss = editor.getCss(); // returns the correct css with the predefined set of media queries from JSON

editor.CssComposer.clear();

editor.setComponents(initialHtml);
editor.setStyle(initialCss);

let css = editor.getCss(); // at this point the initial media queries are missing even though they were provided in initialCss variable.

Can you please give a hint for the workaround?

Answers (3)

artfAugust 12, 20190 reactions

Provide a reproducible demo, please

no-response[bot]August 22, 20190 reactions

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

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.