Grapesjs: How to load css link into the head tag?

Created on 23 Oct 2017  路  6Comments  路  Source: artf/grapesjs

Hello,
First of all, thanks for contributing such an amazing js framework.
I am very new to grapesjs. And github too.

canvas: {
    scripts: ['https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js']
  }

https://github.com/artf/grapesjs/wiki/Components-&-JS#template-related
According to grapesjs wiki, I load js links inside the canvas as the above codes and it works fine.

But when I try with css links like this, it doesn't work.

canvas: {
      links : ['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'] 
  }

Some people here suggest to add those CSS links directly under the id="gjs".
I did it but what happen is if I clean the canvas, it also clean my css links and CSS doesn't work anymore.
My question is how can I load CSS link into the head tag?

outdated

Most helpful comment

You were almost there :)

canvas: {
    styles: ['https://...'] 
}

All 6 comments

You were almost there :)

canvas: {
    styles: ['https://...'] 
}

Thank you so much @artf , it works like a charm.

the css files in canvas doesnt included in the editor.gethtml() ..how can i can i get it ?

You have to include separately while rendering, it won't come in getHtml() or anything.

Hi,
I Tried loading the external stylesheet with "styles" as mentioned above, but it has included the stylesheet into the body, and that too many times.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kickbk picture kickbk  路  3Comments

nojacko picture nojacko  路  3Comments

adam-gpc picture adam-gpc  路  3Comments

Snarkly picture Snarkly  路  3Comments

alibouaziz picture alibouaziz  路  3Comments