Browse Source

fix: prompt editor new line (#6310)

zxhlyh 8 months ago
parent
commit
23e8043160
1 changed files with 4 additions and 2 deletions
  1. 4 2
      web/app/components/base/prompt-editor/index.tsx

+ 4 - 2
web/app/components/base/prompt-editor/index.tsx

@@ -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(() => {