añadido import
This commit is contained in:
@@ -44,6 +44,40 @@ export default function Keeper({ tipo }) {
|
|||||||
}
|
}
|
||||||
}, [tipo]);
|
}, [tipo]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handlePaste = async (e) => {
|
||||||
|
const text = await navigator.clipboard.readText();
|
||||||
|
const regex = /- (.*), X: (-?\d+)(?:\s*Y:\s*(-?\d+))?\s*Z:\s*(-?\d+)/;
|
||||||
|
const match = text.match(regex);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const [_, descripcion, x, y, z] = match;
|
||||||
|
const newCoord = {
|
||||||
|
descripcion,
|
||||||
|
x: parseInt(x),
|
||||||
|
y: y ? parseInt(y) : null,
|
||||||
|
z: parseInt(z),
|
||||||
|
num: coords.length + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const newCoords = [...coords, newCoord];
|
||||||
|
setCoords(newCoords);
|
||||||
|
localStorage.setItem(tipo, JSON.stringify(newCoords));
|
||||||
|
setShowToast(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("keydown", (e) => {
|
||||||
|
if (e.ctrlKey && e.key === "v") {
|
||||||
|
handlePaste(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*return () => {
|
||||||
|
document.removeEventListener("keydown", handlePaste);
|
||||||
|
};*/
|
||||||
|
}, [coords, tipo]);
|
||||||
|
|
||||||
const Editar = (coord) => {
|
const Editar = (coord) => {
|
||||||
setCoord(coord);
|
setCoord(coord);
|
||||||
setEditar(true);
|
setEditar(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user