1.0.0 • Published 3 years ago

vue-my-quill-editor v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

MQuillEditor

A quill editor component for vue.

Example

img

npm

npm install vue-m-quill-editor

use

import MQuillEditor from 'vue-m-quill-editor'

Vue.use(MQuillEditor)
<template>
  <m-quill-editor 
    :width="quill.width"
    :has-border="quill.border"
    v-model="quill.content"
    :sync-output="quill.syncOutput"
    :theme="quill.theme"
    :disabled="quill.disabled"
    :fullscreen="quill.full"
    :toolbar="quill.toolbar"
    @upload="upload"
    ></m-quill-editor>
</template>
<script>
import MQuillEditor from 'm-quill-editor'
export default {
  components: {
    MQuillEditor
  },
  data () {
    return {
      pkg,
      quill: {
        width: 800,
        border: false,
        content: 'wellcome ~',
        syncOutput: false,
        theme: 'snow', //bubble snow
        disabled: false,
        full: false,
        toolbar: [
          [{ 'header': 1 }, { 'header': 2 }],
          ['bold', 'italic', 'underline', 'strike', 'link']
        ]
      }
    }
  },
  methods: {
    upload (file, insert) {
      console.log(file)
      insert('https://avatars0.githubusercontent.com/u/11366654?s=460&v=4', 'center')
    }
  }
}
</script>

MQuillEditor Attributes

参数说明类型可选值默认值
value内容string
width宽度number
height高度number
placeholder占位符string在这里输入内容...
toolbar工具栏配置object
zIndex编辑器z-index值string1000
fullscreen是否全屏booleantrue/falsefalse
show-full-button是否显示全屏按钮booleantrue/falsetrue
syncOutput是否同步value(同步到v-model)booleantrue/falsefalse
theme主题stringbubble/snowsnow
has-border是否显示边框booleantrue/falsefalse
disabled禁用booleantrue/falsefalse
img-accept图片输入框 accept 属性string

toolbar 的值可以是一下数组:

[
  // [{'size': ['small', false, 'large', 'huge']}],
  ['bold', 'italic', 'underline', 'strike', 'link', {'header': [1, 2, 3, 4, 5, 6, false]}],
  // [{ 'header': 1 }, { 'header': 2 }],
  // [{'header': [1, 2, 3, 4, 5, 6, false]}],
  ['blockquote', 'code-block'],
  [{'list': 'ordered'}, {'list': 'bullet'}],
  // [{ 'script': 'sub'}, { 'script': 'super' }],
  // [{ 'indent': '-1'}, { 'indent': '+1' }],
  // [{ 'direction': 'rtl' }],
  [{'color': []}, {'background': []}],
  // [{align: []}],
  // [{ 'align': [false, 'right', 'center', 'justify'] }],
  [{align: ''}, {align: 'right'}, {align: 'center'}, {align: 'justify'}],
  ['image', 'video'],
  ['clean']
]

MQuillEditor Events

事件说明参数
init初始化quill, MQuillEditor
blur失去焦点
focus获取焦点
change内容改变
upload选择图片File, quill.insertImage

MQuillEditor Methods

名称说明参数
setContent设置htmlhtml
getContent获取html
setDisabled禁用

other

Quill

Quill Github

Quill API