grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

How do I reference external CSS in blockManager instead of adding each and every style in body of index.html?

Open cpcashion opened this issue 9 years ago • 4 comments

@artf

Let's say I'm adding a new custom block called 'big-hero', and I want the custom HTML that I'm adding to that new block to reference an entire stylesheet instead of having to add each individual style in the <body>. How does one accomplish that? Where does one add an external stylesheet?

image

cpcashion avatar Jul 26 '17 18:07 cpcashion

For block specific styles I'd recommend just using style tag

content: `
<section class="big-hero">...</section>
<style>
  .big-hero{...} ....
</style>
`,

If you want to preload external stylesheet inside the canvas

var editor = grapesjs.init({
  ...
  canvas: {
    styles: [
      'https://...',
      ...
    ]
  }
});

artf avatar Aug 02 '17 21:08 artf

For block specific styles I'd recommend just using style tag

content: `
<section class="big-hero">...</section>
<style>
  .big-hero{...} ....
</style>
`,

If you want to preload external stylesheet inside the canvas

var editor = grapesjs.init({
  ...
  canvas: {
    styles: [
      'https://...',
      ...
    ]
  }
});

Hi @artf

When using