优化语法
This commit is contained in:
		@@ -90,16 +90,14 @@ export class Cursor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (key === "ArrowUp" && currentIndex > 0) {
 | 
					        if (key === "ArrowUp" && currentIndex > 0) {
 | 
				
			||||||
            const prevSibling = siblings[currentIndex - 1]
 | 
					            const prevSibling = siblings[currentIndex - 1]
 | 
				
			||||||
            const length = prevSibling.textContent.length
 | 
					            const index = Math.max(0, Math.min(prevSibling.textContent.length, this.insertIndex))
 | 
				
			||||||
            const index = length < this.insertIndex ? length : this.insertIndex
 | 
					 | 
				
			||||||
            this.setTarget(prevSibling, index)  // 光标在上一个兄弟元素的起始位置
 | 
					            this.setTarget(prevSibling, index)  // 光标在上一个兄弟元素的起始位置
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (key === "ArrowDown" && currentIndex >= 0 && currentIndex < siblings.length - 1) {
 | 
					        if (key === "ArrowDown" && currentIndex >= 0 && currentIndex < siblings.length - 1) {
 | 
				
			||||||
            const nextSibling = siblings[currentIndex + 1]
 | 
					            const nextSibling = siblings[currentIndex + 1]
 | 
				
			||||||
            const length = nextSibling.textContent.length
 | 
					            const index = Math.max(0, Math.min(nextSibling.textContent.length, this.insertIndex))
 | 
				
			||||||
            const index = length < this.insertIndex ? length : this.insertIndex
 | 
					 | 
				
			||||||
            this.setTarget(nextSibling, index)  // 光标在下一个兄弟元素的起始位置
 | 
					            this.setTarget(nextSibling, index)  // 光标在下一个兄弟元素的起始位置
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user