dev_2022-03-03
e 3 years ago
parent 73a317582c
commit 2f6ea7ff59
  1. 2
      .gitignore
  2. 15
      src/components/quill/index.vue

2
.gitignore vendored

@ -2,7 +2,7 @@
node_modules node_modules
/dist /dist
example.html example.html
favicon.ico #favicon.ico
# local env files # local env files
.env.local .env.local
.env.*.local .env.*.local

@ -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('图片插入失败')
} }

Loading…
Cancel
Save