Kaynağa Gözat

解决高亮错位问题

zhuliu 1 yıl önce
ebeveyn
işleme
8f329704de
1 değiştirilmiş dosya ile 16 ekleme ve 12 silme
  1. 16 12
      src/utils/model/RichText/mixins.js

+ 16 - 12
src/utils/model/RichText/mixins.js

@@ -127,18 +127,22 @@ export default {
             var currentIndex = 0
             var currentIndex1 = 0
             for(var i = 0;i<data.length;i++){
+                var a = data[i].text
+                if(data[i].text.indexOf('&nbsp;')!=-1){
+                    a = data[i].text.replace(/&nbsp;/g,' ')
+                }
                 if(data[i].type == 'text'){
                     if(this.selectObj.startIndex >= currentIndex && this.selectObj.startIndex<currentIndex + data[i].text.length && !sign){
                         startIndex = i
                         sign = true
                     }else{
                         if(!sign){
-                            if(data[i].text.indexOf('&nbsp;')!=-1){
-                                var a = data[i].text.replace(/&nbsp;/g,' ')
-                                currentIndex += a.length
-                                continue
-                            }
-                            currentIndex += data[i].text.length
+                            // if(data[i].text.indexOf('&nbsp;')!=-1){
+                            //     var a = data[i].text.replace(/&nbsp;/g,' ')
+                            //     currentIndex += a.length
+                            //     continue
+                            // }
+                            currentIndex += a.length
                         }
                         
                     }
@@ -146,12 +150,12 @@ export default {
                         endIndex = i
                         break
                     }else{
-                        if(data[i].text.indexOf('&nbsp;')!=-1){
-                            var a = data[i].text.replace(/&nbsp;/g,' ')
-                            currentIndex1 += a.length
-                            continue
-                        }
-                        currentIndex1 += data[i].text.length
+                        // if(data[i].text.indexOf('&nbsp;')!=-1 && sign){
+                        //     var a = data[i].text.replace(/&nbsp;/g,' ')
+                        //     currentIndex1 += a.length
+                        //     continue
+                        // }
+                        currentIndex1 += a.length
                     }
                 }
             }