|
@@ -13,11 +13,10 @@ class Textarea extends Component {
|
|
|
this.$dom = React.createRef();
|
|
|
this.$domW = React.createRef();
|
|
|
this.handleInput = this.handleInput.bind(this);
|
|
|
- this.handleBlur = this.handleBlur.bind(this);
|
|
|
}
|
|
|
handleInput(e){
|
|
|
const {handleChangeAssistValue,idx,handlePush} = this.props;
|
|
|
- const text = e.target.innerText;
|
|
|
+ const text = e.target.innerText || e.target.innerHTML;
|
|
|
const stimer = this.state.timer;
|
|
|
handleChangeAssistValue&&handleChangeAssistValue(text,idx);
|
|
|
//右侧推送--延时推送
|
|
@@ -26,10 +25,13 @@ class Textarea extends Component {
|
|
|
handlePush&&handlePush();
|
|
|
clearTimeout(stimer);
|
|
|
},config.delayPushTime);
|
|
|
- if(text.trim() != ''){
|
|
|
+
|
|
|
+ if(text.trim() != '' && text != '<br>'){
|
|
|
e.target.nextSibling.innerText = ''
|
|
|
+ e.target.nextSibling.innerHTML = ''
|
|
|
}else{
|
|
|
e.target.nextSibling.innerText = '报告描述或意见'
|
|
|
+ e.target.nextSibling.innerHTML = '报告描述或意见'
|
|
|
}
|
|
|
this.setState({
|
|
|
timer
|
|
@@ -44,25 +46,18 @@ class Textarea extends Component {
|
|
|
componentWillReceiveProps(next){
|
|
|
const isRead = this.props.isRead;
|
|
|
if(next.isRead != isRead){
|
|
|
- this.$dom.current.innerText = next.value||'';
|
|
|
- }
|
|
|
- if(next.value && next.value.trim() != ''){
|
|
|
- this.$dom.current.nextSibling.innerText = ''
|
|
|
+ this.$dom.current.innerText?(this.$dom.current.innerText = next.value||'') : (this.$dom.current.innerHTML = next.value||'')
|
|
|
}
|
|
|
}
|
|
|
componentDidMount(){
|
|
|
const {value} = this.props;
|
|
|
if(value && value.trim()){
|
|
|
- this.$dom.current.innerText = value||'';
|
|
|
+ this.$dom.current.innerText?(this.$dom.current.innerText = value) : (this.$dom.current.innerHTML = value)
|
|
|
this.$dom.current.nextSibling.innerText = '';
|
|
|
+ this.$dom.current.nextSibling.innerHTML = '';
|
|
|
}else{
|
|
|
this.$dom.current.nextSibling.innerText = '报告描述或意见'
|
|
|
- }
|
|
|
- }
|
|
|
- handleBlur(e){
|
|
|
- let str = e.target.innerText
|
|
|
- if(str.trim() == ''){
|
|
|
- e.target.nextSibling.innerText = '报告描述或意见'
|
|
|
+ this.$dom.current.nextSibling.innerHTML = '报告描述或意见'
|
|
|
}
|
|
|
}
|
|
|
render() {
|
|
@@ -73,7 +68,6 @@ class Textarea extends Component {
|
|
|
contenteditable={true}
|
|
|
ref={this.$dom}
|
|
|
onInput={this.handleInput}
|
|
|
- onBlur={this.handleBlur}
|
|
|
onPropertyChange={this.handleInput}
|
|
|
></div>
|
|
|
<p style={{position: "absolute",left: '0',top: '0',color: "#a5a3a3",zIndex: '5'}} className="textareaWarring"></p>
|