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
b99b0aa3
Commit
b99b0aa3
authored
May 14, 2020
by
满振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改子空间
parent
8651474a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
index.tsx
components/braftEditor/index.tsx
+7
-1
No files found.
components/braftEditor/index.tsx
View file @
b99b0aa3
...
@@ -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
}
...
...
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