GrapesJS / mjml

Newsletter Builder with MJML components in GrapesJS
http://grapesjs.com/demo-mjml.html
BSD 3-Clause "New" or "Revised" License
618 stars 218 forks source link

Get the rendered html from the editor? #348

Closed casesolved-co-uk closed 5 months ago

casesolved-co-uk commented 5 months ago

Hi,

I've not used typescript before so struggling to understand how I get the rendered HTML from an MJML template. getHTML() returns the MJML.

I can see I need to call the command cmdGetMjmlToHtml or mjml-code-to-html, how do I do that?

Thanks

gustavohleal commented 5 months ago

Hi,

To run any command you call for `editor.runCommand("command-name"). I sugest you take a look at the tutorials in the grapesjs docs. Here you can see how to add custom commands and how to run them. https://grapesjs.com/docs/modules/Commands.html#basic-configuration

You can experiment more using the demo version of grapejs standard or with mjml online through the console in the devtools.

casesolved-co-uk commented 5 months ago

Thanks @gustavohleal I just figured out this.editor.Command.run, but runCommand is even better!

Yes it was in the documentation 😊