JavaScript Get HTML and CSS from grapes.js newsletter editor in Javascript

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. https://screenshots.firefox.com/u752bu0nNN97rXlr/127.0.0.1

Answer:1

Getting only HTML:

var html = editor.getHtml();

Getting only CSS:

var css = editor.getCss();

Getting HTML with CSS inline:

var htmlWithCss = editor.runCommand('gjs-get-inlined-html');
Answer:2

In Angularjs, I keep lot of data in my services so that the server calls can be reduced and the data can be picked from local variables. This leads to data being persisted in the application till user ...

In Angularjs, I keep lot of data in my services so that the server calls can be reduced and the data can be picked from local variables. This leads to data being persisted in the application till user ...

I've just learnt about Getters/Setters for objects and decided to play with it. However, I tried to put a Getter in an array and failed to do so. Is it not possible or am I just doing something wrong? ...

I've just learnt about Getters/Setters for objects and decided to play with it. However, I tried to put a Getter in an array and failed to do so. Is it not possible or am I just doing something wrong? ...

I have a fairly simple webpack set up with a bit of a twist. I have a few different ways I can think of to create my intended behavior, but I'm wondering if there are better approaches (I'm still ...

I have a fairly simple webpack set up with a bit of a twist. I have a few different ways I can think of to create my intended behavior, but I'm wondering if there are better approaches (I'm still ...

  1. vue manually trigger watch
  2. angularjs manually trigger watch

I know it is possible to override functions in JS, however is it possible to override implementation of conditional statements like ''if''. Update As asked by some comments, I am building a chrome ...

I know it is possible to override functions in JS, however is it possible to override implementation of conditional statements like ''if''. Update As asked by some comments, I am building a chrome ...