Skip to content

Commit 28277a0

Browse files
committed
Support multi-char deletion
1 parent eeb4151 commit 28277a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,8 +2254,17 @@ <h3>設定</h3>
22542254
//console.log(document.getElementById("cursor").children[1].selectionStart, document.getElementById("cursor").children[1].selectionEnd);
22552255
if (e.data == null || e.data == undefined) {
22562256
if (e.inputType == "deleteContentBackward") {
2257+
let i = 0;
2258+
let count = ((range)=>range.endOffset-range.startOffset)(e.getTargetRanges()[0]);
2259+
while (count > 0) {
2260+
count -= texts[cursor_pos[0]][cursor_pos[1] - i].length;
2261+
i++;
2262+
}
22572263
let ev = new KeyboardEvent("keydown", {key: "Backspace", isComposing: false});
2258-
e.target.dispatchEvent(ev);
2264+
while (i > 0) {
2265+
e.target.dispatchEvent(ev);
2266+
i--;
2267+
}
22592268
}
22602269
return;
22612270
}

0 commit comments

Comments
 (0)