'use client'; /** * @author: Kim Jino * @since: 2025.03.31 * @description: CKEditor component for Next.js using Script component for loading CKEditor script */ // @/app/component/editor.tsx import '@/styles/editor.scss'; import Script from 'next/script'; import React, { useRef, useState, useEffect } from 'react'; import { CKEditor } from '@ckeditor/ckeditor5-react'; import Loading from '@/app/component/Loading'; interface EditorProps { data?: string; onChange?: (data: string) => void; } export default function Editor({ data = '', onChange }: EditorProps) { const editorRef = useRef(null); const [ready, setReady] = useState(false); useEffect(() => { if (typeof window !== 'undefined' && window.Editor) { editorRef.current = window.Editor; setReady(true); } }, []); const handleScriptLoad = () => { if (typeof window !== 'undefined' && window.Editor) { editorRef.current = window.Editor; setReady(true); } else { console.error('CKEditor script not loaded properly.'); } }; return ( <>