Notice 第二阶段

This commit is contained in:
Connor
2021-07-06 16:39:58 +08:00
parent c35d84dd80
commit f5762bfade
11 changed files with 541 additions and 43 deletions

View File

@@ -1,20 +1,19 @@
import React, { Component } from 'react'
import { Col, Input, InputNumber, Row } from 'antd'
import { AntIcon } from 'components'
import BraftEditor from 'braft-editor'
import 'braft-editor/dist/index.css'
export default class index extends Component {
state = {
editorState: BraftEditor.createEditorState(this.props.value), // 设置编辑器初始内容
editorState: '',
outputHTML: '',
}
/**
* mount后回调
*/
componentDidMount() {
// 3秒后更改编辑器内容
setTimeout(this.setEditorContentAsync, 2000)
this.isLivinig = true
this.toParent()
}
componentWillUnmount() {
this.isLivinig = false
@@ -33,23 +32,26 @@ export default class index extends Component {
}
setEditorContentAsync = () => {
const { placeholder, value, onChange } = this.props
this.isLivinig &&
this.setState({
editorState: BraftEditor.createEditorState(value),
editorState: BraftEditor.createEditorState(this.props.value),
})
}
render() {
const { editorState, outputHTML } = this.state
//localStorage.setItem('props', JSON.stringify(this.props))
//给父控件 调用这个方法 因为只有父控件才能掌握页面加载完的时间
toParent = () => {
this.props.parent.getChildrenMsg(this.setEditorContentAsync)
}
render() {
const { editorState } = this.state
const controls = ['bold', 'italic', 'underline', 'text-color', 'separator']
return (
<BraftEditor
value={editorState}
controls={controls}
onChange={this.handleChange}
placeholder={'输入内容'}
placeholder={'输入内容'}
/>
)
}