[BUG] Not able to use plugin: grapesjs-custom-code
Question
- I am trying to add "custom code plugin" but getting an error in console that "Plugin grapesjs-custom-code not found"
- I have created an react app and this is part of a reach component. Note that this is working fine when I add the plugin from a html page rather than react component.
- This issue is only with "grapesjs-custom-code". "gjs-preset-webpage" is working fine
I may be doing something silly wrong in my react component or there may be a bug. I have been trying to figure this out for hours and need some help please.
**Following is my react component code**
import React, { Component } from 'react';
import 'grapesjs/dist/css/grapes.min.css';
import 'grapesjs-preset-webpage/dist/grapesjs-preset-webpage.min.css';
import grapesjs from 'grapesjs';
import 'grapesjs-custom-code';
import 'grapesjs-preset-webpage';
export default class grapesjsPresetWebpageWithCustomComponent extends Component {
//Prevents ReactJS from working on the same DOM elements as grapesjs. This is
//needed to include a non react library under react. See ref at
// https://medium.com/@garrettmac/reactjs-how-to-safely-manipulate-the-dom-when-reactjs-cant-the-right-way-8a20928e8a6
shouldComponentUpdate() {
return false;
}
componentDidMount(){
var editor = grapesjs.init({
container : '#gjs',
plugins: ['gjs-preset-webpage', 'grapesjs-custom-code'],
pluginsOpts: {
'grapesjs-custom-code': {
// options
},
'gjs-preset-webpage': {
// options
},
}
});
}
render() {
return (
<div>
Render Grapesjs here*********
<div id="gjs"></div>
</div>
)
}
}
**Following html code works fine:**
<HTML>
<HEAD>
<link rel='stylesheet' href='https://unpkg.com/formiojs@latest/dist/formio.full.min.css'>
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<link href="../node_modules/grapesjs-preset-webpage/dist/grapesjs-preset-webpage.min.css" rel="stylesheet"/>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<script src="https://unpkg.com/grapesjs"></script>
<script src="../node_modules/grapesjs-custom-code/dist/grapesjs-custom-code.min.js"></script>
<script src="../node_modules/grapesjs-preset-webpage/dist/grapesjs-preset-webpage.min.js"></script>
<script src='https://unpkg.com/formiojs@latest/dist/formio.full.min.js'></script>
<div id="gjs"></div>
<script type="text/javascript">
/***/
/***/
var editor = grapesjs.init({
container : '#gjs',
plugins: ['gjs-preset-webpage', 'grapesjs-custom-code'],
pluginsOpts: {
'grapesjs-custom-code': {
// options
},
'gjs-preset-webpage': {
// options
}
}
});
/***/
</script>
</BODY>
</HTML>Answers (2)
Hi @megarg actually new plugins (presets are not yet updated) use a new export format which makes this import import 'grapesjs-custom-code'; not usable. You can see the example of usage of new plugins here
Let me provide some more details: -----Configuration----- $ node -v v10.15.3
$ npx node-sass -v node-sass 4.12.0 (Wrapper) [JavaScript] libsass 3.5.4 (Sass Compiler) [C/C++]
OS is: Windows 10
Will really appreciate any pointers on why this plugin is giving this error.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3575
grapes.min.js:2 Uncaught TypeError: Cannot read property 'length' of undefined
I got this error when add the <iframe src="https://app.conversiobot.com/boot/fvMEvO" width="100%" height="500" frameBorder="0" allow="geolo...
Issue #6152
BUG: CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #2771
[BUG] component with textable:1 not working since version 0.16.12
Hello, I've just updated to the lasted version 0.16.12 and have a bug when trying to move a component that has the property textable:1 into...
Issue #3457
BUG: Custom trait input not working
Hi @artf ! Version: 0.17.3 Are you able to reproduce the bug from the demo?[ ] Yes[x] No What is the expected behavior? The input is create...
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.