Commit b99b0aa3 authored by 满振华's avatar 满振华

修改子空间

parent 8651474a
...@@ -33,7 +33,7 @@ interface IProps { ...@@ -33,7 +33,7 @@ interface IProps {
onChange?: Function onChange?: Function
} }
const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef, excludeControls = excludeControlsDefault }) => { const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef, excludeControls = excludeControlsDefault, ...others }) => {
// 创建一个空的editorState作为初始值 // 创建一个空的editorState作为初始值
const [editorState, setEditorState] = useState(BraftEditor.createEditorState(null)); const [editorState, setEditorState] = useState(BraftEditor.createEditorState(null));
const [percent, setPercent] = useState(0); // 进度条 const [percent, setPercent] = useState(0); // 进度条
...@@ -102,17 +102,23 @@ const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef, ...@@ -102,17 +102,23 @@ const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef,
), ),
}, },
]; ];
const insertText = (text: string) => {
setEditorState(ContentUtils.insertText(editorState, text))
}
// 向外抛出数据 // 向外抛出数据
useImperativeHandle(cRef, () => { useImperativeHandle(cRef, () => {
return { return {
getHtml, getHtml,
previewMth, previewMth,
insertText,
}; };
}); });
return ( return (
<div className={styles.box}> <div className={styles.box}>
<BraftEditor <BraftEditor
{...others}
id="editor-with-color-picker" id="editor-with-color-picker"
value={editorState} value={editorState}
excludeControls={excludeControls} excludeControls={excludeControls}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment