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] Replace all of HTML #2787

Closed JoLoZ closed 4 years ago

JoLoZ commented 4 years ago

Hello there, I am trying to use GrapesJS for template customization for my end users, but ran in the following problem: There is no documented way which I can replace all of the content with something like a function.

I tried redirecting, but that, well... redirects.

What I have: -An exact copy of the demo page (I couldn't get the main thing running yet, but it's good enough for testing.) -Static .html files where I pull the templates from -A small script that catches URL arguments and tries to replace the content with the file from the base parameter. -PHP 7.4 (Could also switch to a bunch of other versions, including PHP 5) -An external catalogue, which redirects the browser to the editor with the base parameter set.

The content is comming like this:

<body>
<p>Imagen some content here. Get creative!</p>
<style>
</style>
</body>
artf commented 4 years ago

Well a lot of things depend on your backend and there I can't help you, but if you need to replace the canvas with a new template you would use something like this

editor.setComponents(`<p>Imagen some content here. Get creative!</p>
<style>
</style>`)