https://velog.io/@bepyan/series/DND-%EB%BD%80%EA%B0%9C%EA%B8%B0
위 게시물을 참조했습니다.
마우스 드래그 이벤트 함수인 registDragEvent.ts와 바운더리 범위를 계산해주는 inRange함수는 그대로 사용했습니다.
1-1. Konva 라이브러리의 내부 코드 구조 이해가 어려워 화면 추가 기능(스크린샷) 이어지는데 어려움
1-2. Konva가 Next.js에 최적화 안됨
2. 기업홍보 사이트인데 SEO가 안되는 것은 매우 큰 약점
const OptionBody: React.FC<OptionBodyProps> = ({ styleMode, setPointLogo, setConfig, boundaryRef }) => {
function handleChange(e: any) {
setPointLogo(URL.createObjectURL(e.target.files[0]));
const boundary = boundaryRef.current?.getBoundingClientRect();
//❗️❗️❗️
if (boundary) {
const DEFAULT_W = 80;
const DEFAULT_H = 80;
setConfig({
x: Math.floor(boundary.width / 2 - DEFAULT_W / 2),
y: Math.floor(boundary.height / 2 - DEFAULT_H / 2),
w: DEFAULT_W,
h: DEFAULT_H,
});
}
}
const inputRef = useRef<HTMLInputElement | null>(null);
const resetFileInput = () => {
if (inputRef.current) {
inputRef.current.value = "";
}
};
switch (styleMode) {
case "pointLogo":
return (
<div className="relative">
<input
type="file"
ref={inputRef}
className="w-full p-4 bg-white border-2 rounded-md outline-none border-neutral-300 focus:border-black"
onChange={handleChange}
/>
<div
onClick={() => {
setPointLogo("");
resetFileInput();
}}
>
<IoMdClose size={24} className="absolute top-4 right-4 z-10 cursor-pointer" />
</div>
</div>
);
case "textLogo":
return <div></div>;
default:
return <div></div>;
}
};
export default OptionBody;