Browse Source

Fix with styles in array blocks content

pull/3828/head
Artur Arseniev 5 years ago
parent
commit
c248e9d94f
  1. 19
      docs/modules/Blocks.md
  2. 1
      src/dom_components/model/Components.js

19
docs/modules/Blocks.md

@ -12,6 +12,9 @@ The default UI is a lightweight component with built-in Drag & Drop support, but
::: warning ::: warning
To get a better understanding of the content in this guide, we recommend reading [Components] first To get a better understanding of the content in this guide, we recommend reading [Components] first
::: :::
::: warning
This guide is referring to GrapesJS v0.17.27 or higher
:::
[[toc]] [[toc]]
@ -221,7 +224,21 @@ Don't put non serializable properties, like functions, in your blocks, keep them
``` ```
This will work, but if you try to save and reload a stored project, those will disappear. This will work, but if you try to save and reload a stored project, those will disappear.
### Avoid styles
Don't put styles in your blocks.
```js
// Your block
{
content: [
{ type: 'my-cmp', styles: '.cmp { color: red }' },
`
<div class="el">Element</div>
<style>.el { color: blue }</style>
`,
],
}
```
If you remove those components from the canvas, the CSS code generator will be able to skip some of those from the output, but
## DONT PUT IDS in your content ## DONT PUT IDS in your content

1
src/dom_components/model/Components.js

@ -162,6 +162,7 @@ export default Backbone.Collection.extend({
if (isString(models)) { if (isString(models)) {
models = this.parseString(models, opt); models = this.parseString(models, opt);
} else if (isArray(models)) { } else if (isArray(models)) {
models = [...models];
models.forEach((item, index) => { models.forEach((item, index) => {
if (isString(item)) { if (isString(item)) {
const nodes = this.parseString(item, opt); const nodes = this.parseString(item, opt);

Loading…
Cancel
Save