fix(B07-CAD): 한글 IME 조합 입력 — 문자 단계 숨은 받개 · 조합 중 단축키 건너뜀
- 문자를 기다리는 단계(TEXT · MTEXT · 표 칸 · 지시선)에서 숨은 input 에 초점 · compositionupdate/end 로 글자 받음 - 조합 중 키(isComposing · 229 · Process)는 단축키 처리에서 건너뜀 · 명령줄도 같음 - 명령 단계는 초점을 풀어 한글 자판이어도 영문 명령 그대로 - 입력 해석 패턴을 input-patterns.ts 로 나눔(700줄 상한) - 검증 창구 entities 에 label · 시나리오 ui_checks/44-8_CAD_한글입력.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UoSr2sqvYtBf1dtQdus88s
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { ImeSink, isImeKey } from './ime-sink.ts';
|
||||
import { InputController } from './input-controller.ts';
|
||||
|
||||
describe('한글 IME 입력', () => {
|
||||
it('조합 사건으로 「가나다」 가 들어간다', () => {
|
||||
let text = '';
|
||||
const sink = new ImeSink((data) => {
|
||||
text += data;
|
||||
});
|
||||
for (const [steps, done] of [
|
||||
[['ㄱ', '가'], '가'],
|
||||
[['ㄴ', '나'], '나'],
|
||||
[['ㄷ', '다'], '다'],
|
||||
] as const) {
|
||||
for (const step of steps) sink.handleCompositionUpdate(step);
|
||||
expect(sink.composing).toBe(steps[steps.length - 1]);
|
||||
sink.handleCompositionEnd(done);
|
||||
}
|
||||
expect(text).toBe('가나다');
|
||||
expect(sink.composing).toBe('');
|
||||
// 조합 중 input 은 compositionend 몫 — 겹쳐 넣지 않음 · 조합 뒤 띄어쓰기는 받음
|
||||
sink.handleInput({ isComposing: true, data: '다' });
|
||||
sink.handleInput({ isComposing: false, data: ' ' });
|
||||
expect(text).toBe('가나다 ');
|
||||
});
|
||||
|
||||
it('조합 중 키는 단축키로 먹지 않는다', () => {
|
||||
expect(isImeKey({ isComposing: true, keyCode: 0, key: 'r' } as KeyboardEvent)).toBe(true);
|
||||
expect(isImeKey({ isComposing: false, keyCode: 229, key: 'r' } as KeyboardEvent)).toBe(true);
|
||||
expect(isImeKey({ isComposing: false, keyCode: 0, key: 'Process' } as KeyboardEvent)).toBe(
|
||||
true
|
||||
);
|
||||
expect(isImeKey({ isComposing: false, keyCode: 76, key: 'l' } as KeyboardEvent)).toBe(false);
|
||||
|
||||
const controller = new InputController();
|
||||
const preventDefault = vi.fn();
|
||||
controller.handleKeyStroke({
|
||||
key: 'Process',
|
||||
keyCode: 229,
|
||||
isComposing: true,
|
||||
target: null,
|
||||
preventDefault,
|
||||
stopPropagation: vi.fn(),
|
||||
} as unknown as KeyboardEvent);
|
||||
expect(preventDefault).not.toHaveBeenCalled();
|
||||
controller.ime.handleCompositionEnd('가나다');
|
||||
expect((controller as unknown as { text: string }).text).toBe('가나다');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user