Skip to content

Commit a4f9228

Browse files
authored
Add files via upload
1 parent 7311c5d commit a4f9228

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

index.html

Lines changed: 12 additions & 11 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 = '';
@@ -1078,13 +1078,14 @@ <h2>輸入法模式:</h2>
10781078
if (j < codesToDisplay.length) {
10791079
const result = codesToDisplay[j];
10801080
const code = result.code;
1081-
const candidatesForCode = currentCodemap[code];
10821081

10831082
let suffix = '';
1084-
if (candidatesForCode && candidatesForCode.length > 1) {
1085-
if (result.index === 0) {
1086-
suffix = '';
1087-
} else if (result.index < 9) {
1083+
if (result.index === 0) {
1084+
if (code.length < 3) {
1085+
suffix = '空';
1086+
}
1087+
} else {
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)