Is it possible to remove all CSS, instead of resetting to default?
Question
On saving I export my CSS, then import it the next time I load. When doing so, it appends my CSS to the existing default CSS.
editor.CssComposer.clear() appears to reset to default CSS, rather than clear all CSS.
https://jsfiddle.net/benvmatheson/movxw7p1/3/
Is it possible to clear all CSS, or just have imported CSS replace all CSS rather than appending to default CSS?
Answers (3)
On saving I export my CSS, then import it the next time I load
Read this please https://grapesjs.com/docs/modules/Storage.html
One example on those docs suggested just using the style attribute:
const editor = grapesjs.init({
container: '#gjs',
fromElement: 1,
height: '100%',
storageManager: { type: 0 },
plugins: ['gjs-blocks-basic'],
style: '* {display: none;}',
});
However, other style was still prepended. Should it be assumed that when importing style, it will always be prepended with the following?
* {
box-sizing: border-box;
}
body {
margin: 0;
}
This is the default CSS that you can change via protectedCss option, but again, if your purpose is to edit a previously created template, importing exported CSS is WRONG You might need to import HTML/CSS only on the creation of the template and this is ok, but later you should rely on the JSON created by the editor
Related Questions and Answers
Continue research with similar issue discussions.
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...
Issue #1742
How to load local css in to canvas of grapesjs editor in React ? Css path is not taking
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
Issue #1033
[BUG]: When IDs are used, it's not possible to update or remove a style
Steps to reproducehttps://jsfiddle.net/1cjjr02p/Click the text in editor, change background colour.Export CSS. You'll see both new and orig...
Issue #843
[QUESTION] - CssComposer - removes unused classes
hi @artf , I import a html , using import from grapesjs-preset-newsletter, with some css classes inside the <style> tag. After the import,...
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.