ð¡Quill editor component for Vue, support SPA and SSR.
åºäº Quillãéç¨äº Vue ç坿æ¬ç¼è¾å¨ï¼æ¯ææå¡ç«¯æ¸²æåå页åºç¨ã
Example Projects Using Vue-Quill-Editor Install CDNNPM<link rel="stylesheet" href="path/to/quill.core.css"/>
<link rel="stylesheet" href="path/to/quill.snow.css"/>
<link rel="stylesheet" href="path/to/quill.bubble.css"/>
<script type="text/javascript" src="path/to/quill.js"></script>
<script type="text/javascript" src="path/to/vue.min.js"></script>
<script type="text/javascript" src="path/to/dist/vue-quill-editor.js"></script>
<script type="text/javascript">
  Vue.use(window.VueQuillEditor)
</script>Â
Mount mount with globalnpm install vue-quill-editor --save
mount with componentimport Vue from 'vue'
import VueQuillEditor from 'vue-quill-editor'
Â
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Â
Vue.use(VueQuillEditor, )
mount with ssrimport 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Â
import { quillEditor } from 'vue-quill-editor'
Â
export default {
  components: {
    quillEditor
  }
}
register quill moduleif (process.browser) {
  const VueQuillEditor = require('vue-quill-editor/dist/ssr')
  Vue.use(VueQuillEditor, )
}
Differenceï¼ä½¿ç¨æ¹æ³çåºå«ï¼import Quill from 'quill'
import yourQuillModule from '../yourModulePath/yourQuillModule.js'
Quill.register('modules/yourQuillModule', yourQuillModule)
SSR and the only difference in the use of the SPA:
component
, find quill instance by ref attribute
.directive
, find quill instance by directive arg
.SPA<!-- You can custom the "myQuillEditor" name used to find the quill instance in current component -->
<template>
  <!-- bidirectional data bindingï¼ååæ°æ®ç»å®ï¼Â -->
  <div class="quill-editor"Â
       v-model="content"
       v-quill:myQuillEditor="editorOption">
  </div>
Â
  <!-- Or manually control the data synchronizationï¼æå¨æ§å¶æ°æ®æµï¼Â  -->
  <div class="quill-editor"Â
       :content="content"
       @change="onEditorChange($event)"
       v-quill:myQuillEditor="editorOption">
  </div>
</template>
Â
<script>
  export default {
    data() {
      return {
        content: '<p>example content</p>',
        editorOption: { /* quill options */ }
      }
    },
    mounted() {
      console.log('this is current quill instance object', this.myQuillEditor)
    },
    methods: {
      onEditorChange(event) {
        console.log('onEditorChange')
      }
    },
    // Omit the same parts as in the following component sample code
    // ...
  }
</script>
Modules<template>
  <!-- bidirectional data bindingï¼ååæ°æ®ç»å®ï¼Â -->
  <quill-editor v-model="content"
                ref="myQuillEditor"
                :options="editorOption"
                @blur="onEditorBlur($event)"
                @focus="onEditorFocus($event)"
                @ready="onEditorReady($event)">
  </quill-editor>
Â
  <!-- Or manually control the data synchronizationï¼ææå¨æ§å¶æ°æ®æµï¼Â -->
  <quill-editor :content="content"
                :options="editorOption"
                @change="onEditorChange($event)">
  </quill-editor>
</template>
Â
<script>
Â
  // you can also register quill modules in the component
  import Quill from 'quill'
  import { someModule } from '../yourModulePath/someQuillModule.js'
  Quill.register('modules/someModule', someModule)
 Â
  export default {
    data () {
      return {
        content: '<h2>I am Example</h2>',
        editorOption: {
          // some quill options
        }
      }
    },
    // manually control the data synchronization
    //Â å¦æéè¦æå¨æ§å¶æ°æ®åæ¥ï¼ç¶ç»ä»¶éè¦æ¾å¼å°å¤çchangedäºä»¶
    methods: {
      onEditorBlur(quill) {
        console.log('editor blur!', quill)
      },
      onEditorFocus(quill) {
        console.log('editor focus!', quill)
      },
      onEditorReady(quill) {
        console.log('editor ready!', quill)
      },
      onEditorChange({ quill, html, text }) {
        console.log('editor change!', quill, html, text)
        this.content = html
      }
    },
    computed: {
      editor() {
        return this.$refs.myQuillEditor.quill
      }
    },
    mounted() {
      console.log('this is current quill instance object', this.editor)
    }
  }
</script>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4