mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-21 03:10:50 +00:00
fix: simple prompt editor list render (#5717)
This commit is contained in:
@@ -132,7 +132,7 @@ export default function Editor({
|
||||
CodeNode,
|
||||
CodeHighlightNode
|
||||
],
|
||||
editorState: textToEditorState(value),
|
||||
editorState: textToEditorState(value, isRichText),
|
||||
onError: (error: Error) => {
|
||||
throw error;
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ const PromptEditor = ({
|
||||
minH={400}
|
||||
maxH={400}
|
||||
showOpenModal={false}
|
||||
value={value}
|
||||
value={formattedValue}
|
||||
onChange={onChangeInput}
|
||||
onChangeText={onChange}
|
||||
onBlur={onBlurInput}
|
||||
|
@@ -270,10 +270,42 @@ const buildListStructure = (items: ListItemInfo[]) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
export const textToEditorState = (text = '') => {
|
||||
export const textToEditorState = (text = '', isRichText = false) => {
|
||||
const lines = text.split('\n');
|
||||
const children: Array<ParagraphEditorNode | ListEditorNode> = [];
|
||||
|
||||
if (!isRichText) {
|
||||
return JSON.stringify({
|
||||
root: {
|
||||
children: lines.map((p) => {
|
||||
return {
|
||||
children: [
|
||||
{
|
||||
detail: 0,
|
||||
format: 0,
|
||||
mode: 'normal',
|
||||
style: '',
|
||||
text: p,
|
||||
type: 'text',
|
||||
version: 1
|
||||
}
|
||||
],
|
||||
direction: 'ltr',
|
||||
format: '',
|
||||
indent: 0,
|
||||
type: 'paragraph',
|
||||
version: 1
|
||||
};
|
||||
}),
|
||||
direction: 'ltr',
|
||||
format: '',
|
||||
indent: 0,
|
||||
type: 'root',
|
||||
version: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
while (i < lines.length) {
|
||||
const parsed = parseTextLine(lines[i]);
|
||||
|
Reference in New Issue
Block a user