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

Listen Import Event, dont work editor.on('run:mjml-import:change' #316

Closed karlitaviky811 closed 1 year ago

karlitaviky811 commented 1 year ago

Hi, I'm using the latest version of grapesjsmjml and this solution doesn't work for me. I need to listen to the event when importing, can someone help me?

try this solution, but it doesn't work https://github.com/GrapesJS/mjml/issues/104

lechuhuuha commented 1 year ago

Hi Have you tried to look at the doc in this link https://grapesjs.com/docs/api/commands.html#available-events

Maybe its like this

editor.on('stop:mjml-import:before', (mjml) => {
  console.log(mjml);
})
karlitaviky811 commented 1 year ago

I'm also trying to use this.editor.runCommand('mjml-get-code').html to get the generated html, but it doesn't work for me either. Please help me to know how to access html and css ?

karlitaviky811 commented 1 year ago

Try the proposed solution, but it is not importing the mjml code. I need to listen to the event and have access to the mjml code I'm loading.

And here for another functionality I need to access the generated html to store it in the data base, but using this.editor.runCommand('mjml-get-code').html doesn't work for me

lechuhuuha commented 1 year ago

Try the proposed solution, but it is not importing the mjml code. I need to listen to the event and have access to the mjml code I'm loading.

And here for another functionality I need to access the generated html to store it in the data base, but using this.editor.runCommand('mjml-get-code').html doesn't work for me

i dont know if you can listen to event when importing. You could however after user imported you can get the mjml code with this code

var mjml = editor.runCommand('mjml-code');

and this code to get html render by mjml

var content = editor.runCommand("mjml-code-to-html").html;

Hope this solve your problem!

karlitaviky811 commented 1 year ago

I also have this problem, please help me to know how I can solve it ? error_ core.mjs:7739 ERROR Error: Malformed MJML. Check that your structure is correct and enclosed in tags. Captura de pantalla de 2023-02-15 10-56-34

the wrapper is not generating well the code initially ...

lechuhuuha commented 1 year ago

I also have this problem, please help me to know how I can solve it ? error_ core.mjs:7739 ERROR Error: Malformed MJML. Check that your structure is correct and enclosed in tags. Captura de pantalla de 2023-02-15 10-56-34

the wrapper is not generating well the code initially ...

the mjml you have is not enclose in mjml tag Its need to be like this

<mjml>
  <mj-body>

     // the rest of your code in image

  </mj-body>
</mjml>
karlitaviky811 commented 1 year ago

however, this is the code that is generated by drag and drop (just dragging to create the plant) :/. How can it initialize? because installing the library and making editor.init should generate it automatically.

lechuhuuha commented 1 year ago

however, this is the code that is generated by drag and drop (just dragging to create the plant) :/. How can it initialize? because installing the library and making editor.init should generate it automatically.

well you could capture your screen to show me because currently i dont see any errors when drag and drop the wrapper to the editor make any malformed mjml.

lechuhuuha commented 1 year ago

If I want to create a plant by drag and drop (from the beginning) I am not building the code correctly so it is sold without the initial tags

sorry but i dont really understand what you said and this issue getting a little drag out. You can contact me from telegram for further assistance https://t.me/huuhazozo.

karlitaviky811 commented 1 year ago

If I want to create a plant by drag and drop (from the beginning) I am not building the code correctly so it is sold without the initial tags