Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
submodule
Commits
8651474a
Commit
8651474a
authored
May 14, 2020
by
满振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改子组件
parent
57facb12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
index.tsx
components/braftEditor/index.tsx
+7
-7
No files found.
components/braftEditor/index.tsx
View file @
8651474a
...
...
@@ -38,13 +38,14 @@ const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef,
const
[
editorState
,
setEditorState
]
=
useState
(
BraftEditor
.
createEditorState
(
null
));
const
[
percent
,
setPercent
]
=
useState
(
0
);
// 进度条
const
previewRef
=
useRef
(
null
);
useEffect
(()
=>
{
// 使用BraftEditor.createEditorState将html字符串转换为编辑器需要的editorStat
setEditorState
(
BraftEditor
.
createEditorState
(
value
));
if
(
value
&&
typeof
value
===
'object'
)
{
// 不做转换
setEditorState
(
value
)
}
else
{
// 使用BraftEditor.createEditorState将html字符串转换为编辑器需要的editorStat
setEditorState
(
BraftEditor
.
createEditorState
(
value
));
}
},
[
value
]);
// 获取HTML
const
getHtml
=
()
=>
{
// 直接调用editorState.toHTML()来获取HTML格式的内容
...
...
@@ -57,8 +58,7 @@ const EditorDemo: React.FC<IProps> = ({ value, language = 'zh', onChange, cRef,
const
handleEditorChange
=
(
editorState
:
any
)
=>
{
setEditorState
(
editorState
);
if
(
onChange
)
{
const
htmlContent
=
editorState
.
toHTML
();
onChange
(
editorState
,
htmlContent
);
onChange
(
editorState
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment