Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vue2-editor save image

<template>
  <div id="app">
    <vue-editor use-custom-image-handler @image-added="handleImageAdded" v-model="data[dataItem + lang.code]" :editorOptions="editorSettings"></vue-editor>
  </div>
</template>

<script>
import { VueEditor,Quill } from 'vue2-editor'
import axios from "axios";
import ImageResize from 'quill-image-resize-vue';
import { ImageDrop } from 'quill-image-drop-module';

Quill.register("modules/imageDrop", ImageDrop);
Quill.register("modules/imageResize", ImageResize);

export default {
  name: 'Editor',
  components: {
    VueEditor
  },
  props: ['data', 'lang', 'dataItem'],
  data() {
    return {
      htmlForEditor: "",
      editorSettings: {
        modules: {
          imageDrop: true,
          imageResize: {},
        }
      }
    };
  },

  methods: {
    handleImageAdded: function (file, Editor, cursorLocation, resetUploader) {
      var formData = new FormData();
      formData.append("file", file);
      var vuex = window.localStorage.getItem('vuex')
      var token = JSON.parse(vuex);

      axios({
        url: this.base_url + "/file/fileupload",
        method: "POST",
        data: formData,
        headers: {'Authorization': 'Bearer ' + token.auth.userToken}
      }).then(result => {
        let url = result.data.filePath; // Get url from response
        Editor.insertEmbed(cursorLocation, "image", url);
        resetUploader();
      }).catch(err => {
        alert('yukleme basarisiz! ' + err)
      });
    }
  }
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: enzyme to json 
Javascript :: rest client vs code 
Javascript :: browser console unhide element 
Javascript :: javascript online programming test 
Javascript :: parsing error cannot find module 
Javascript :: convert javascript to jquery converter online tool 
Javascript :: online js to typescript converter 
Javascript :: how to combine folder for render in express js 
Javascript :: push code from vscode using CL 
Javascript :: ERROR in ./node_modules/pretty-format/node_modules/ansi-regex/index.js Module build failed: Error: ENOENT: no such file or directory 
Javascript :: reactjs .map is not a function 
Javascript :: select elm inside a specific id in js 
Javascript :: generate history logs 
Javascript :: KIVIN 
Javascript :: javascript hashmap equivalent 
Javascript :: asp.net mvc with ext js 
Javascript :: Use Set to ensure the uniqueness of a list of values javascript 
Javascript :: html5 web component 
Javascript :: call function on scroll down javascript 
Javascript :: utility javascript function list 
Javascript :: edit mongodb array if checkbox is checked 
Javascript :: input should reject non-alphabetical input reacj js 
Javascript :: dict equivalent js 
Javascript :: Get JSON Key In Array Alternative Syntax 
Javascript :: js rotate matrix 
Javascript :: giftedchat anpm 
Javascript :: i18next plural not working 
Javascript :: Error: Minified React error #321 
Javascript :: ipinfo location javascript 
Javascript :: moment format time 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =