From b70a08230753853306efc77978904dc914794922 Mon Sep 17 00:00:00 2001 From: satori Date: Thu, 16 Jan 2025 06:21:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=A0=BC=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cursor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cursor.js b/cursor.js index f6afd9f..91e29b4 100644 --- a/cursor.js +++ b/cursor.js @@ -100,6 +100,14 @@ export class Cursor { this.insertIndex = Math.max(0, Math.min(this.targetNode.textContent.length, this.insertIndex + 1)) 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()) + } } }