Coder Social home page Coder Social logo

10chars / quill-image-uploader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from noeloconnell/quill-image-uploader

0.0 2.0 0.0 432 KB

A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded

JavaScript 61.26% HTML 30.13% CSS 8.60%

quill-image-uploader's Introduction

Quill ImageHandler Module

A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded License: MIT

Demo

Image Uploading Demo GIF

Install

Install with npm:

npm install quill-image-uploader --save

Usage

Include the CSS for the loading effect or create your own.

const quill = new Quill(editor, {
  // ...
  modules: {
    // ...
    imageUploader: {
      upload: file => {
        // return a Promise that resolves in a link to the uploaded image
        return new Promise((resolve, reject) => {
          const fd = new FormData();
          fd.append("upload_file", file);

          const xhr = new XMLHttpRequest();
          xhr.open("POST", `${window.location.pathname}/api/files/add`, true);
          xhr.onload = () => {
            if (xhr.status === 200) {
              const response = JSON.parse(xhr.responseText);
              resolve(response.file_path); // Must resolve as a link to the image
            }
          };
          xhr.send(fd);
        });
      }
    }
  }
});

quill-image-uploader's People

Contributors

noeloconnell avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.