提交 4e2d1248 authored 作者: chscls@163.com's avatar chscls@163.com

富文本bug

上级 7528dc9b
......@@ -64,7 +64,6 @@ export default class DraftEditor extends React.Component {
constructor(props) {
super(props);
const value = props.value || {};
const editorState = changeToDraftState2(blocks)
this.state = {
editorState: value.editorState,
......
......@@ -83,11 +83,11 @@ export default class DraftEditorCom extends React.Component {
this.onChange = (editorState,callback) => {
if (!('value' in this.props)) {
this.setState({ editorState },()=>{
if(callback)callback()
});
}
this.triggerChange({ editorState },()=>{
if(callback)callback()
});
......@@ -141,12 +141,12 @@ export default class DraftEditorCom extends React.Component {
const xx = AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, text);
if (!('value' in this.props)) {
this.setState({ editorState: xx }, () => {
callback()
});
}
this.triggerChange({ editorState: xx}, () => {
callback()
......@@ -177,13 +177,13 @@ export default class DraftEditorCom extends React.Component {
);
}
componentWillReceiveProps(nextProps) {
/* componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('value' in nextProps) {
const value = nextProps.value;
this.setState({editorState: changeToDraftState(value)});
}
}
} */
......@@ -191,27 +191,27 @@ export default class DraftEditorCom extends React.Component {
}
insertAttr = () => {
if (!('value' in this.props)) {
this.setState({ modalVisible: true, fnKey: "attr" });
}
this.triggerChange({ modalVisible: true, fnKey: "attr" });
}
insertPic = () => {
if (!('value' in this.props)) {
this.setState({ modalVisible: true, fnKey: "image" });
}
this.triggerChange({ modalVisible: true, fnKey: "image" });
}
insertFormula = () => {
if (!('value' in this.props)) {
this.setState({ modalVisible: true, fnKey: "formula" });
}
this.triggerChange({ modalVisible: true, fnKey: "formula" });
}
insertVideo = () => {
if (!('value' in this.props)) {
this.setState({ modalVisible: true, fnKey: "video" });
}
this.triggerChange({ modalVisible: true, fnKey: "video" });
}
insertLink = () => {
......@@ -221,9 +221,9 @@ export default class DraftEditorCom extends React.Component {
message.error("请选择需要插入链接的内容")
return
}
if (!('value' in this.props)) {
this.setState({ modalVisible: true, fnKey: "link" });
}
this.triggerChange({ modalVisible: true, fnKey: "link" });
}
......@@ -244,9 +244,9 @@ export default class DraftEditorCom extends React.Component {
if (!('value' in this.props)) {
this.setState({ editorState: xx, modalVisible: false, });
}
this.triggerChange({ editorState: xx, modalVisible: false, });
}
......@@ -267,9 +267,9 @@ export default class DraftEditorCom extends React.Component {
if (!('value' in this.props)) {
this.setState({ editorState: xx, modalVisible: false, });
}
this.triggerChange({ editorState: xx, modalVisible: false, });
}
......@@ -286,13 +286,8 @@ export default class DraftEditorCom extends React.Component {
const xx = AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, '[图片]');
if (!('value' in this.props)) {
this.setState({ editorState: xx, modalVisible: false, });
}
this.triggerChange({ editorState: xx, modalVisible: false, });
}
......@@ -321,9 +316,9 @@ export default class DraftEditorCom extends React.Component {
entityKey
)
if (!('value' in this.props)) {
this.setState({ editorState: xx, modalVisible: false});
}
this.triggerChange({ editorState: xx, modalVisible: false});
}
......@@ -361,9 +356,9 @@ export default class DraftEditorCom extends React.Component {
blocks.blocks.splice(j,1)
const editorState = changeToDraftState2(blocks)
if (!('value' in this.props)) {
this.setState({ editorState });
}
this.triggerChange({ editorState });
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论