Selaa lähdekoodia

起始可以是非文本标签

zhouna 5 vuotta sitten
vanhempi
commit
b4f5f7e706

+ 6 - 1
src/common/components/InlineTag/index.jsx

@@ -115,6 +115,10 @@ class InlineTag extends Component {
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   componentDidMount(){
     //设置最小宽度避免输入后宽度跳动
     this.$span.current.innerHTML=this.props.placeholder;
@@ -125,7 +129,8 @@ class InlineTag extends Component {
     const {prefix,suffix,isExtBlue} = this.props;
     return <div className={this.getStyle()}
                 onClick={this.handleFixClick}
-                onMouseUp={this.handleMouseUp.bind(this)}>
+                onMouseUp={this.handleMouseUp.bind(this)}
+                onMouseDown={this.handleMouseDown.bind(this)}>
                 <span className="prefixUnset">{prefix}</span>
                 <span className={`${style['free-in']}`}
                       contentEditable={true}

+ 6 - 1
src/components/MultSpread/index.jsx

@@ -246,6 +246,10 @@ class MultSpread extends Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   componentDidMount(){
     //挂载完成保存有加号的项目数据
     const {saveAddItem,fullData,copyId,showAdd} = this.props;
@@ -269,7 +273,8 @@ class MultSpread extends Component{
     const {showAdd,addLabelItem,ikey,copyId,textPrefix,textSuffix,isExtBlue} = this.props;
     return (<div className={this.getContClass()}
                  style={{display:'inline-block'}}
-                 onMouseUp={this.handleMouseUp.bind(this)}>
+                 onMouseUp={this.handleMouseUp.bind(this)}
+                 onMouseDown={this.handleMouseDown.bind(this)}>
         {textPrefix?<span className="prefixUnset">{textPrefix}</span>:''}
         <div className={this.getClass()}>
           {this.getLabels()}

+ 5 - 1
src/components/Multiple/index.jsx

@@ -167,7 +167,10 @@ class Multiple extends react.Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
-
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   componentDidMount(){
     if(isIE()){
       $(this.$div.current).onIe8Input(function(e){
@@ -187,6 +190,7 @@ class Multiple extends react.Component{
       onInput={this.onChange}
       onKeyDown={handleEnter}
       onMouseUp={this.handleMouseUp.bind(this)}
+      onMouseDown={this.handleMouseDown.bind(this)}
       contentEditable={editable}>{value||placeholder}</div>
       <div className={this.getListClass()} contentEditable="false">
         <SlideItem

+ 6 - 1
src/components/NumberDrop/index.jsx

@@ -222,6 +222,10 @@ class NumberDrop extends Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   componentDidMount(){
     //设置最小宽度避免输入后宽度跳动
     const spanWidth = window.getComputedStyle(this.$span.current).width;
@@ -259,7 +263,8 @@ class NumberDrop extends Component{
     return <div className={this.getClasses(nospecial)}
                 style={{position:'relative'}}
                 onClick={allClick?this.handleNumClick:null}
-                onMouseUp={this.handleMouseUp.bind(this)}>
+                onMouseUp={this.handleMouseUp.bind(this)}
+                onMouseDown={this.handleMouseDown.bind(this)}>
       <span className={`${setFontColorSize(val?'':isSelectAll?2:isExtBlue?2:1)}`}>{prefix}</span>
       <span onFocus={this.handleNumFocus}
             onClick={allClick?null:this.handleNumClick}

+ 5 - 0
src/components/NumberUnitDrop/index.jsx

@@ -74,6 +74,10 @@ class NumberUnitDrop extends Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   getClasses(){         //整个标签是否有值的状态
     const {value,hideTag,show,isImports,isExtBlue,mouseSelect} = this.props;
     const inpValue = this.state.value;
@@ -104,6 +108,7 @@ class NumberUnitDrop extends Component{
     return <div className={this.getClasses()}
                 ref={this.$cont}
                 onMouseUp={this.handleMouseUp.bind(this)}
+                onMouseDown={this.handleMouseDown.bind(this)}
                 onClick={this.handleNumClick}>
       <span ref = {this.$pre} className="prefixUnset">{prefix?prefix+' ':prefix}</span>
       <span ref = {this.$span}

+ 5 - 0
src/components/RadioDrop/index.jsx

@@ -155,6 +155,10 @@ class RadioDrop extends Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   render(){
     const {data,placeholder,show,value,hideTag,boxMark} = this.props;
     const {tmpDom} = this.state
@@ -169,6 +173,7 @@ class RadioDrop extends Component{
            onFocus={(e)=>{e.stopPropagation()}}
            onClick={(e)=>this.handleShow(e,true)}
            onMouseUp={this.handleMouseUp.bind(this)}
+           onMouseDown={this.handleMouseDown.bind(this)}
            onKeyDown={handleEnter}>
         {value||placeholder}
       </div>

+ 5 - 0
src/components/RadioInpDrop/index.jsx

@@ -102,6 +102,10 @@ class RadioInpDrop extends Component{
       setSelectArea({i,boxMark,dir:'end'});
     }
   }
+  handleMouseDown(){
+    const {i,setSelectArea,boxMark}= this.props;
+    setSelectArea({i,boxMark,dir:'start'});
+  }
   parseInputDom(){
     const {mainSaveText,ikey,boxMark} = this.props;
     const {texts} = this.state;
@@ -130,6 +134,7 @@ class RadioInpDrop extends Component{
       <div className={this.getClass()}
            onClick={(e)=>this.handleShow(e)}
            onMouseUp={this.handleMouseUp.bind(this)}
+           onMouseDown={this.handleMouseDown.bind(this)}
            onKeyDown={handleEnter}>
         {vals?this.parseInputDom():<span className='inheritStyle'>{placeholder}</span>}
       </div>

+ 1 - 0
src/containers/eleType.js

@@ -201,6 +201,7 @@ export default function(params){
   }
   const isInArea = start!==undefined&&end!==undefined&&(start<i||start==i)&&(end>i||end==i);
   params.mouseSelected = select_boxMark===boxMark&&isInArea;
+  //console.log(select_start,select_end,select_boxMark,isInArea,boxMark)
   const data = params.item;
   switch (+data.tagType) {
     case 1: