退格键
This commit is contained in:
parent
5bb61de760
commit
b70a082307
@ -100,6 +100,14 @@ export class Cursor {
|
|||||||
this.insertIndex = Math.max(0, Math.min(this.targetNode.textContent.length, this.insertIndex + 1))
|
this.insertIndex = Math.max(0, Math.min(this.targetNode.textContent.length, this.insertIndex + 1))
|
||||||
return this.updatePosition(this.getBoundingClientRect())
|
return this.updatePosition(this.getBoundingClientRect())
|
||||||
}
|
}
|
||||||
|
if (key === "Backspace") {
|
||||||
|
const text = this.targetNode.textContent
|
||||||
|
const left = text.slice(0, Math.max(0, this.insertIndex - 1))
|
||||||
|
const right = text.slice(this.insertIndex)
|
||||||
|
this.targetNode.textContent = left + right
|
||||||
|
this.insertIndex = Math.max(0, this.insertIndex - 1)
|
||||||
|
return this.updatePosition(this.getBoundingClientRect())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user