Skip to content

Commit b7c4f9c

Browse files
committed
Fix backspacing
1 parent 460a61b commit b7c4f9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,7 @@ <h3>設定</h3>
21062106
}
21072107
} else if ((e.code == "Backspace" || e.key == "Backspace") && !e.isComposing) {
21082108
if (mode == EDITOR_MODES.MODERN) {
2109+
e.preventDefault();
21092110
if (selecting) {
21102111
deleteSelected();
21112112
draw();
@@ -2242,6 +2243,10 @@ <h3>設定</h3>
22422243
console.log(e.type, e);
22432244
//console.log(document.getElementById("cursor").children[1].selectionStart, document.getElementById("cursor").children[1].selectionEnd);
22442245
if (e.data == null || e.data == undefined) {
2246+
if (e.inputType == "deleteContentBackward") {
2247+
let ev = new KeyboardEvent("keydown", {key: "Backspace", isComposing: false});
2248+
e.target.dispatchEvent(ev);
2249+
}
22452250
return;
22462251
}
22472252
if (composing) {
@@ -2252,7 +2257,6 @@ <h3>設定</h3>
22522257
texts[cursor_pos[0]] = UTF8String.fromString(
22532258
texts[cursor_pos[0]].slice(0, cursor_pos[1]) + e.data + texts[cursor_pos[0]].slice(cursor_pos[1])
22542259
);
2255-
let word;
22562260
let wordStart, wordCursor, wordEnd;
22572261
wordStart = wordCursor = wordEnd = cursor_pos[1] + UTF8String.fromString(e.data).length;
22582262
while (wordStart > 0) {

0 commit comments

Comments
 (0)