I created a simple page builder by following GrapeJS Docs and it is working well.
I think there need to be 2 functions to save and load the generated page.
How can I do this?
const editor = grapesjs.init({
// Indicate where to init the editor. You can also pass an HTMLElement
container: '#gjs',
// Get the content for the canvas directly from the element
// As an alternative we could use: `components: '<h1>Hello World Component!</h1>'`,
fromElement: true,
// Size of the editor
height: '300px',
width: 'auto',
// Disable the storage manager for the moment
storageManager: false,
// Avoid any default panel
panels: { defaults: [] },
blockManager: { },
layerManager: { },
deviceManager: { },
selectorManager: { },
styleManager: { },
storageManager: { }
});
2
Answers
1.If you need to load/get project source data after the initialization, Grapes js provide two functions for that.
2.Grapes js also provides 3 functions to get HTML,CSS & JS
3.You can also define the storage manager like below and call
editor.store()
to save &editor.load()
to load project data from the provided endpoints.For more details about the storage manager check the official docs setup remote storage
Save current stage of template
Load saved data
You can save in database instead of localStorage. This worked for me!