mirror of https://github.com/jetkvm/kvm.git
Improve error handling and pre-loading
This commit is contained in:
parent
962a6f6dfc
commit
34f48f9bea
|
@ -33,6 +33,13 @@ export default function PasteModal() {
|
||||||
state => state.setKeyboardLayout,
|
state => state.setKeyboardLayout,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
send("getKeyboardLayout", {}, resp => {
|
||||||
|
if ("error" in resp) return;
|
||||||
|
setKeyboardLayout(resp.result as string);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const onCancelPasteMode = useCallback(() => {
|
const onCancelPasteMode = useCallback(() => {
|
||||||
setPasteMode(false);
|
setPasteMode(false);
|
||||||
setDisableVideoFocusTrap(false);
|
setDisableVideoFocusTrap(false);
|
||||||
|
@ -48,6 +55,9 @@ export default function PasteModal() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const char of text) {
|
for (const char of text) {
|
||||||
|
if (!keyboardLayout) continue;
|
||||||
|
if (!chars[keyboardLayout]) continue;
|
||||||
|
|
||||||
const { key, shift, altRight, space, capsLock, trema } = chars[keyboardLayout][char] ?? {};
|
const { key, shift, altRight, space, capsLock, trema } = chars[keyboardLayout][char] ?? {};
|
||||||
if (!key) continue;
|
if (!key) continue;
|
||||||
|
|
||||||
|
@ -97,11 +107,6 @@ export default function PasteModal() {
|
||||||
if (TextAreaRef.current) {
|
if (TextAreaRef.current) {
|
||||||
TextAreaRef.current.focus();
|
TextAreaRef.current.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
send("getKeyboardLayout", {}, resp => {
|
|
||||||
if ("error" in resp) return;
|
|
||||||
setKeyboardLayout(resp.result as string);
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue