Problems with using wangeditor rich text editing in Vue

Problems with using wangeditor rich text editing in Vue

wangEditor is a web rich text editor developed based on javascript and css. It is lightweight, simple, easy to use, open source and free.
It is still frequently used in our actual projects. Here is a case for your reference...

wangEditor documentation: https://www.wangeditor.com/

Rich text editor screenshot:

insert image description here
insert image description here
insert image description here

<!--Rich text editor. http://www.wangeditor.com/
Example of use:
<AppEditor v-model="content"></AppEditor>
-->
<template>
 <article ref="editor" class="AppEditor-root"></article>
</template>
<script>
 const E = require('wangeditor');
 export default {
  name: 'AppEditor',
  model: {
   prop: 'value',
   event: 'update:value',
  },
  props: {
   // value, v-model binding value: {type: String, default: ''},
   //Menu optionsmenus: {
    type: Array,
    default(){
     return [
      : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
    },
   },
  },
  data(){
   return {
    editor: {}, // Editor object_value: '', // Content backup, used for judgment during watch, only changes when the editor is input};
  },
  computed: {},
  mounted(){
   this.initEditor();
  },
  watch:
   value(newValue, oldValue){
    // Editor onchange changes are not processed, only those from the parent component are processed to prevent text rollback bug
    if (newValue != this._value) {
     this.editor.txt.html(newValue);
    }
   },
  },
  methods: {
   initEditor(){
    let editor = new E(this.$refs.editor);
    Object.assign(editor.customConfig, {
     menus: this.menus,
     zIndex: 100,
     height: 200,
     pasteFilterStyle: false,
     onchange: (html) => {
      this._value = html; // Update _value
      this.$emit('update:value', html); // Update value
     },
     customUploadImg:((file, insert)=> {
      if(this.$utils.isEmpty(file)){
       return;
      }
      const msg = this.$Message.loading({
       content: 'Dear, the picture is being uploaded, please wait...',
       duration: 0
      });
      var params = new FormData();
      params.append('img', file[0]);
      this.$api.post('/synthesis/crm/picture/pictureUpload',params).then(res => {
       insert(res.data.imgUrl)
       setTimeout(msg, 0);
       this.$Message.success('Upload successful');
      })
     }),
     uploadImgHooks:{

      customInsert: function (insertImg, result, editor) {
       insertImg(result.url)
      }
     }
    });


    editor.create();
    editor.txt.html(this.value); // For asynchronous data acquisition, it cannot be bound immediately. Watch the judgment and process this.editor = editor;
   },
  },
 };
</script>
<style scoped lang="scss">
 .AppEditor-root{ border: 1px solid #f0f0f0; height: 400px !important;
  /deep/ .we-toolbar{ border: none !important; border-bottom: 1px solid #f0f0f0 !important; background-color: #fff !important;

  }
  /deep/ .we-text-container{ height: calc(100% - 43px) !important; border: none !important; z-index:1 !important;
   .we-text{ height: 100%; overflow-y: auto !important;}
  }
 }

</style>

This is the end of this article about the use of wangeditor rich text editing in Vue. For more relevant wangeditor rich text editing content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to get the html and text of wangeditor in vue
  • How to use rich text editor wangEditor3 in Vue
  • Example of using the lightweight rich text editor wangEditor with vue
  • How to use wangEditor in vue and how to get focus by echoing data

<<:  Some notes on mysql create routine permissions

>>:  About MySQL innodb_autoinc_lock_mode

Recommend

HTML table only displays the outer border of the table

I would like to ask a question. In Dreamweaver, I...

Several practical scenarios for implementing the replace function in MySQL

REPLACE Syntax REPLACE(String,from_str,to_str) Th...

MySQL startup error InnoDB: Unable to lock/ibdata1 error

An error message appears when MySQL is started in...

Implementation of react automatic construction routing

Table of contents sequence 1. Centralized routing...

Summary of four ways to introduce CSS (sharing)

1. Inline reference: used directly on the label, ...

Solution to the low writing efficiency of AIX mounted NFS

Services provided by NFS Mount: Enable the /usr/s...

Detailed explanation of MySQL basic operations (Part 2)

Preface This article contains 1. Several major co...

Implementation principle and configuration of MySql master-slave replication

Database read-write separation is an essential an...

avue-crud implementation example of multi-level complex dynamic header

Table of contents Preface Background data splicin...

Summary of common tool examples in MySQL (recommended)

Preface This article mainly introduces the releva...

Docker volumes file mapping method

background When working on the blockchain log mod...

Detailed explanation of mysql basic operation statement commands

1. Connect to MySQL Format: mysql -h host address...

About the problem of no virtual network card after VMware installation

1 Problem description: 1.1 When VMware is install...

How to view the IP address of the Docker container

I always thought that Docker had no IP address. I...