NoelOConnell/quill-image-uploader

I don't know how to make this module work in React Quill

Closed this issue · 4 comments

Hello, first of all thanks for this module.

I know this is probably not the right place for this - but can you please refer me to an example of implementing this module with React-Quill?

Thanks in advance.

What version of react-quill are you using?

You should be able to import it and add it to the modules prop in React

Managed to make it work, thanks.

In case this helps anyone, here is how I've implemented it with react-quill:

import React from 'react';
import 'react-quill/dist/quill.snow.css';
import ImageUploader from "quill-image-uploader";
import ReactQuill, { Quill } from 'react-quill';

import { uploadFile } from '../api';

Quill.register("modules/imageUploader", ImageUploader);

const modules = {
    toolbar: [
        [ 'image'],
    ],
    imageUploader: {
        upload: file => uploadFile(file).then(({ url }) => url),
    },
}
const ContentEditor = ({ content, onContentChange }) => {
    return <ReactQuill
        defaultValue={content}
        onChange={onContentChange}
        modules={modules}
        theme="snow"
    />
}

export default ContentEditor;

Thanks @mmabraham

I've added a react-quill example in the readme.
There's a link to a codesandbox

If you are passing custom formats to the react-quill editor then you need to add "imageBlot" to the array of formats.