Issue #5460๐Ÿ’ฌ AnsweredOpened Oct 12, 2023by mapsmarketing1 reactions

Loading `component` and `styles` from `pageManager`

Quick answerby mapsmarketingโค 1

One annoying thing is that the editor is prepending the below default styles which when saving the styles has numerous duplicates of it: Edit: Looking at the docs I finally managed to find protectedCss and when set to empty stops the styles being prepended.

Read full answer below โ†“

Question

GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome v117.0.5938.149Reproducible demo link https://jsfiddle.net/9oLrsvya/Describe the bug How to reproduce the bug?Please see the pageManager object in the jsfiddle What is the expected behavior? Looking at the following documentation: https://grapesjs.com/docs/api/pages.html#pages It should load in the component and styles from the pageManager correctly into the editor. What is the current behavior? When you check the code via "view code" in the editor you'll notice neither the exact HTML neither...

Answers (4)

mapsmarketingโ€ข Oct 13, 2023

One annoying thing is that the editor is prepending the below default styles which when saving the styles has numerous duplicates of it: Edit: Looking at the docs I finally managed to find protectedCss and when set to empty stops the styles being prepended.

artfโ€ข Oct 12, 2023

Hi @mapsmarketing currently GrapesJS is not able to properly import HTML documents as string, so the parser skips elements like html, head, body and returns only what is parsed inside the body, one workaround you could do right now is to pass component as object Regarding the styles, it's the brows...

mapsmarketingโ€ข Oct 13, 2023

Hi @artf , I've found a way to get the body attributes along with the styles saving correctly via the following method: I noticed that your Page.toJSON outputs everything of the specified page. However, it doesn't seem to output the styles correctly (it's always set as undefined for me), so I retri...

GJS Helperโ€ข May 17, 2026

The issue you're encountering with component and styles not loading from pageManager is due to a common misunderstanding of the fromElement configuration option in GrapesJS, rather than a bug. Root Cause When you initialize GrapesJS with fromElement: true, you are instructing the editor to load its...

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.