Template export adds a html body tag in mjml code
See original GitHub issueHi, im a newbie coder and im using Grapesjs in a react component. i am having troubles to export mjml and html code. When i click on export template button it add an extra <body> tag before and after mjml code. It seems to be the canvas wrapper. how can i prevent this issue?
my console log display this error:
index.js:1 Uncaught Error: Malformed MJML. Check that your structure is correct and enclosed in <mjml> tags.
thats my code:
`import React, {useState, useEffect} from ‘react’; import * as grapesjs from ‘grapesjs’;
import grapesJSMJML from ‘grapesjs-mjml’
import {useParams} from ‘react-router-dom’ import { API_HOST } from ‘./api_utils’;
const Editor = () => { const [editor, setEditor] = useState(null); const pageId = useParams(); console.log(‘params editor :>>’, pageId )
useEffect(() => {
const editor =grapesjs.init({
id:"#editor",
noticeOnUnload: 0,
container:"#editor",
avoidInlineStyle : false,
fromElement: true,
storageManager:{
type: "remote",
stepsBeforeSave: 1,
contentTypeJson:true,
storeComponents:true,
storeStyles:true,
storeHtml:true,
storeCss: true,
headers: {
"Content-Type": "application/json",
},
id: "mycustom-",
urlStore: `${API_HOST}/${pageId.pageId}/content`,
urlLoad: `${API_HOST}/${pageId.pageId}/content`,
},
plugins: [grapesJSMJML],
pluginsOpts:{
grapesJSMJML:{
resetDevices: false,
overwriteExport: true,
resetStyleManager:true,
resetBlocks:true,
},
}
});
editor.DomComponents.clear()
editor.addComponents('<mjml><mj-body><mj-section></mj-section></mj-body></mjml>')
setEditor(editor);
}, []);
return ( <div id="editor"> </div> ) } export default Editor `
and that is the export template modal:
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:12 (1 by maintainers)
Top GitHub Comments
No, I have to remove body tag entirely.
It is like this:
And it would be like this.
The solution is to override wrapper component toHTML() method.
This should be fixed in the latest release.