Issue #1281Opened July 13, 2018by tomichal0 reactions

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)

tomichalJuly 16, 20180 reactions

Thanks @artf !

lock[bot]September 17, 20190 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.