GrapesJS / components-lory

GrapesJS Slider Component by using lory
BSD 3-Clause "New" or "Revised" License
29 stars 30 forks source link

How load the component again #3

Closed omarmd1986 closed 6 years ago

omarmd1986 commented 6 years ago

Hi, I'm using the grapes JS library to create an HTML. I added the slider plugin and everything goes fine the first time. The user creates the HTML and clicks on a button to save the changes. I get the HTML, CSS, and JS generated by Grapes JS and, save them in my database for future use. When I try to load the HTML, CSS, and JS generated by grapes JS to edit the changes that I've saved the slider doesn't work.

My question: How can I save my template whit component that needs JS and load again and the component still by a component? The grapes js remove all the scripts.

cvetlicni commented 5 years ago

@omarmd1986 Can you share some insights on what was wrong and how did you overcome/fix it?

artf commented 5 years ago

@cvetlicni you have to store/load JSON objects for editing purpose, read this: https://grapesjs.com/docs/modules/Storage.html#setup-remote-storage

cvetlicni commented 5 years ago

@artf thanks for quick help, but my problem was actually way simpler.

I was already storing html, css, scripts into DB and loading them, but didn't have allow-scripts: 1 set.

For future references: You must allow scripts when you init grapesJS instance.

const editor = grapesjs.init({
  ...
  allowScripts: 1,
});
omarmd1986 commented 5 years ago

The option allowScripts works fine for me.

ali-alhuwswe commented 3 years ago

How i can get script like css ( editor.getCss(); )