[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)
Provide a reproducible demo, please
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.
I have the same problem. This is my issue -> https://github.com/artf/grapesjs/issues/2843
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1230
[Question]: Doctype in the canvas iframe
Hey @artf, I noticed the canvas iframe doesn't appear to have any doctype set on it, which causes it to be in quirks mode. Is this intentio...
Issue #2784
Are media queries broke?
I'm just trying the demo on my phone https://grapesjs.com/demo.html render of HTML/CSS https://us-central1-connectionhelper-6e7ed.cloudfunc...
Issue #1906
Components & Js - Load Template
Hey, I have a component which has a JS attached to it. Everything is created using the JS. When I drag and drop my block for the first time...
Issue #1888
[Question] Add custom html inside canvas
Hi there, I'm using grapes to export a custom json with all the information i need, instead of HTML and CSS. For doing that I'm parsing the...
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.