How to get output HTML and CSS of grapes.js in Javascript ?
I am writing a Django app for newsletter, in which I need a newsletter editor for which I used "grapes.js" newsletter. Everything is fine but I am stuck in part where I need to get the HTML and CSS of the template created with it.
I have:
<script type="text/javascript">
var editor = grapesjs.init({
container : '#gjs',
plugins: ['gjs-preset-newsletter'],
pluginsOpts: {
'gjs-preset-newsletter': {
modalTitleImport: 'Import template',
'grapesjs-plugin-export': { /* options */ }
// ... other options
}
}
});
function returnHtml(){
console.log('test')
const mjml = editor.getHtml;
preview = editor.getHtml
$("#myiframe").contents().find("body").html(mjml)
}
returnHtml();
This code gives me the html of the template but without the css !
I have tried https://github.com/artf/grapesjs-mjml/issues/2. Can someone please suggest me what i am missing ? Thanks.
EDIT: I have an answer below but what i need is like this with html and css together like in export HTML.Thanks again.