Fix Ctrl+V inserting v and add Delete key text editing
This commit is contained in:
@@ -17,6 +17,10 @@ export function applyTextInput(
|
||||
newString = newString.slice(0, cursorPos - 1) + newString.slice(cursorPos);
|
||||
newCursorPos = cursorPos - 1;
|
||||
}
|
||||
} else if (lowerKey === 'delete') {
|
||||
if (cursorPos < newString.length) {
|
||||
newString = newString.slice(0, cursorPos) + newString.slice(cursorPos + 1);
|
||||
}
|
||||
} else if (lowerKey === 'home') {
|
||||
newCursorPos = 0;
|
||||
} else if (lowerKey === 'end') {
|
||||
@@ -92,6 +96,7 @@ export function mapTextInputKey(code: string, key: string): string {
|
||||
if (code === 'ArrowLeft') return 'arrowleft';
|
||||
if (code === 'ArrowRight') return 'arrowright';
|
||||
if (code === 'Backspace') return 'backspace';
|
||||
if (code === 'Delete') return 'delete';
|
||||
if (code === 'Home') return 'home';
|
||||
if (code === 'End') return 'end';
|
||||
return key;
|
||||
@@ -182,3 +187,8 @@ export function describeBackspaceDeletedCharacter(text: string, cursorPos: numbe
|
||||
if (cursorPos <= 0 || cursorPos > text.length) return null;
|
||||
return describeCharacter(text[cursorPos - 1]);
|
||||
}
|
||||
|
||||
export function describeDeleteDeletedCharacter(text: string, cursorPos: number): string | null {
|
||||
if (cursorPos < 0 || cursorPos >= text.length) return null;
|
||||
return describeCharacter(text[cursorPos]);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
applyPastedText,
|
||||
applyTextInput,
|
||||
describeBackspaceDeletedCharacter,
|
||||
describeDeleteDeletedCharacter,
|
||||
describeCursorCharacter,
|
||||
describeCursorWordOrCharacter,
|
||||
mapTextInputKey,
|
||||
@@ -682,6 +683,10 @@ function applyTextInputEdit(code: string, key: string, maxLength: number, ctrlKe
|
||||
const spoken = describeBackspaceDeletedCharacter(beforeText, beforeCursor);
|
||||
if (spoken) updateStatus(spoken);
|
||||
}
|
||||
if (code === 'Delete') {
|
||||
const spoken = describeDeleteDeletedCharacter(beforeText, beforeCursor);
|
||||
if (spoken) updateStatus(spoken);
|
||||
}
|
||||
if (code === 'ArrowLeft' || code === 'ArrowRight' || code === 'Home' || code === 'End') {
|
||||
const spoken = describeCursorCharacter(state.nicknameInput, state.cursorPos);
|
||||
if (spoken) updateStatus(spoken);
|
||||
@@ -2377,6 +2382,9 @@ function setupInputHandlers(): void {
|
||||
}
|
||||
|
||||
if (event.ctrlKey && isTextEditingMode(state.mode)) {
|
||||
if (code === 'KeyV') {
|
||||
return;
|
||||
}
|
||||
if (code === 'KeyC') {
|
||||
const text = state.nicknameInput;
|
||||
internalClipboardText = text;
|
||||
|
||||
Reference in New Issue
Block a user