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.38k stars 4.06k forks source link

[QUESTION] export options #1167

Closed maxencehenneron closed 6 years ago

maxencehenneron commented 6 years ago

Hi @artf,

Are there any other export options than HTML/CSS ? I'm thinking of a way to directly load the configuration from a remote server and render it on a web page on the fly.

Good job on grapejs! :)

artf commented 6 years ago

Thanks @maxencehenneron but I don't understand how this I'm thinking of a way to directly load the configuration from a remote server and render it on a web page on the fly (that you can alredy do it via the built-in remote storage) is related to other export options than HTML/CSS, what else do you need? Btw maybe this can help: https://github.com/artf/grapesjs/wiki/Storage

maxencehenneron commented 6 years ago

Currently, grapeJS exports the template in HTML/CSS, I wanted to know if there was an easy way to create a front-end app that would load the configuration saved by GrapeJS via the remote storage and render it on a web page. The flow would be:

I achieved the first part quite easily, but I'm still struggling about the second part, is it natively implemented?

Currently, the editor calls the remote storage endpoint with a few parameters like

gjs-css with the css styles gjs-html with the html content

but also a gjs-components and a gjs-styles which includes a list of all the components and their different properties. Is it possible to render a web page directly from these gjs-components/styles array?

artf commented 6 years ago

Yeah sure, I explain the exact thing here https://github.com/artf/grapesjs/wiki/Storage#store-and-load-templates You can init the editor from HTML or directly (without parsing) via the JSON

grapesjs.init({
  ...
  components: `<div>...</div><div>...</div>`,
});
// Or
const editor = grapesjs.init({
  ...
  components: [{...}, {...}],
});
// and now I can get its HTML
const html = editor.getHtml();
lock[bot] commented 5 years ago

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.