zoukankan      html  css  js  c++  java
  • braft-editor编辑器的使用

    一、

    import React, { Component } from 'react'
    import BraftEditor from 'braft-editor'
    import 'braft-editor/dist/index.css'
    
    export default class Main extends Component {
    
      state = {
        editorState: BraftEditor.createEditorState('<p>初始值</p>'), // 设置编辑器初始内容
        outputHTML: '<p></p>' // 编辑器输出内容
      }
    
      componentDidMount () {
        this.setState({
          editorState: BraftEditor.createEditorState('<p>hello,<b>world!</b><p>')
        })
      }
    
      handleChange = (editorState) => {
        this.setState({
          editorState: editorState,
          outputHTML: editorState.toHTML()
        }, () => {
          console.log(editorState)
          console.log(this.state.outputHTML)
        })
      }
    
      render () {
        const { editorState, outputHTML } = this.state
        
        return (
          <div>
            <div className="editor-wrapper">
              <BraftEditor
                value={editorState}
                onChange={this.handleChange}
                style={{ height: 600,marginLeft: 100,marginRight: 100, overflow: "hidden" ,boxShadow: 'inset 0 1px 3px rgba(0,0,0,.1)'}}
                contentStyle={{boxShadow: 'inset 0 1px 3px rgba(0,0,0,.1)'}}
              />
            </div>
          </div>
        )
      }
    }
    点到为止
  • 相关阅读:
    SpringBoot优雅的全局异常处理
    react格式化展示json
    Pycharm调试按钮
    HttpURLConnection和okhttp的使用
    objection自动生成hook代码
    hookString
    python取中位数 位运算
    scrapy mongo pipeline
    xpath tips
    IT日语
  • 原文地址:https://www.cnblogs.com/fger/p/14346166.html
Copyright © 2011-2022 走看看