App.jsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import React, { useState, useRef, useMemo } from 'react'; import JoditEditor from 'jodit-react'; const App = ({ placeholder }) => { const editor = useRef(null); const [content, setContent] = useState(''); const config = useMemo(() => ({ readonly: false, // all options from https://xdsoft.net/jodit/docs/, placeholder: placeholder || 'Start typing...', }), [placeholder]); return ( <JoditEditor ref={editor} value={content} config={config} tabIndex={1} // tabIndex of the editor onBlur={newContent => setContent(newContent)} // Update content on blur for performance reasons onChange={newContent => setContent(newContent)} // Optional: handle changes in real-time /> ); }; export default App; |