What is the proper way to initialize the editor with an already existing HTML and CSS content?
Question
Hi @artf , it seems that in order to initialise an instance of the editor with an already existing CSS you can either give the editor "gjs_styles" or "gjs_css". Similarly for HTML it's either "gjs_components" or "gjs_html". What is the proper way?
So far the way I've been doing this is to have this code run just before running grapesjs.init:
let contentObject = fetchContentObjectFromTheServerViaAnAPICall()
localStorage.gjs_styles = contentObject.gjs_styles || ''
localStorage.gjs_css = contentObject.gjs_css || ''
localStorage.gjs_html = contentObject.gjs_html || ''
localStorage.gjs_components = contentObject.gjs_components || ''
// Now initialize the editor and it will pick up the HTML and CSS set above.
grapesjs.init({
...
})
Am I doing this right?
Answers (3)
Thanks @artf !
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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1836
How to add !important in all the generated apis
Hello @artf, While i am going to edit some html from editor with the help of css then i need to add !important into all the css which is ch...
Issue #1519
[QUESTIONS]: Init components in grapesjs.init
Is it possible to initialise the components at grapesjs.init. We are not using StorageManager.load. We already have the project data at ini...
Issue #1012
Is it possible to export the html content with data attributes in editor?
@artf Is it possible to export the html content with data attributes in order reuse? We discussed about this on earlier , on How to pass da...
Issue #1310
Grape JS works for newsletter
We are testing to use the editor and we want to know if the grape js editor works for content newsletters, we were doing tests but CSS styl...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.