BUG When import as module Angular 6
Question
in Version: "grapesjs": "^0.14.61", "grapesjs-preset-newsletter": "^0.2.20",
i import the script as:
import grapesjs from "grapesjs";
import grapesjsPresetNewsletter from "grapesjs-preset-newsletter";
and the context is the code:
ngOnInit() {
this.editor = grapesjs.init({
container: "#gjs",
components: `<div class="txt-red">Hello world!</div>`,
style: ".txt-red{color: red}",
plugins: [
// "gjs-preset-newsletter"
grapesjsPresetNewsletter
],
pluginsOpts: {
"gjs-preset-newsletter": {
modalTitleImport: "Importar Template",
importPlaceholder: "Inserte aquí el HTML y CSS inline",
inlineCss: true,
},
}
});
}
And only on build, the console print:
main.011758c7e31c6528fe91.js:1 ERROR TypeError: i is not a function
at 15.aacc28347512f1c58ef9.js:1
at 15.aacc28347512f1c58ef9.js:1
at 15.aacc28347512f1c58ef9.js:1
at Array.forEach (<anonymous>)
at Object.init (15.aacc28347512f1c58ef9.js:1)
at e.ngOnInit (15.aacc28347512f1c58ef9.js:1)
at main.011758c7e31c6528fe91.js:1
at main.011758c7e31c6528fe91.js:1
at bo (main.011758c7e31c6528fe91.js:1)
at qo (main.011758c7e31c6528fe91.js:1)
Please Help me. Thanks for your time.
Answers (3)
@nternouski I'm guessing you needed to include the gjs-preset-newsletter script in the scripts section of your build in angular.json.
"scripts": [
"./node_modules/grapesjs/dist/grapes.min.js",
"./node_modules/grapesjs-preset-webpage/dist/grapesjs-preset-webpage.min.js",
"./node_modules/grapesjs-blocks-bootstrap/dist/grapesjs-blocks-bootstrap4.min.js"
]
Any plugins you want to use need to be included here or the angular build won't know to include them.
If you don't add it globally, you'll need to manually register the plugin with grapesjs.
import grapesjs from "grapesjs";
import grapesjsPresetNewsletter from "grapesjs-preset-newsletter";
grapesjs.plugins.add('grapesjs-preset-newsletter', grapesjsPresetNewsletter );
Then, be sure to use the ID you configured and not the variable name when initializing.
ngOnInit() {
this.editor = grapesjs.init({
container: "#gjs",
plugins: [ "gjs-preset-newsletter" ]
});
}
Hi @nternouski, unfortunately, that plugin still uses the old exporting, so you have to use it like this:
import grapesjs from "grapesjs";
import "grapesjs-preset-newsletter";
...
grapesjs.init({
...
plugins: ["gjs-preset-newsletter"],
...
})
Related Questions and Answers
Continue research with similar issue discussions.
Issue #519
No Blocks by default
Using this code I get an editor but there are no blocks. I also do not get the icons for the screen size but other icons are there. As you...
Issue #1505
adding row and sections not working
i am integrating grapejs with angular6. but it is not working means it is not showing on blocks i am using following code
Issue #507
uploadFile being called twice on drop file?
I have an editor initialized as so: If I add an image to the canvas and try to upload a new image by dragging it into the drop area in the...
Issue #3071
BUG: update listener triggered on initial load
Hello! I found weird bug with update listener. It's triggered on initial load if html code has <img> tag with class attribute: You can chec...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.