question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use grapesjs-mjml inside a react app.

See original GitHub issue

Hello and thanks for grapesjs!

I’m running into an issue using the MJML plugin with grapesjs inside a react app.

The canvas loads but I’m not able to drop any blocks into the canvas area. Not using the the mjml plugin the canvas loads and allows for blocks to be dropped into the canvas area.

I get the following warning when using grapesjs-mjml plugin:

Invalid target position: Target collection not found, Target is not droppable, accepts [undefined], Component not draggable, acceptable by [undefined]

Here is my setup, maybe I’m missing something simple.

"grapesjs": "^0.16.30",
"grapesjs-mjml": "^0.3.4",
import 'grapesjs/dist/css/grapes.min.css';
import grapesjs from 'grapesjs';
import grapesjsMJML from 'grapesjs-mjml';
import React, { useEffect } from 'react';

export const Editor = () => {
    useEffect(() => {
        const editor = grapesjs.init({
            container: '#email-editor',
            fromElement: true,
            avoidInlineStyle: false,
            panels: { defaults: [] },
            plugins: [grapesjsMJML],
            pluginsOpts: {
                [grapesjsMJML]: {}
            },
            height: '300px',
            blockManager: {
                appendTo: '#email-editor-blocks',
            }
        });
    }, []);
    return (
        <div>
            <div id="email-editor" />
            <div id="email-editor-blocks" />
        </div>
    );
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:10

github_iconTop GitHub Comments

3reactions
edward-vocommented, Jan 15, 2021

Try adding

<mjml>
  <mj-body>
    <mj-section>
    </mj-section>
  </mj-body>
</mjml>

It can be done thru editor.addComponents or fromElement

1reaction
DRoetcommented, Dec 28, 2020

Hmm interesting, I’ve had problems in the past using VueJS (https://github.com/artf/grapesjs-mjml/issues/155) but I haven’t seen this error before.

Does the block manager get rendered correctly? also could you try the unminified build aswell and see if that work:

import grapesjsMJML from 'grapesjs-mjml/dist/grapesjs-mjml'
Read more comments on GitHub >

github_iconTop Results From Across the Web

grapesjs-mjml - npm
Start using grapesjs-mjml in your project by running `npm i grapesjs-mjml`. There are 5 other projects in the npm registry using grapesjs-mjml.
Read more >
1 - Asset Manager in Grapes JS - Webpage Editor - YouTube
So for now, we saw how to use Grapes JS with Vaniall JS /HTML and also with React. In this, I will try...
Read more >
4 - Create Custom Swiper Plugin for Grapes JS - No Code
In this video, we will create a Grapes JS plugin for Swiper and use it. ... grapesjs tutorial grapesjs - mjml grapesjs template...
Read more >
Grapes.js MJML Editor - Save additional data with ... - CodePen
Grapes.js MJML Email Editor exports mjml to html. To save that html, along with the mjml, css and their json representations, just use...
Read more >
grapesjs-mjml examples - CodeSandbox
Learn how to use grapesjs-mjml by viewing and forking example apps that make use ... Please use it and report everything inside the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found