-
Notifications
You must be signed in to change notification settings - Fork 54
Home
Thanh Tùng edited this page Oct 18, 2019
·
3 revisions
The first integration of GrapesJS for React.
-
Installation
yarn add grapesjs-react
-
Usage Editor:
import React, {Component} from 'react'; import {GEditor} from 'grapesjs-react'; class GEditorExample extends Component { render() { return ( <GEditor/> ); } } export default GEditorExample;
Custom block src/example/CustomBlock.tsx:
import React from 'react'; import {GEditor, GBlock} from 'grapesjs-react'; import 'antd/dist/antd.min.css'; import 'bootstrap/dist/css/bootstrap.min.css'; class SimpleBlock extends GBlock { content = `<div class="simple-block"> This is a simple block </div>`; constructor() { super('simple-block', 'Simple Block'); } } function CustomBlock() { return ( <div className="container-fluid"> <div> <GEditor id="geditor" newsletter blocks={[ new SimpleBlock(), ]}/> </div> </div> ); } export default CustomBlock;
-
Options
Props Description Type Default Value components Custom components Array Empty plugins Additional plugins Array Empty newsletter Apply newsletter preset boolean false webpage Apply webpage preset boolean false
-
This package does not include CSS, so you have to import css from
grapesjs
package manually.import 'grapesjs/dist/css/grapes.min.css';