nonespace
11/4/2018 - 3:53 PM

react-quill

import React from 'react'
import { Table, Divider, Tag } from 'antd';
import ReactQuill from 'react-quill'
import 'react-quill/dist/quill.bubble.css';
import 'react-quill/dist/quill.snow.css';
export default class IndexPage extends React.Component {
    constructor(){
        super()
        this.state={
            value:''
        }
    }
    modules = {
        toolbar: [
            ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
            ['blockquote', 'code-block'],

            [{ 'header': 1 }, { 'header': 2 }],               // custom button values
            [{ 'list': 'ordered' }, { 'list': 'bullet' }],
            [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
            [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
            [{ 'direction': 'rtl' }],                         // text direction

            [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
            [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

            [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
            [{ 'font': [] }],
            [{ 'align': [] }],
            ['link', 'image', 'video'],
            ['clean']  
        ],
    };

    // formats = [
    //     'bold', 'italic', 'underline', 'strike', 'blockquote',
    //     'list', 'bullet', 'indent',
    //     'link', 'image','code'
    // ];
    render() {
        return (
            <div style={{display:'block'}}>
                <ReactQuill
                    theme="snow"
                    modules={this.modules}
                    formats={this.formats}
                    onChange={(value) => {
                        console.log(value)
                         this.setState({value:value})}}
                    defaultValue={this.state.value}
                    getHTML()
               
            />
                {/* <ReactQuill
                    // theme="snow"
                    modules={this.modules}
                    formats={this.formats}
                    value={this.state.value}
                    theme="bubble"
                /> */}
                {/* <div dangerouslySetInnerHTML={{ __html:this.state.value} }></div> */}
            </div>
        );
    }
}