QuillImageDropAndPaste
A quill editor module for drop and paste image, with a callback hook before inserting image into the editor.
This module was forked from [quill-image-drop-module]: https://www.npmjs.com/package/quill-image-drop-module
The only difference was that we could choose how to handle the image we just dropped or pasted, without inserting a base64 url image into the editor directly.
For example, a base64 string was too large, if we saved it into the database, it could easilly out of the size of the column, the best practice was to save the image on our server and returned the image's url, and finally we inserted the image with the returned url into the editor.
Examples
Install
npm install quill-image-drop-and-paste --save
Usage
ES6
Quill const quill = '#editor-container' modules: imageDropAndPaste: // add an custom image handler handler: imageHandler /*** Do something to our dropped or pasted image* @param.imageDataUrl - image's base64 url* @param.type - image's mime type* @param.file - File Object*/ { // give a default mime type if the type was null if !type type = 'image/png' // base64 to blob var blob = var filename = 'my' 'cool' 'image' '-' Math '-' '.' type1 // generate a form data var formData = formData formData // upload image to your server }
Additional, you could rewrite the toolbar's insert image button with our image handler.
quill
Script Tag
Copy quill-image-drop-and-paste.min.js into your web root or include from node_modules
var quill = editorSelector // ... modules: imageDropAndPaste: // add an custom image handler handler: imageHandler ;
Finally
If you didnot config a image handler, it will insert the image into the quill editor directory after you drop/paste a image. Just like the module [quill-image-drop-module]: https://www.npmjs.com/package/quill-image-drop-module did.