vue2-quill2-editor
How to use
<template>
<div class="demo">
<vue2-quill2-editor
ref="vue2Quill2Editor"
:upload-function="uploadFunction"
>
</vue2-quill2-editor>
<CmsJournal></CmsJournal>
</div>
</template>
<script>
import axios from 'axios'
import Vue from 'vue'
import Editor from 'vue2-quill2-editor/dist/index'
Vue.use(Editor)
export default {
components: {Editor},
data () {
return {}
},
methods: {
uploadFunction (range, fileList) {
const headers = {
'eptoken': '7856456e-7b5d-4f3a-be37-a98d0ba51d8d',
'Content-Type': 'application/json'
}
let file = fileList[0]
const fileName = file.name.toString()
// 使用FormData构建请求
const formData = new FormData()
formData.append('file', file) // 添加文件
formData.append('fileName', fileName)
formData.append('linkId', '999') // 示例字段
formData.append('linkType', 'journal') // 示例字段
formData.append('inText', 1) // 示例字段
axios.post('http://localhost:8090/file/upload', formData, {headers}).then(json => {
const Delta = this.$refs.vue2Quill2Editor.quill.constructor.import('delta'); // 使用构造函数访问
// 下面三行必填
const cursorPosition = this.$refs.vue2Quill2Editor.quill.getSelection().index
this.$refs.vue2Quill2Editor.quill.updateContents(new Delta().retain(cursorPosition).insert({image: json.data.data}))
this.$refs.vue2Quill2Editor.quill.setSelection(cursorPosition + 1, 0)
})
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
Related Packages
@kodaeditor/vue2
Vue 2 wrapper for KodaEditor: a WYSIWYG rich-text editor that keeps Word and Exc...
1,118
0
@shamimsofte/universal-editor-vue2
Vue 2 adapter for Universal Rich Text Editor (Vue 2.6+ & 2.7)
571
0
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.68 | ^2.7.16 | ISC | |
| 1.0.67 | ^2.7.16 | ISC | |
| 1.0.66 | ^2.7.16 | ISC | |
| 1.0.65 | ^2.7.16 | ISC | |
| 1.0.64 | ^2.7.16 | ISC | |
| 1.0.63 | ^2.7.16 | ISC | |
| 1.0.52 | ^2.7.16 | ISC | |
| 1.0.51 | ^2.7.16 | ISC | |
| 1.0.49 | ^2.7.16 | ISC | |
| 1.0.48 | ^2.7.16 | ISC | |
| 1.0.47 | ^2.7.16 | ISC | |
| 1.0.46 | ^2.7.16 | ISC | |
| 1.0.45 | ^2.7.16 | ISC | |
| 1.0.43 | ^2.7.16 | ISC | |
| 1.0.42 | ^2.7.16 | ISC | |
| 1.0.41 | ^2.7.16 | ISC | |
| 1.0.40 | ^2.7.16 | ISC | |
| 1.0.39 | ^2.7.16 | ISC | |
| 1.0.38 | ^2.7.16 | ISC | |
| 1.0.37 | ^2.7.16 | ISC | |
| 1.0.36 | ^2.7.16 | ISC | |
| 1.0.35 | ^2.7.16 | ISC | |
| 1.0.34 | ^2.7.16 | ISC | |
| 1.0.33 | ^2.7.16 | ISC | |
| 1.0.32 | ^2.7.16 | ISC | |
| 1.0.31 | ^2.7.16 | ISC | |
| 1.0.30 | ^2.7.16 | ISC | |
| 1.0.29 | ^2.7.16 | ISC | |
| 1.0.28 | ^2.7.16 | ISC | |
| 1.0.27 | ^2.7.16 | ISC |
Showing the latest 30 of 56. See every release on npm