|
@@ -21,7 +21,7 @@ class InlineTag extends Component {
|
|
|
this.$span = React.createRef();
|
|
|
this.state = {
|
|
|
editable:false,
|
|
|
- value:props.value
|
|
|
+ value:props.value||''
|
|
|
};
|
|
|
this.changeToEdit = this.changeToEdit.bind(this);
|
|
|
this.changeToClick = this.changeToClick.bind(this);
|
|
@@ -47,17 +47,30 @@ class InlineTag extends Component {
|
|
|
});
|
|
|
}
|
|
|
handleInput(e){ //输入时保存临时值,在修改灰显为黑色时判断用
|
|
|
+ const {handleInput,ikey,prefix,suffix} = this.props;
|
|
|
const text = e.target.innerText || e.target.innerHTML;
|
|
|
+ // 内容全部删除时,要把空值存到store,否则会遗留最后一个字且为灰色无法删除
|
|
|
+ if(!text){
|
|
|
+ this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML=''); //修改生成文字变成输入的2倍bug
|
|
|
+ handleInput&&handleInput({text:text,ikey,prefix,suffix});
|
|
|
+ this.setState({
|
|
|
+ value:" "
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
this.setState({
|
|
|
value:text
|
|
|
});
|
|
|
- // e.target.innerText = text;
|
|
|
+ // e.target.innerText = text;
|
|
|
}
|
|
|
handleBlur(e){ //鼠标离开是保存值到store中
|
|
|
const {value} = this.state;
|
|
|
const {handleInput,ikey,prefix,suffix} = this.props;
|
|
|
this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML=''); //修改生成文字变成输入的2倍bug
|
|
|
- handleInput&&handleInput({text:value,ikey,prefix,suffix});
|
|
|
+ handleInput&&handleInput({text:value.trim(),ikey,prefix,suffix});
|
|
|
+ this.setState({
|
|
|
+ value:value.trim()
|
|
|
+ });
|
|
|
}
|
|
|
handleFocus(e){
|
|
|
e.stopPropagation();
|