0.3.1 • Published 8 months ago

vue3-quill v0.3.1

Weekly downloads
61
License
MIT
Repository
github
Last release
8 months ago

vue3-quill

Quill editor for vue3

Homepage

vue3-quill github-page

Usage

npm i vue3-quill

Global Registration:

// global
import { quillEditor } from 'vue3-quill'
app.use(quillEditor)

or Local Registration:

// single file
import { quillEditor } from 'vue3-quill'

export default {
  components: {
    quillEditor
  }
}

Module registration example:

// global
import { quillEditor, Quill } from 'vue3-quill'

// Attention:
// customQuillModule means 'custom module name of Quill',
// not a package's name called 'customQuillModule'.
// Such as:
// import ImageUploader from "quill.imageUploader.js";
// Quill.register("modules/imageUploader", ImageUploader);

import customQuillModule from 'customQuillModule'
Quill.register('modules/customQuillModule', customQuillModule)
app.use(quillEditor)

or in a single component

import { quillEditor, Quill } from 'vue3-quill'
// Attention:
// customQuillModule means 'custom module name of Quill',
// not a package's name called 'customQuillModule'.
// Such as:
// import ImageUploader from "quill.imageUploader.js";
// Quill.register("modules/imageUploader", ImageUploader);
import customQuillModule from 'customQuillModule'
Quill.register('modules/customQuillModule', customQuillModule)

export default {
  components: {
    quillEditor
  }
}

In .vue

<template>
  <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>

<script>
import { reactive } from 'vue'

export default {
  name: 'App',
  setup() {
    const state = reactive({
      content: '<p>2333</p>',
      _content: '',
      editorOption: {
        placeholder: 'core',
        modules: {
          // toolbars: [
            // custom toolbars options
            // will override the default configuration
          // ],
          // other moudle options here
          // otherMoudle: {}
        },
        // 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 }
  }
}
</script>

Options

Form Input Bindings: v-model

The v-model directive can be used to create a two-way data binding. For example:

<quill-editor v-model:value="state.content"></quill-editor>

Event binding

<quill-editor
    v-model:value="state.content"
    @blur="onEditorBlur($event)"
    @focus="onEditorFocus($event)"
    @ready="onEditorReady($event)"
    @change="onEditorChange($event)"
  />

The following events are available:

  • blur
  • focus
  • ready
  • change

Options prop

  • options
    Apply the default options by not passing this prop.
    The options passed in will override the default preset options.
    For example:
    modules: {
      toolbar: []
    }
    this option will generate an empty toolbar.
    Check the offical doc Quill Documentation for all options.
  • disabled
    Default: false
    Set true to disabled the editor. As the value of readOnly when initialized. Value changing will call API Quill Documentation of quill after initialization.

Default Quill options

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']
  ]
}

Packages

Borrowing from: vue-quill-editor Inspired by this one.

Quill ImageHandler Module
...

Development

# root dir
yarn serve

Welcome PR

Thanks to the open source. :heart:

@csii-lowcode/designervform3-builds-pluscx-variant-form3hlw-v-formvariant-form3wkl-form3wklform@infinitebrahmanuniverse/nolb-vue3-qanyi-process-ee-antvuepg4-console-uiskillfull-process-pro-antvue@everything-registry/sub-chunk-3100cbd-dyformiking-low-codeiking-formiking-form-pro@wangwangwang963/formcomponental-variant-form3alp_customform_1angh-variant-form3@52css/vform3-builds@zjwit/agriculture@ddsfe/designcsii-lowcode-designerc-form3bv-formcjt-ty-formdesign@csii-lowcode/plugin-designer-vformkt-form-renderlemon_form_designlemon_front_form-designlims-vformlk-party-vformlk-vform-projinhewwzslchart-uizslg2chart-uiy-variant-form3y-variant-form3.1wangyumeng-formtemplatevue3-kuangkeym-vfor-mobile-proym-vform-proym-formv3xiems-form-desingerxiems-form-desinger1v-form-buildvariant-form-copyvariant-form3-ldvariant-form3-provariant-form3-test1variant-form3-yysvform-pro-pc-qgvform3-plusvform3-twicedevvform3-vue3vform3-yqvform-autodevvform-dyys-pcvform-jyvcu-form-v3ts-form-pro-mobiletest-vform3test-vform3-trantg-form-protg-form-pro-mobilevisable-echartscz-questionczy-variant-form3lz-resource-center-form@gwdata/chatjk-vform3autodev-frameworkmy-variant-form3mo-form-simplemo-formmo-form-render-mobiledd-form-render-v3dd-form3doze_variant-form3dh-formdh-form3element-screen-designerermiaozia-test1ermiaozia-test3ezlcp-form-vue3@imlinhanchao/variant-form3duohu-form3esi-low-designform-design-ltyform-table-renderfjsc-form-enginessh-vforma3gd-form-teststar-designform-design-yh@psy21d/pdf-editorh-create-form3gnc-formsumfen-form-builds
0.3.1

8 months ago

0.3.0

2 years ago

0.2.7

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

4 years ago

0.1.0

4 years ago