GrapesJS / preset-newsletter

GrapesJS preset configuration for the newsletter editor.
https://grapesjs.com/demo-newsletter-editor.html
BSD 3-Clause "New" or "Revised" License
197 stars 143 forks source link

how to call the gjs-get-inlined-html command #44

Closed JPPreusDev closed 4 years ago

JPPreusDev commented 6 years ago

Please help me figure out how to call the gjs-get-inlined-html command.

LKozakewycz commented 6 years ago
var editor = grapesjs.init({
// ...
});

console.log(editor.Commands.get('gjs-get-inlined-html'));

That works. My concern now is how I actually get the HTML. This returns an object.

LKozakewycz commented 6 years ago

Worked it out:

var editor = grapesjs.init({
// ...
});

console.log(editor.Commands.get('gjs-get-inlined-html').run(editor));
AnkitKachhadiya commented 6 years ago

You can also do like this:

var editor = grapesjs.init({
// ...
});
console.log(editor.runCommand('gjs-get-inlined-html'));
carboni-rob commented 6 years ago

It's returning undefined for me. Any idea why? Also, editor.Commands.has('gjs-get-inlined-html') returns false. grapesjs 0.14.27 grapesjs-preset-newsletter 0.2.19

zolga commented 4 years ago

I'm getting undefined as well, any update on this?

chezhiane commented 4 years ago

getting undefined as well any reasons ?

yatide commented 4 years ago

Same here

artf commented 4 years ago

editor.runCommand('gjs-get-inlined-html') works in the demo (you can try it in dev console). Be sure to use the latest version

YannikFirre commented 4 years ago

Hello @artf

I have the same issue but only at the initialization after the command work fine.

/! grapesjs - 0.16.12 / /! grapesjs-preset-newsletter - 0.2.20 /

editor = grapesjs.init({
   container: '#gjs',
   plugins: ['gjs-preset-newsletter'],
   pluginsOpts: {
      'gjs-preset-newsletter': {
       }
   },
});

// Doesn't work
editor.runCommand('gjs-get-inlined-html')

editor.on('change:changesCount', e => {
    // Work after first edition
    editor.runCommand('gjs-get-inlined-html')
});

Thanks :)