From 23e8043160d6224d9d140151a76b68e144199387 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Tue, 16 Jul 2024 11:23:26 +0800 Subject: [PATCH] fix: prompt editor new line (#6310) --- web/app/components/base/prompt-editor/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 16057ea7d1e2c..da70d04ac1b10 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -122,9 +122,11 @@ const PromptEditor: FC = ({ } 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(() => {