Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
Details
Activity
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
liyang
sts网站
Commits
f13b6d92
Commit
f13b6d92
authored
Apr 13, 2021
by
若依
Browse files
Options
Browse Files
Download
Plain Diff
!205 富文本编辑器自定义上传地址
Merge pull request !205 from hechieh/N/A
parents
5a2a0c09
ccf05b69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
index.vue
ruoyi-ui/src/components/Editor/index.vue
+40
-0
No files found.
ruoyi-ui/src/components/Editor/index.vue
View file @
f13b6d92
<
template
>
<div>
<el-upload
:action=
"uploadUrl"
:on-success=
"handleUploadSuccess"
:before-upload=
"handleBeforeUpload"
:on-error=
"handleUploadError"
name=
"file"
:show-file-list=
"false"
:headers=
"headers"
style=
"display: none;"
ref=
'upload'
v-if=
'this.uploadUrl'
>
</el-upload>
<div
class=
"editor"
ref=
"editor"
:style=
"styles"
></div>
</div>
</
template
>
<
script
>
...
...
@@ -30,6 +45,11 @@ export default {
readOnly
:
{
type
:
Boolean
,
default
:
false
,
},
/* 上传地址 */
uploadUrl
:
{
type
:
String
,
default
:
''
,
}
},
data
()
{
...
...
@@ -95,6 +115,26 @@ export default {
init
()
{
const
editor
=
this
.
$refs
.
editor
;
this
.
Quill
=
new
Quill
(
editor
,
this
.
options
);
// 如果设置了上传地址则自定义图片和视频的上传事件
if
(
this
.
uploadUrl
)
{
let
toolbar
=
this
.
Quill
.
getModule
(
'toolbar'
);
toolbar
.
addHandler
(
'image'
,
(
value
)
=>
{
this
.
uploadType
=
'image'
;
if
(
value
)
{
this
.
$refs
.
upload
.
$children
[
0
].
$refs
.
input
.
click
();
}
else
{
this
.
quill
.
format
(
'image'
,
false
);
}
});
toolbar
.
addHandler
(
'video'
,
(
value
)
=>
{
this
.
uploadType
=
'video'
;
if
(
value
)
{
this
.
$refs
.
upload
.
$children
[
0
].
$refs
.
input
.
click
();
}
else
{
this
.
quill
.
format
(
'video'
,
false
);
}
});
}
this
.
Quill
.
pasteHTML
(
this
.
currentValue
);
this
.
Quill
.
on
(
"text-change"
,
(
delta
,
oldDelta
,
source
)
=>
{
const
html
=
this
.
$refs
.
editor
.
children
[
0
].
innerHTML
;
...
...
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