0.1.0 • Published 2 years ago
react-braft-editor v0.1.0
安装
npm i --save react-braft-editor
使用
import MyBraftEditor from '@/components/BraftEditor';
import type { MyBraftEditorProps } from '@/components/BraftEditor';
import type { FormViewProps } from 'forms-pack';
import FormView from 'forms-pack';
const Page = () => {
/**
* 表单提交
* @param 提交的数据
* @description 处理数据注意接口约束
*/
const handleOk = useDebounceFn((data = {}) => {
const info: CurrentItem & Record<string, any> = data;
info.content = info?.content?.toHTML
? info?.content?.toHTML()
: info?.content;
onOk(info);
});
const myBraftEditorProps: MyBraftEditorProps = {
initialValues: currentItem?.content,
label: '政策内容',
name: 'content',
formItemLayout: {
required: true,
labelCol: { span: 6 },
wrapperCol: { span: 14 },
},
};
/** 表单配置 */
const formViewProps: FormViewProps = {
onCancel: modalProps?.onCancel,
type: 1,
list: [
{
otherView: <MyBraftEditor {...myBraftEditorProps} />,
},
],
};
return (
<Form form={form} onFinish={handleOk}>
<FormView {...formViewProps} />
</Form>
);
};
export default memo(Page);
0.1.0
2 years ago