vue2-quill2-editor

A rich text editor component for Vue 2 based on Quill 2, supporting tables, image upload/resize, color picker and custom HTML blocks.
1,782 1
Install
npm install vue2-quill2-editor
Latest Version:1.0.68
Vue:2
License:ISC
Last Updated:Sep 14, 2026
Links: GitHub  ·  npm
Maintainer: a59852855

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
vue-wysiwyg

A WYSIWYG HTML editor for Vue.js

564,994
vue-bulma-quill

Your powerful, rich text editor for Vue

11,507 32
@shamimsofte/universal-editor-vue2

Vue 2 adapter for Universal Rich Text Editor (Vue 2.6+ & 2.7)

571 0
@ddosdor/vue-sh-wysiwyg

Simple and very basic Wysiwyg editor for Vue.js

320 3

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