Issue #3070Opened October 9, 2020by mhowey2 reactions

BUG / Feature? Applying background color to body component isn't part of the exported HTML.

Question

Hi Art, thanks for creating such a fantastic project!

I'm not sure if this would be considered a bug or feature request...but I'm having issues deciding how to hande the background color on the body while using the newsletter plugin with GrapesJS.

Steps to Reproduce:

  1. Select the body (root element) in the canvas.
  2. In the style palette under "decorations" >> "Background" -- select a color to fill the body with
  3. Click export HTML, only the children elements are provided, so when the output HTML is used, it has no wrapper to apply the background color with.

If there is a way to handle this correctly that I'm missing, I'm not sure. I am considering manually wrapping the HTML in a table or div that applies the color or something like that??

Thanks in Advance for any and all assistance.

image

Answers (3)

JoshLucioOctober 9, 20201 reactions

@mhowey I have seen this also, but I always assumed that the body is just the placeholder canvas for the content. Changes to the body do not export since the content placed in the body is the only thing being exported. In my application use, the body color change is used just to visualize what the content will look like when I place it on my site if the site has a background color.

artfOctober 11, 20201 reactions

You can use this option

grapesjs.init({
 exportWrapper: true,
})
mhoweyOctober 9, 20200 reactions

Thanks for the reply @JoshLucio . I'm using the newsletter preset plugin, which I believe is more targeted toward HTML email, rather than site building. I was actually thinking what you said to be the case, and I've explored all the getWrapper and getWrapperEl methods that Grapes provides, but they do not seem to carry any styling with them.

@artf - is the only way to accomplish this by manually wrapping the exported html? Thanks!

> @mhowey I have seen this also, but I always assumed that the body is just the placeholder canvas for the content. Changes to the body do not export since the content placed in the body is the only thing being exported. In my application use, the body color change is used just to visualize what the content will look like when I place it on my site if the site has a background color.

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.