perf: editor input 属性类型

2.0/email-builder
Lei OT 11 months ago
parent 118acc6671
commit caf6efcbf8

@ -1,5 +1,6 @@
import { useState, useEffect } from 'react'
import LexicalEditor from '@/components/LexicalEditor'
import { isEmpty } from '@/utils/commons';
const LexicalEditorInput = (props) => {
const { id, value = {}, onChange } = props
@ -7,8 +8,8 @@ const LexicalEditorInput = (props) => {
const [defaultHtml, setDefaultHtml] = useState('');
useEffect(() => {
if (value.html) {
setDefaultHtml(value.html)
if (typeof value === 'string' && !isEmpty(value)) {
setDefaultHtml(value)
}
return () => {}

@ -16,7 +16,7 @@ const useSnippetStore = create(devtools((set, get) => ({
title: '',
owner: '',
category: '',
content: {html: ''}
content: '',
},
openDrawer: () => {
@ -86,7 +86,7 @@ const useSnippetStore = create(devtools((set, get) => ({
title: snippet.adi_title,
owner: snippet.adi_owner,
category: snippet.adi_type,
content: { html: detail.adi_content}
content: detail.adi_content,
}
}))
return content
@ -115,7 +115,7 @@ const useSnippetStore = create(devtools((set, get) => ({
title: formValues.title,
owner: formValues.owner,
category: formValues.category,
content: { html: formValues.content.htmlContent }
content: formValues.content.htmlContent,
}
}))
} else {

@ -188,7 +188,7 @@ function SnippetList() {
</Col>
<Col span={16}>
<HtmlPreview
value={currentSnippet.content.html}
value={currentSnippet.content}
loading={isHtmlLoading}
onEdit={() => handelSnippetEdit()}
onCopied={() => messageApi.success('已复制')}

Loading…
Cancel
Save