Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] a way to provide a parser override #113

Closed
DRoet opened this issue Jul 26, 2019 · 2 comments
Closed

[Feature Request] a way to provide a parser override #113

DRoet opened this issue Jul 26, 2019 · 2 comments

Comments

@DRoet
Copy link
Collaborator

DRoet commented Jul 26, 2019

Hi,

Since mjml4-in-browser is only being used to compile the mjml -> html, I was wondering if there is a way to create an override to the current parse method, to allow users to compile the mjml on the server instead.

something like:

const editor = grapesjs.init({
  fromElement: 1,
  container : '#gjs',
  plugins: ['grapesjs-mjml'],
  pluginsOpts: {
    'grapesjs-mjml': {
      parser: async function (mjml) {
        const res = await axios.post("/parser", {
          mjml: mjml
        })
        // this returns the html
        return res.data
      }
    }
  }
});

pros:

  • this way the mjml4-in-browser package could become an optional peerDependency and would probably shave off a lot of the bundle size.
  • parsing mjml in the browser can be quite heavy, so this should be less stress on the browser
  • no future problems with running mjml in the browser since it is a node.js package

cons:

  • parsing delay since you are now depending on network requests, needs error handling.

I don't have any experience with the grapesjs internals so I was just wondering if building something like this is even possible, @artf thoughts?

@larsdecker
Copy link
Contributor

I like the idea. I will look at the code and check if we can provide an option for it.

@artf
Copy link
Member

artf commented Aug 22, 2024

#341

@artf artf closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants