GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

Is it possible to create a component using react components? #2629

Closed vitor-peixoto closed 4 years ago

vitor-peixoto commented 4 years ago

is it possible to create or get a react component from some library and insert as a allowed component for create a template?

import React from 'react';
import CustomButton from './components/CustomButton'
import grapesjs from 'grapesjs'

const editor = grapesjs.init({
...
});

editor.addComponents(<CustomButton color="red" otherProp={...somepros}/>);

//or 

editor.BlockManager.add('CustomButton', {
  label: 'button',
  content: <CustomButton color="red" otherProp={...somepros}/>,
});
pouyamiralayi commented 4 years ago

@TRUEND here is an example Cheers!