Use of rich text-quill-editor in vue project

1. Basic steps:

  • 1.1 installation
    npm install vue-quill-editor
  • 1.2 Partial registration
    import '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}
    }
  • 1.3 Use
    //content富文本内容  editorOption富文本配置 
    <quill-editor v-model="content" :options="editorOption"/>
    new Vue({
    
    
	    data () {
    
    
		    return {
    
    
		      // 富文本配置
		      editorOption: {
    
    }
		    }
		}
   })

2. The basic configuration of rich text:

As shown below:
Insert picture description here
landing code configuration:

var toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
  ['blockquote', 'code-block'],

  [{
    
     'header': 1 }, {
    
     'header': 2 }],               // custom button values
  [{
    
     'list': 'ordered'}, {
    
     'list': 'bullet' }],
  [{
    
     'script': 'sub'}, {
    
     'script': 'super' }],      // superscript/subscript
  [{
    
     'indent': '-1'}, {
    
     'indent': '+1' }],          // outdent/indent
  [{
    
     'direction': 'rtl' }],                         // text direction

  [{
    
     'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
  [{
    
     'header': [1, 2, 3, 4, 5, 6, false] }],

  [{
    
     'color': [] }, {
    
     'background': [] }],          // dropdown with defaults from theme
  [{
    
     'font': [] }],
  [{
    
     'align': [] }],

  ['clean']                                         // remove formatting button
];

var quill = new Quill('#editor', {
    
    
  modules: {
    
    
    toolbar: toolbarOptions
  },
  theme: 'snow'
});

3. Corresponding style settings:

Background color-background
bold-bold
color-color
font-font
inline code-code
italic-italic
link-link
size-size
strikethrough-strike
superscript/subscript-script
underline-underline
quote-blockquote
title-header
indent -indent
list-list
text alignment-align
text direction-direction
code block-code-block
formula-formula
picture-image
video-video
clear font style-clean

Write the style you want in the toolbar under modules in the option to generate the response style.

		data(){
    
    
            return {
    
    
                Option:{
    
    
                    modules:{
    
    
                        toolbar:[
                            //标题 - header  
                            [{
    
     'header': 1 }, {
    
     'header': 2 }]//列表 - list 
							[{
    
     'list': 'ordered'}, {
    
     'list': 'bullet' }],
							
							//上标/下标 - script 
							[{
    
     'script': 'sub'}, {
    
     'script': 'super' }], 
							
							//缩进 - indent
							[{
    
     'indent': '-1'}, {
    
     'indent': '+1' }],
							
							//文本方向 - direction
							[{
    
     'direction': 'rtl' }],  

                        ]
                    }
                }
            }
        },

The display effect is as follows:
Insert picture description here

Share some plug-ins used in your own projects. If you have a good plug-in, you can comment on it and let's explore it together.

Guess you like

Origin blog.csdn.net/asd577007722/article/details/115056304