Dev 0.2.1 #30

Merged
LukeGus merged 47 commits from dev-0.2.1 into main 2025-03-24 03:17:56 +00:00
Showing only changes of commit 652b8d2da2 - Show all commits
+13 -28
View File
@@ -115,8 +115,6 @@ export const NewTerminal = forwardRef(({ hostConfig, isVisible, setIsNoAuthHidde
terminalInstance.current.write(decoder.decode(new Uint8Array(data))); terminalInstance.current.write(decoder.decode(new Uint8Array(data)));
}); });
let isPasting = false;
let buffer = ""; let buffer = "";
let bufferTimeout = null; let bufferTimeout = null;
@@ -131,38 +129,25 @@ export const NewTerminal = forwardRef(({ hostConfig, isVisible, setIsNoAuthHidde
} }
}); });
terminalInstance.current.attachCustomKeyEventHandler((event) => { terminalInstance.current.attachCustomKeyEventHandler(async (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === "v") { if ((event.ctrlKey || event.metaKey) && event.key === "v") {
if (isPasting) return false;
isPasting = true;
event.preventDefault(); event.preventDefault();
navigator.clipboard.readText().then((text) => { if (!socketRef.current) return false;
text = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
const lines = text.split("\n");
if (socketRef.current) { try {
let index = 0; const text = await navigator.clipboard.readText();
const lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
const sendLine = () => { await Promise.all(lines.map(line => {
if (index < lines.length) { return new Promise(resolve => {
socketRef.current.emit("data", lines[index] + "\r"); socketRef.current.emit("data", line + "\r");
index++; resolve();
setTimeout(sendLine, 10); });
} else { }));
isPasting = false; } catch (err) {
}
};
sendLine();
} else {
isPasting = false;
}
}).catch((err) => {
console.error("Failed to read clipboard contents:", err); console.error("Failed to read clipboard contents:", err);
isPasting = false; }
});
return false; return false;
} }