Skip to content

Commit 878064e

Browse files
authored
Add files via upload
1 parent b551e8e commit 878064e

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

test.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ <h2>輸入法模式:</h2>
717717

718718
function handleChineseInput(code) {
719719
if (code.match(/^[1-90]$/)) {
720-
if (currentCandidates.length > 0) {
720+
if (currentCandidates.length > 1) { // 數字選字要確保有重碼字
721721
const num = code === '0' ? 10 : parseInt(code, 10);
722722
selectCandidate(num - 1);
723723
} else {
@@ -760,7 +760,7 @@ <h2>輸入法模式:</h2>
760760

761761
const inputChar = code.toLowerCase();
762762
if (inputChar.match(/^[a-z;'./,]$/)) {
763-
if (currentCode.length === MAX_CODE_LENGTH && currentCandidates.length > 0) {
763+
if (currentCode.length >= MAX_CODE_LENGTH && currentCandidates.length > 0) {
764764
selectCandidate(0);
765765
currentCode = inputChar;
766766
} else {
@@ -1020,14 +1020,14 @@ <h2>輸入法模式:</h2>
10201020
const textToCompare = textOutput.value;
10211021

10221022
let lookupStartIndex = 0;
1023-
let highlightIndex = -1; // 使用 -1 表示不需高亮
1024-
1023+
let highlightIndex = -1;
1024+
10251025
if (phraseInput === document.activeElement) {
1026-
lookupStartIndex = 0; // 當游標在查碼區時,固定從索引 0 開始
1026+
lookupStartIndex = 0;
10271027
} else if (textOutput === document.activeElement) {
10281028
const cursorPosition = textOutput.selectionStart;
10291029
lookupStartIndex = Math.floor(cursorPosition / 10) * 10;
1030-
highlightIndex = cursorPosition; // 當游標在練打區時,高亮游標所在的字
1030+
highlightIndex = cursorPosition;
10311031
}
10321032

10331033
encodingResults.innerHTML = '';
@@ -1081,10 +1081,11 @@ <h2>輸入法模式:</h2>
10811081
const candidatesForCode = currentCodemap[code];
10821082

10831083
let suffix = '';
1084-
if (candidatesForCode && candidatesForCode.length > 1) {
1085-
if (result.index === 0) {
1086-
suffix = '';
1087-
} else if (result.index < 9) {
1084+
// 檢查是否為第一候選字且編碼長度小於3
1085+
if (result.index === 0 && code.length < 3) {
1086+
suffix = '空';
1087+
} else if (candidatesForCode && candidatesForCode.length > 1) {
1088+
if (result.index < 9) {
10881089
const digit = (result.index + 1).toString();
10891090
suffix = fullWidthDigits[digit];
10901091
} else if (result.index === 9) {

0 commit comments

Comments
 (0)