|
|
@ -1,14 +1,12 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="quill" ref="quill" :class="classes"> |
|
|
|
<div class="quill" ref="quill" :class="classes"> |
|
|
|
<div ref="editor" :style="styles" v-loading="loading"></div> |
|
|
|
<div ref="editor" :style="styles" v-loading="loading"></div> |
|
|
|
|
|
|
|
|
|
|
|
<el-upload |
|
|
|
<el-upload |
|
|
|
:headers="headers" |
|
|
|
:headers="headers" |
|
|
|
:action="this.api.fileupload" |
|
|
|
:action="this.api.fileupload" |
|
|
|
:before-upload="beforeUpload" |
|
|
|
:before-upload="beforeUpload" |
|
|
|
:on-success="editorUploadSuccess" |
|
|
|
:on-success="editorUploadSuccess" |
|
|
|
style="display: none" |
|
|
|
style="display: none"> |
|
|
|
> |
|
|
|
|
|
|
|
<el-button class="editorUpload" type="primary">点击上传</el-button> |
|
|
|
<el-button class="editorUpload" type="primary">点击上传</el-button> |
|
|
|
</el-upload> |
|
|
|
</el-upload> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -180,11 +178,16 @@ |
|
|
|
// 如果上传成功 |
|
|
|
// 如果上传成功 |
|
|
|
if (res.data.filesResult.fileUrl) { |
|
|
|
if (res.data.filesResult.fileUrl) { |
|
|
|
// 获取光标所在位置 |
|
|
|
// 获取光标所在位置 |
|
|
|
let length = quill.getSelection().index; |
|
|
|
let lengths; |
|
|
|
|
|
|
|
if ( quill.getSelection() == null){ |
|
|
|
|
|
|
|
lengths = 1 |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
lengths = quill.getSelection().index; |
|
|
|
|
|
|
|
} |
|
|
|
// 插入图片,res为服务器返回的图片链接地址 |
|
|
|
// 插入图片,res为服务器返回的图片链接地址 |
|
|
|
quill.insertEmbed(length, 'image', res.data.filesResult.fileUrl) |
|
|
|
quill.insertEmbed(lengths, 'image', res.data.filesResult.fileUrl) |
|
|
|
// 调整光标到最后 |
|
|
|
// 调整光标到最后 |
|
|
|
quill.setSelection(length + 1) |
|
|
|
quill.setSelection(lengths + 1) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.$message.success('图片插入失败') |
|
|
|
this.$message.success('图片插入失败') |
|
|
|
} |
|
|
|
} |
|
|
|