claude-opencode-viewer 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.html +33 -1
- package/package.json +1 -1
package/index.html
CHANGED
|
@@ -500,7 +500,39 @@
|
|
|
500
500
|
'tab': '\t'
|
|
501
501
|
};
|
|
502
502
|
|
|
503
|
+
// 方向键列表
|
|
504
|
+
var ARROW_KEYS = ['up', 'down', 'left', 'right'];
|
|
505
|
+
|
|
503
506
|
function sendKey(keyName) {
|
|
507
|
+
var isArrowKey = ARROW_KEYS.indexOf(keyName) !== -1;
|
|
508
|
+
|
|
509
|
+
// 方向键特殊处理:根据焦点位置决定行为
|
|
510
|
+
if (isArrowKey) {
|
|
511
|
+
if (inputFocused && inputField) {
|
|
512
|
+
// 焦点在输入框:模拟方向键操作输入框光标
|
|
513
|
+
var cursorPos = inputField.selectionStart;
|
|
514
|
+
var textLen = inputField.value.length;
|
|
515
|
+
|
|
516
|
+
if (keyName === 'left' && cursorPos > 0) {
|
|
517
|
+
inputField.setSelectionRange(cursorPos - 1, cursorPos - 1);
|
|
518
|
+
} else if (keyName === 'right' && cursorPos < textLen) {
|
|
519
|
+
inputField.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
|
520
|
+
}
|
|
521
|
+
// 上下方向键在单行输入框中无操作
|
|
522
|
+
return;
|
|
523
|
+
} else {
|
|
524
|
+
// 焦点在终端:发送方向键到终端,并收起键盘
|
|
525
|
+
if (inputField && isMobile) {
|
|
526
|
+
inputField.blur();
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
// 非方向键:点击时收起键盘
|
|
531
|
+
if (inputField && isMobile) {
|
|
532
|
+
inputField.blur();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
504
536
|
// Enter 键特殊处理:根据焦点位置决定行为
|
|
505
537
|
if (keyName === 'enter') {
|
|
506
538
|
if (inputFocused && inputField && inputField.value) {
|
|
@@ -522,7 +554,7 @@
|
|
|
522
554
|
return;
|
|
523
555
|
}
|
|
524
556
|
|
|
525
|
-
//
|
|
557
|
+
// 其他按键直接发送到终端
|
|
526
558
|
var key = KEY_MAP[keyName];
|
|
527
559
|
if (key && ws && ws.readyState === 1 && !isTransitioning) {
|
|
528
560
|
console.log('[sendKey] sending:', keyName, '->', key);
|