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

Cannot load javascript under grapesjs #3195

Closed henry930 closed 3 years ago

henry930 commented 3 years ago

Can javascript under the grapesjs panel load?

fzerman commented 3 years ago

Hi @henry930,

I fixed this problem by developing an reloader.

let editorConfig = {
// your configs
}
let editor = false;

function editorLoad(){
  $(editorConfig.container).empty(); // with JQuery
  editor = grapesjs.init(editorConfig);
  editor.load();
}

editorLoad();

If you want to update your config,

// for example
/* 
old
editorConfig.height = '100px'
*/
editorConfig.height = '150px';
editorLoad();

Your editor will reload. Your html, css... will remain.

artf commented 3 years ago

https://grapesjs.com/docs/modules/Components-js.html