Yet Another Quill Editor For Vue 3

Description:

Just another Quill editor for Vue 3 powered projects.

How to use it:

1. Import and register the Quill Editor.

// Import
import { quillEditor, Quill } from 'vue3-quill'
import customQuillModule from 'customQuillModule'
Quill.register('modules/customQuillModule', customQuillModule)
// Register the component globally
app.use(quillEditor)
// Register the component locally
export default {
  components: {
    quillEditor
  }
}

2. Add the Quill Editor component to your app.

<template>
<component v-if="dynamicComponent" :is="dynamicComponent"></component>
  <quill-editor
    v-model:value="state.content"
    :options="state.editorOption"
    :disabled="state.disabled"
    @blur="onEditorBlur($event)"
    @focus="onEditorFocus($event)"
    @ready="onEditorReady($event)"
    @change="onEditorChange($event)"
  />
</template>
import { reactive } from 'vue'
import { quillEditor } from 'vue3-quill'
export default {
  name: 'App',
  components: {
    quillEditor
  },
  setup() {
    const state = reactive({
      dynamicComponent: null,
      content: '<p>Initial Content</p>',
      _content: '',
      editorOption: {
        placeholder: 'core',
        modules: {
          toolbar: [
            // custom toolbars options
            // will override the default configuration
          ],
          // other moudle options here
        }
        // more options
      },
      disabled: false
    })
    const onEditorBlur = quill => {
      console.log('editor blur!', quill)
    }
    const onEditorFocus = quill => {
      console.log('editor focus!', quill)
    }
    const onEditorReady = quill => {
      console.log('editor ready!', quill)
    }
    const onEditorChange = ({ quill, html, text }) => {
      console.log('editor change!', quill, html, text)
      state._content = html
    }
    setTimeout(() => {
      state.disabled = true
    }, 2000)
    return { state, onEditorBlur, onEditorFocus, onEditorReady, onEditorChange }
  }
}

3. Default editor options.

theme: 'snow', // or 'bubble'
boundary: document.body,
modules: {
toolbar: [
  ['bold', 'italic', 'underline', 'strike'],
  ['blockquote', 'code-block'],
  [{ header: 1 }, { header: 2 }],
  [{ list: 'ordered' }, { list: 'bullet' }],
  [{ script: 'sub' }, { script: 'super' }],
  [{ indent: '-1' }, { indent: '+1' }],
  [{ direction: 'rtl' }],
  [{ size: ['small', false, 'large', 'huge'] }],
  [{ header: [1, 2, 3, 4, 5, 6, false] }],
  [{ color: [] }, { background: [] }],
  [{ font: [] }],
  [{ align: [] }],
  ['clean'],
  ['link', 'image', 'video']
]
},
placeholder: 'Insert content here ...',
readOnly: false

Preview:

Yet Another Quill Editor For Vue 3

Changelog:

v0.2.6 (06/21/2021)

  • fixed ‘disabled’ not work while initialization

Download Details:

Author: flyween

Live Demo: https://flyween.github.io/vue3-quill/

Download Link: https://github.com/flyween/vue3-quill/archive/refs/heads/main.zip

Official Website: https://github.com/flyween/vue3-quill

Install & Download:

# NPM
$ npm i vue3-quill

You Might Be Interested In:

Add Comment