|
@@ -17,7 +17,7 @@ class Textarea extends Component {
|
|
|
this.$dom = React.createRef();
|
|
|
this.handleInput = this.handleInput.bind(this);
|
|
|
this.handleFocus = this.handleFocus.bind(this);
|
|
|
- //this.handleBlur = this.handleBlur.bind(this);
|
|
|
+ this.handleBlur = this.handleBlur.bind(this);
|
|
|
}
|
|
|
handleFocus(){ //初始显示props中的值,focus已经显示输入的值,避免值更新闪烁
|
|
|
const {handleFocus,fuzhen,handleInput} = this.props;
|
|
@@ -58,7 +58,7 @@ class Textarea extends Component {
|
|
|
})
|
|
|
|
|
|
//存值到store
|
|
|
- handleInput&&handleInput({text});
|
|
|
+ // handleInput&&handleInput({text});
|
|
|
//右侧推送--延时推送
|
|
|
clearTimeout(stimer);
|
|
|
let timer = setTimeout(function(){
|
|
@@ -84,7 +84,7 @@ class Textarea extends Component {
|
|
|
componentDidMount(){
|
|
|
const {value} = this.props;
|
|
|
if(value){
|
|
|
- this.$dom.current.innerText?(this.$dom.current.innerText = value||''):(this.$dom.current.innerText=value||'');
|
|
|
+ this.$dom.current.innerText?(this.$dom.current.innerText = value||''):(this.$dom.current.innerHTML=value||'');
|
|
|
}
|
|
|
if(isIE()){
|
|
|
$(this.$dom.current).onIe8Input(function(e){
|
|
@@ -92,6 +92,12 @@ class Textarea extends Component {
|
|
|
},this);
|
|
|
}
|
|
|
}
|
|
|
+ handleBlur(){
|
|
|
+ const {handleInput} = this.props;
|
|
|
+ const text = this.$dom.current.innerText||this.$dom.current.innerHTML;
|
|
|
+ //存值到store
|
|
|
+ handleInput&&handleInput({text});
|
|
|
+ }
|
|
|
render() {
|
|
|
const { title } = this.props;
|
|
|
return (
|
|
@@ -102,7 +108,8 @@ class Textarea extends Component {
|
|
|
onFocus={this.handleFocus}
|
|
|
ref={this.$dom}
|
|
|
contentEditable={true}
|
|
|
- onInput={this.handleInput}>
|
|
|
+ onInput={this.handleInput}
|
|
|
+ onBlur={this.handleBlur}>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|