Issue #1281πŸ’¬ AnsweredOpened July 13, 2018by tomichal0 reactions

What is the proper way to initialize the editor with an already existing HTML and CSS content?

Quick answerby artf

Am I doing this right? Not really. You have to setup the remote storage

Read full answer below ↓

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)

tomichalβ€’ July 16, 2018

Thanks @artf !

lock[bot]β€’ September 17, 2019

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.