| } | } | ||||
| const handleEditorChange = (editorState: EditorState) => { | const handleEditorChange = (editorState: EditorState) => { | ||||
| const text = editorState.read(() => $getRoot().getTextContent()) | |||||
| const text = editorState.read(() => { | |||||
| return $getRoot().getChildren().map(p => p.getTextContent()).join('\n') | |||||
| }) | |||||
| if (onChange) | if (onChange) | ||||
| onChange(text.replaceAll('\n\n', '\n')) | |||||
| onChange(text) | |||||
| } | } | ||||
| useEffect(() => { | useEffect(() => { |