Replace all of HTML
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
Read full answer below ↓Question
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>
Answers (1)
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>`)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1066
[QUESTION] Get content with inline CSS
I've been looking for some explanation and I found that some email clients blocks CSS... I would like to know if is there some way to get e...
Issue #1112
[Question]How to add a new event to asset images
Hello, is there a way to add a new event to the AssetImageView, something like 'onRemove'. I overwritten the addAsset function from asset m...
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Issue #1960
[QUESTION] Dynamic class generation with a template
Hi there ! I am wondering if there is a way to force the dynamic class generation (of the form cXXXXX which happens when I drag'n'drop a co...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.