Selaa lähdekoodia

文本模式黏贴2255

zhouna 5 vuotta sitten
vanhempi
commit
2d4c913a8f
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      src/common/components/Textarea/index.jsx

+ 12 - 0
src/common/components/Textarea/index.jsx

@@ -26,6 +26,16 @@ class Textarea extends Component {
   }
   handleFocus(e){            //初始显示props中的值,focus已经显示输入的值,避免值更新闪烁
     const {handleFocus,fuzhen,handleInput,isChronic,hasMain,boxMark} = this.props;
+    //黏贴时去掉html格式
+    const that = this;
+    let txt = '';
+    $(this.$dom.current).on("paste",function(e){
+      setTimeout(function(){
+        txt = that.$dom.current.innerText||that.$dom.current.innerHTML;
+        that.$dom.current.innerHTML = txt;
+        that.moveEnd($(that.$dom.current)[0]);     //光标落到最后去
+      });
+    });
     //const {inpText} = this.state;console.log(inpText,boxMark,hasMain)
     if(boxMark!='1'&&!hasMain&&!e.target.innerText){
       //现病史、其他史无主诉且本身无内容是聚焦提示无法操作
@@ -104,6 +114,8 @@ class Textarea extends Component {
   handleBlur(e){
     const {saveChronic} = this.props;
     const text = e.target.innerText || e.target.innerHTML;
+    //解除绑定事件
+    $(this.$dom.current).off("paste");
     getFeature(text).then((res)=>{
       if(res.data.code==0){
         const result = res.data.data;