Skip to content

Convert MJML to Grapesjs JSON data on server side #4840

Answered by artf
jay-softsages asked this question in Q&A
Discussion options

You must be logged in to vote

The main issue with the headless option is that it's still relies on DOM API for parsing that means you could init the editor with the MJML plugin but you would need something like jsdom in order to work.

Here a quick example you can try directly on npm.runkit.com

require("jsdom");
require("global-jsdom/register");
const grapesjs = require("grapesjs");
const grapesjsMjml = require("grapesjs-mjml").default;

const editor = grapesjs.init({ headless: true, plugins: [grapesjsMjml]});

editor.setComponents(`<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-image width="100px" src="/assets/img/logo-small.png"></mj-image>
        <mj-divider border-color="#F45E43"></mj-divider>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jay-softsages
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants