margox / braft-editor

美观易用的React富文本编辑器,基于draft-js开发
MIT License
4.61k stars 593 forks source link

编辑器输入时焦点自动跳到头部,如输入1234,得到4321 #926

Open alittlegit opened 3 years ago

alittlegit commented 3 years ago

import React, { useState } from 'react'; import ReactDOM from 'react-dom'; import BraftEditor from 'braft-editor'; import 'braft-editor/dist/index.css';

const RichText = () => { const [data, setData] = useState(); const handleEditorChange = (value) => { setData(value.toHTML()); };

return (

); };

export default RichText;

ReactDOM.render( , document.getElementById('container'), );

alittlegit commented 3 years ago

return的内容:

alittlegit commented 3 years ago
  BraftEditor
    value={BraftEditor.createEditorState(data)}
    onChange={handleEditorChange}
nmsn commented 3 years ago

同样的问题,想要封装在自定义组件中,对外只暴露 html 的字符串,就出现这种情况了