Call parent method from within plugin
Probably you would need something like this in any case, seems really weird that the minifer makes such an unsafe removal. I use something similar here and it doesn't break
Read full answer below ↓Question
Hi @artf,
What would be the recommended way of calling a grapesjs method from within a plugin?
The grapesjs-mjml plugin uses this.MethodName() (https://github.com/artf/grapesjs-mjml/blob/7a9712ce7a401079f31932a7fe2c342657e85efa/src/components/index.js#L248)
However when the plugin gets minified in the production bundle, the plugin no longer works since there is no direct inheritance w/ grapesjs.
Is there a way to call the functions/variables from the Editor object directly? since this is the only variable that gets directly passed to the plugin. So for example this.methodName() would become editor.View.methodName() or something similar.
EDIT: example of downstream issues: https://github.com/artf/grapesjs-mjml/issues/155, https://github.com/artf/grapesjs-mjml/issues/166
Answers (1)
Probably you would need something like this
const View = editor.DomComponents.getType('default').view;
View.prototype.renderAttributes.apply(this);
in any case, seems really weird that the minifer makes such an unsafe removal. I use something similar here and it doesn't break
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3367
Modal template
Is there a way for me to modify the template from a compiled state? https://github.com/artf/grapesjs/blob/d3256e621bb43a537213ffcd86b10dc0b...
Issue #3130
[Question] Standard approach in slight restructuring the HTML toolbar & badge
Version: 0.15.10 This question is intended to validate if there is a proper way to extend the current https://github.com/artf/grapesjs/blob...
Issue #3235
"component:update" does not trigger when components are moved
Taken from https://github.com/artf/grapesjs/blob/dev/src/editor/index.js#L33 component:update - Triggered when a component is updated (move...
Issue #4735
resetId types mismatch
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? n/a Reproducible demo link n/a Describe th...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.