Add editor lang

This commit is contained in:
Виталий Лавшонок
2025-10-27 13:24:01 +03:00
parent 8fa48ef67e
commit 1690169d5a
6 changed files with 59 additions and 21 deletions

View File

@@ -0,0 +1,18 @@
import React from "react";
export const useClickOutside = (ref: React.RefObject<any>, onClickOutside: () => void) => {
React.useEffect(() => {
const handleClickOutside = (event: MouseEvent | TouchEvent) => {
if (ref.current && !ref.current.contains(event.target)) {
onClickOutside();
}
}
document.addEventListener("mousedown", handleClickOutside);
document.addEventListener("touchstart", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
document.removeEventListener("touchstart", handleClickOutside);
}
}, [ref, onClickOutside]);
}