Skip to content

Commit 5f9c5c4

Browse files
committed
make mobile work... maybe?
1 parent a795460 commit 5f9c5c4

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

src/components/IMEField.tsx

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ import {
2020
DropdownMenuTrigger,
2121
} from "./ui/DropdownMenu";
2222

23-
type JishoJapanese = { word?: string; reading: string };
24-
type JishoEntry = { japanese: JishoJapanese[] };
25-
type JishoResponse = { data: JishoEntry[] };
23+
type JishoJapanese = {
24+
word?: string;
25+
reading: string;
26+
};
27+
type JishoEntry = {
28+
japanese: JishoJapanese[];
29+
};
30+
type JishoResponse = {
31+
data: JishoEntry[];
32+
};
2633

2734
type LastConversion = {
2835
confirmed: string;
@@ -47,7 +54,9 @@ async function fetchKanjiFromJisho(reading: string): Promise<string[]> {
4754
const res = await fetch(proxyUrl);
4855

4956
if (!res.ok) {
50-
console.error(`Error fetching from CORS Anywhere proxy: ${res.status} ${res.statusText}`);
57+
console.error(
58+
`Error fetching from CORS Anywhere proxy: ${res.status} ` + `${res.statusText}`
59+
);
5160
try {
5261
const errorText = await res.text();
5362
console.error("Proxy error response:", errorText);
@@ -146,7 +155,11 @@ export function IMEField() {
146155
setTimeout(() => ta?.focus(), 0);
147156
}
148157

149-
function handleKeyDown(e: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {
158+
function handleKeyDown(
159+
e: KeyboardEvent & {
160+
currentTarget: HTMLTextAreaElement;
161+
}
162+
) {
150163
if (isMenuOpen()) {
151164
const len = suggestions().length;
152165
if (len > 0 && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
@@ -236,7 +249,11 @@ export function IMEField() {
236249
}
237250
}
238251

239-
function handleInput(e: InputEvent & { currentTarget: HTMLTextAreaElement }) {
252+
function handleInput(
253+
e: InputEvent & {
254+
currentTarget: HTMLTextAreaElement;
255+
}
256+
) {
240257
const val = e.currentTarget.value;
241258
setInput(val);
242259
setIsComposing(val.length > confirmedIndex());
@@ -255,12 +272,20 @@ export function IMEField() {
255272
}
256273
}
257274

258-
function handleCompositionStart(e: CompositionEvent & { currentTarget: HTMLTextAreaElement }) {
275+
function handleCompositionStart(
276+
e: CompositionEvent & {
277+
currentTarget: HTMLTextAreaElement;
278+
}
279+
) {
259280
setIsComposing(true);
260281
setCompositionStart(e.currentTarget.selectionStart);
261282
}
262283

263-
function handleCompositionEnd(e: CompositionEvent & { currentTarget: HTMLTextAreaElement }) {
284+
function handleCompositionEnd(
285+
e: CompositionEvent & {
286+
currentTarget: HTMLTextAreaElement;
287+
}
288+
) {
264289
setIsComposing(false);
265290
const start = compositionStart();
266291
const pos = e.currentTarget.selectionStart;

0 commit comments

Comments
 (0)