问题,我正在创建这个组件,它将从我的后端查看数据并允许用户修改数据。来自后端的数据将被传递到使用 react-draft-wysiwyg 和 draft.js 的输入字段
查看评论组件
import {
convertToRaw
ContentState,
} from 'draft-js';
import { Editor } from 'react-draft-wysiwyg';
import draftToHtml from 'draftjs-to-html';
import htmlToDraft from 'html-to-draftjs';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
const ViewTaskComment = ({ content }) => {
const contentBlocks = htmlToDraft(content);
const contentState = ContentState.createFromBlockArray(contentBlocks);
const rawHtml = convertToRaw(contentState);
return (
<div className='comment-container p-2 border rounded-md'>
<Editor
contentState={rawHtml}
wrapperClassName='wrapper-class'
editorClassName='editor-class'
toolbarClassName='toolbar-class'
/>
</div>
);
};