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