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

[Question]: How to load external javascript,i tried all methods,Useless #3238

Closed sizhousama closed 3 years ago

sizhousama commented 3 years ago

I write html strings as blocks, and need to introduce a lot of external scripts and styles, but I tried all the methods, when I drag the block to the canvas, the script does not take effect, but styles can be loaded,I hope to get help。 1. Load by appendchild image

2. init load by canvas:{scripts:[...]} image

who can help me?

sizhousama commented 3 years ago

The console shows loaded image

harsh201 commented 3 years ago

@sizhousama I am loading scripts/stylesheets via canvas while initializing grapesjs editor and it works for me.

 canvas: {
          scripts: ['https://unpkg.com/abc.js'],
          styles: ['https://unpkg.com/abc/dist/css/abc.min.css'],
        },

More details can be found here. Hope it helps!