9.1 에디터(Tiptap/Quill 중 택1) 통합 o

This commit is contained in:
koreacomp5
2025-10-09 17:49:39 +09:00
parent 8f4446a87a
commit 0c66bf6fa7
4 changed files with 38 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
"use client";
import { useEffect, useRef } from "react";
export function Editor({ value, onChange, placeholder }: { value: string; onChange: (v: string) => void; placeholder?: string }) {
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
if (el.innerHTML !== value) el.innerHTML = value || "";
}, [value]);
return (
<div
ref={ref}
contentEditable
onInput={(e) => onChange((e.target as HTMLDivElement).innerHTML)}
data-placeholder={placeholder}
style={{
minHeight: 160,
border: "1px solid #ddd",
borderRadius: 6,
padding: 12,
}}
suppressContentEditableWarning
/>
);
}