|
@@ -1,7 +1,7 @@
|
|
|
import React,{Component} from 'react';
|
|
|
import style from './index.less';
|
|
|
import config from "@config/index";
|
|
|
-import {filterArr,isIE,getPageCoordinate,filterDataArr,preventDefault,setFontColorSize} from '@utils/tools.js';
|
|
|
+import {filterArr,isIE,getPageCoordinate,filterDataArr,preventDefault,setFontColorSize,moveEnd} from '@utils/tools.js';
|
|
|
import Notify from '../Notify/index.js';
|
|
|
import classNames from 'classnames';
|
|
|
|
|
@@ -37,7 +37,6 @@ class EditableSpan extends Component{
|
|
|
this.handleBlur = this.handleBlur.bind(this);
|
|
|
this.handleKeydown = this.handleKeydown.bind(this);
|
|
|
this.handleKeyup = this.handleKeyup.bind(this);
|
|
|
- this.moveEnd = this.moveEnd.bind(this);
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
}
|
|
|
handleFocus(e){
|
|
@@ -49,7 +48,7 @@ class EditableSpan extends Component{
|
|
|
setTimeout(function(){
|
|
|
txt = that.$span.current.innerText||that.$span.current.innerHTML;
|
|
|
that.$span.current.innerHTML = txt;
|
|
|
- that.moveEnd($(that.$span.current)[0]); //光标落到最后去
|
|
|
+ moveEnd($(that.$span.current)[0]); //光标落到最后去
|
|
|
});
|
|
|
})
|
|
|
|
|
@@ -138,31 +137,6 @@ class EditableSpan extends Component{
|
|
|
$(this.$span.current).off("paste");
|
|
|
}
|
|
|
|
|
|
- moveEnd(obj,flg) {
|
|
|
- if(window.getSelection){//ie11 10 9 ff safari
|
|
|
- setTimeout(() => {
|
|
|
- obj.focus(); //解决ff不获取焦点无法定位问题
|
|
|
- var range = window.getSelection();//创建range
|
|
|
- range.selectAllChildren(obj);//range 选择obj下所有子内容
|
|
|
- if(flg){
|
|
|
- range.collapseToStart();//光标移至开头
|
|
|
- }else{
|
|
|
- range.collapseToEnd();//光标移至最后
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- else if (document.selection) {//ie10 9 8 7 6 5
|
|
|
- var range = document.selection.createRange();//创建选择对象
|
|
|
- range.moveToElementText(obj);//range定位到obj
|
|
|
- if(flg){
|
|
|
- range.collapse(true);//光标移至开头
|
|
|
- }else{
|
|
|
- range.collapse(false);//光标移至最后
|
|
|
- }
|
|
|
- range.select();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
handleKeydown(e){
|
|
|
const ev = e||window.event;
|
|
|
const {i} = this.props;
|