Fix Ctrl+V inserting v and add Delete key text editing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.22 R142";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R143";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ export function applyTextInput(
|
|||||||
newString = newString.slice(0, cursorPos - 1) + newString.slice(cursorPos);
|
newString = newString.slice(0, cursorPos - 1) + newString.slice(cursorPos);
|
||||||
newCursorPos = cursorPos - 1;
|
newCursorPos = cursorPos - 1;
|
||||||
}
|
}
|
||||||
|
} else if (lowerKey === 'delete') {
|
||||||
|
if (cursorPos < newString.length) {
|
||||||
|
newString = newString.slice(0, cursorPos) + newString.slice(cursorPos + 1);
|
||||||
|
}
|
||||||
} else if (lowerKey === 'home') {
|
} else if (lowerKey === 'home') {
|
||||||
newCursorPos = 0;
|
newCursorPos = 0;
|
||||||
} else if (lowerKey === 'end') {
|
} else if (lowerKey === 'end') {
|
||||||
@@ -92,6 +96,7 @@ export function mapTextInputKey(code: string, key: string): string {
|
|||||||
if (code === 'ArrowLeft') return 'arrowleft';
|
if (code === 'ArrowLeft') return 'arrowleft';
|
||||||
if (code === 'ArrowRight') return 'arrowright';
|
if (code === 'ArrowRight') return 'arrowright';
|
||||||
if (code === 'Backspace') return 'backspace';
|
if (code === 'Backspace') return 'backspace';
|
||||||
|
if (code === 'Delete') return 'delete';
|
||||||
if (code === 'Home') return 'home';
|
if (code === 'Home') return 'home';
|
||||||
if (code === 'End') return 'end';
|
if (code === 'End') return 'end';
|
||||||
return key;
|
return key;
|
||||||
@@ -182,3 +187,8 @@ export function describeBackspaceDeletedCharacter(text: string, cursorPos: numbe
|
|||||||
if (cursorPos <= 0 || cursorPos > text.length) return null;
|
if (cursorPos <= 0 || cursorPos > text.length) return null;
|
||||||
return describeCharacter(text[cursorPos - 1]);
|
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,
|
applyPastedText,
|
||||||
applyTextInput,
|
applyTextInput,
|
||||||
describeBackspaceDeletedCharacter,
|
describeBackspaceDeletedCharacter,
|
||||||
|
describeDeleteDeletedCharacter,
|
||||||
describeCursorCharacter,
|
describeCursorCharacter,
|
||||||
describeCursorWordOrCharacter,
|
describeCursorWordOrCharacter,
|
||||||
mapTextInputKey,
|
mapTextInputKey,
|
||||||
@@ -682,6 +683,10 @@ function applyTextInputEdit(code: string, key: string, maxLength: number, ctrlKe
|
|||||||
const spoken = describeBackspaceDeletedCharacter(beforeText, beforeCursor);
|
const spoken = describeBackspaceDeletedCharacter(beforeText, beforeCursor);
|
||||||
if (spoken) updateStatus(spoken);
|
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') {
|
if (code === 'ArrowLeft' || code === 'ArrowRight' || code === 'Home' || code === 'End') {
|
||||||
const spoken = describeCursorCharacter(state.nicknameInput, state.cursorPos);
|
const spoken = describeCursorCharacter(state.nicknameInput, state.cursorPos);
|
||||||
if (spoken) updateStatus(spoken);
|
if (spoken) updateStatus(spoken);
|
||||||
@@ -2377,6 +2382,9 @@ function setupInputHandlers(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.ctrlKey && isTextEditingMode(state.mode)) {
|
if (event.ctrlKey && isTextEditingMode(state.mode)) {
|
||||||
|
if (code === 'KeyV') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (code === 'KeyC') {
|
if (code === 'KeyC') {
|
||||||
const text = state.nicknameInput;
|
const text = state.nicknameInput;
|
||||||
internalClipboardText = text;
|
internalClipboardText = text;
|
||||||
|
|||||||
Reference in New Issue
Block a user