fix: prompt editor new line (#6310)

This commit is contained in:
zxhlyh 2024-07-16 11:23:26 +08:00 committed by GitHub
parent d66d7146a3
commit 23e8043160
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,9 +122,11 @@ const PromptEditor: FC<PromptEditorProps> = ({
}
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)
onChange(text.replaceAll('\n\n', '\n'))
onChange(text)
}
useEffect(() => {