7.15 富文本修改
This commit is contained in:
@ -3,7 +3,7 @@ import AlertMenu from './fullScreen'
|
||||
import E from 'wangeditor';
|
||||
import { Button, message, Spin } from 'antd';
|
||||
import { pictureDisplayPath, uploadAttachmentPath } from '@/utils/DownloadUtils';
|
||||
import { isEmpty } from '@/utils/CommonUtils';
|
||||
import { isEmpty, isNotEmpty } from '@/utils/CommonUtils';
|
||||
import { createNewFileBid } from '@/services/download_';
|
||||
|
||||
interface WangType {
|
||||
@ -194,21 +194,18 @@ const BraftText: React.FC<WangType> = (props) => {
|
||||
willCreate = false;
|
||||
}
|
||||
|
||||
// 重新设置编辑器内容
|
||||
echo && editor.txt.html(echo);
|
||||
|
||||
return () => {
|
||||
// 组件销毁时销毁编辑器 注:class写法需要在componentWillUnmount中调用
|
||||
editor.destroy()
|
||||
setLoading(false);
|
||||
setContent('');
|
||||
}
|
||||
}, [echo]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// 重新设置编辑器内容
|
||||
value && editor.txt.html(value);
|
||||
}, [value])
|
||||
echo && editor.txt.html(echo);
|
||||
}, [echo])
|
||||
/**
|
||||
*提供给父级的内容
|
||||
**/
|
||||
|
@ -38,6 +38,8 @@ const EventMaintenanceModal: React.FC<EventMaintenanceModalProps> = (props) => {
|
||||
const [imageId, setImageId] = useState<string>('');
|
||||
//富文本正文图片objectId
|
||||
const [contentImageId, setContentImageId] = useState<string>('');
|
||||
//富文本正文
|
||||
const [content, setContent] = useState<string>('');
|
||||
//活动类型选择
|
||||
const [typeSelect, setTypeSelect] = useState<string>('');
|
||||
//loading
|
||||
@ -49,6 +51,10 @@ const EventMaintenanceModal: React.FC<EventMaintenanceModalProps> = (props) => {
|
||||
message.error("请上传主图");
|
||||
return;
|
||||
}
|
||||
if (isEmpty(braftRef.current.getHtml())) {
|
||||
message.error("请编辑正文内容");
|
||||
return;
|
||||
}
|
||||
form.validateFields().then(values => {
|
||||
const data = {
|
||||
banner: null,
|
||||
@ -92,12 +98,14 @@ const EventMaintenanceModal: React.FC<EventMaintenanceModalProps> = (props) => {
|
||||
form.setFieldsValue(record);
|
||||
setImageId(record?.image);
|
||||
setContentImageId(record?.contentImageId);
|
||||
setContent(record?.content);
|
||||
onTypeChage(record?.type);
|
||||
}
|
||||
return () => {
|
||||
setImageId('');
|
||||
setContentImageId('');
|
||||
setTypeSelect('');
|
||||
setContent('');
|
||||
setLoading(false);
|
||||
};
|
||||
}, [record?.id])
|
||||
@ -174,13 +182,13 @@ const EventMaintenanceModal: React.FC<EventMaintenanceModalProps> = (props) => {
|
||||
</Col>
|
||||
</Row>
|
||||
</Form.Item>
|
||||
<Form.Item name="content" label="正文内容" rules={[{ required: !readOnly }]}>
|
||||
<Form.Item name="content" label="正文内容">
|
||||
{readOnly ? (
|
||||
<div style={{ border: '1px solid #c9d8db', padding: '16px', overflowX: 'auto' }}>
|
||||
<div dangerouslySetInnerHTML={{ __html: record?.content }}></div>
|
||||
</div>
|
||||
) : (
|
||||
<BraftText braftRef={braftRef} disabled={false} useImage imageId={contentImageId} />
|
||||
<BraftText braftRef={braftRef} echo={content} disabled={false} useImage imageId={contentImageId} />
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
Reference in New Issue
Block a user