GrapesJS component:mount bug
by artur_arseniev
HTML
<script src="https://unpkg.com/grapesjs"></script>
<link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
<script src="https://unpkg.com/grapesjs-blocks-basic"></script>
<div id="gjs">
<div style="padding: 25px">Hello World!!!</div>
</div>
CSS
body, html {
margin: 0;
height: 100%;
}
Babel + JSX
const editor = grapesjs.init({
container: '#gjs',
fromElement: 1,
height: '100%',
storageManager: { type: 0 },
plugins: ['gjs-blocks-basic']
});
editor.on('component:mount', component => {
if (component.is('text')) {
component.set('highlightable', false);
component.set('selectable', false);
component.set('hoverable', false);
}
});
editor.on('component:selected', component => {
component.components().map(child => {
child.set('highlightable', true);
child.set('hoverable', true);
child.set('selectable', true);
});
setTimeout(() => {
editor.refresh();
editor.trigger('component:toggled');
})
console.log('refershsssss 33');
});