[Question]右边预览滚动时左边编辑器会跟着滚动,但是demo里不会
Closed this issue · 0 comments
isVicky722 commented
放重要的代码
import MdEditor from 'react-markdown-editor-lite';
import MarkdownIt from 'markdown-it';
import 'react-markdown-editor-lite/lib/index.css';
const mdParser = new MarkdownIt({
html: true,
linkify: false,
typographer: false,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
}
return ''; // use external default escaping
},
});
function handleEditorChange({ html, text }) {
setContentHtml(html);
setContentMd(text);
}
<MdEditor
value={contentMd}
style={{ height: '500px', margin: '20px 0', whiteSpace: 'normal' }}
renderHTML={(text) => mdParser.render(text)}
onChange={handleEditorChange}
/>