import React, { useEffect, useRef } from "react"; function Editor({ onChange, editorLoaded, name, value }) { const editorRef = useRef(); const { CKEditor, ClassicEditor } = editorRef.current || {}; useEffect(() => { editorRef.current = { CKEditor: require("@ckeditor/ckeditor5-react").CKEditor, // v3+ ClassicEditor: require("@ckeditor/ckeditor5-build-classic") }; }, []); return (
{editorLoaded ? ( { const data = editor.getData(); // console.log({ event, editor, data }) onChange(data); }} /> ) : (
Editor loading
)}
); } export default Editor;