GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

Is it possible to remove all CSS, instead of resetting to default? #1992

Closed benvmatheson closed 5 years ago

benvmatheson commented 5 years ago

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?

artf commented 5 years ago

On saving I export my CSS, then import it the next time I load

Read this please https://grapesjs.com/docs/modules/Storage.html

benvmatheson commented 5 years ago

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;
}
artf commented 5 years ago

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

benvmatheson commented 5 years ago

Unfortunately our usage requires that we import/export raw CSS/HTML. But protectedCss appears to be doing exactly what we need. Thank you!

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.