From b99b0aa3958d72a5c1925ac9ced11fadf729b8c5 Mon Sep 17 00:00:00 2001 From: manzhenhua Date: Thu, 14 May 2020 17:06:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=90=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/braftEditor/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/braftEditor/index.tsx b/components/braftEditor/index.tsx index 9fe8aea..ed577fa 100644 --- a/components/braftEditor/index.tsx +++ b/components/braftEditor/index.tsx @@ -33,7 +33,7 @@ interface IProps { onChange?: Function } -const EditorDemo: React.FC = ({ value, language = 'zh', onChange, cRef, excludeControls = excludeControlsDefault }) => { +const EditorDemo: React.FC = ({ value, language = 'zh', onChange, cRef, excludeControls = excludeControlsDefault, ...others }) => { // 创建一个空的editorState作为初始值 const [editorState, setEditorState] = useState(BraftEditor.createEditorState(null)); const [percent, setPercent] = useState(0); // 进度条 @@ -102,17 +102,23 @@ const EditorDemo: React.FC = ({ value, language = 'zh', onChange, cRef, ), }, ]; + const insertText = (text: string) => { + setEditorState(ContentUtils.insertText(editorState, text)) + } // 向外抛出数据 useImperativeHandle(cRef, () => { return { getHtml, previewMth, + insertText, }; }); + return (