Closed woahdae closed 2 years ago
The included index.html
file is meant for development so it won't work unless you setup a development environment and run the development server(https://github.com/Ju99ernaut/grapesjs-plugin-toolbox#development). A reproduction of the issue would be helpful but if you're using a node environment you should install the plugin like this:
import grapesjs from 'grapesjs';
import toolbox from 'grapesjs-plugin-toolbox';
import 'grapesjs/dist/css/grapes.min.css';
import 'grapesjs-plugin-toolbox/dist/grapesjs-plugin-toolbox.min.css';
const editor = grapesjs.init({
container : '#gjs',
// ...
plugins: [toolbox],
pluginsOpts: {
[toolbox]: { /* options */ }
}
// or
plugins: [
editor => toolbox(editor, { /* options */ }),
],
});
Ah, cool, thanks. I'm using native ES6 import maps (or the import map polyfill where needed).
The toolbox code here does export default (editor, opts = {}) => {
, and what I get from importing is a Module with a default
attribute containing the exported function. I don't know about the export default () => {
style in the context of browser-native import - seems like it's wrapping that in an extra concept instead of exporting the intended function correctly.
I could dig deeper, but I have my answer - replacing toolbox
with toolbox.default
in your examples works great. Thanks!
If you're interested in fixing the issue, I could set up a repro, but if you think it's fine as is I won't bother.
I think iwe can leave it as is at the moment since the current format seems to work in most cases.
I see the demo works, but the included
index.html
doesn't locally, and for the life of me I can't get the distributed NPM package to load in a way where GrapesJS recognizesgrapesjs-plugin-toolbox
as a plugin. I also don't see where in the code it callsgrapesjs.plugins.add('grapesjs-plugin-toolbox', [...])
like other plugins do.Would you like a reproduction of the issue, or is there an implied trick I'm not doing? All I'm attempting is loading the plugin source and adding it to the
plugins: [...]
config section as per the docs.