quill-image-uploader-nextjs

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

Usage no npm install needed!

<script type="module">
  import quillImageUploaderNextjs from 'https://cdn.skypack.dev/quill-image-uploader-nextjs';
</script>

README

Quill ImageHandler Module for NextJS

A modifed alternative of Quill Image Upload Plugin to support NextJS

The original plugin uses css import in node_modules, which is not supported by the latest NextJS.

Credits

The full credit for the editor plugin goes to Quill Image Upload Plugin and this is a modificaion to support the NextJS.

Therefore, keep upto date on its issue tracker whether the issue is fixed.

Install

Install with npm:

npm install quill-image-uploader-next --save

Webpack/ES6

import Quill from "quill";
import ImageUploader from "quill.imageUploader.js";
import 'quill-image-uploader-next/src/quill.imageUploader.css';

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

const quill = new Quill(editor, {
  // ...
  modules: {
    // ...
    imageUploader: {
      upload: (file) => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve(
              "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/480px-JavaScript-logo.png"
            );
          }, 3500);
        });
      },
    },
  },
});

Note: It's also important that you create a quill component and dynamically import the component with SSR: false for NextJS.

e.g: No SSR Editor component includes all the above code.


const QuillNoSSR = dynamic(
  () => import('src/components/no-ssr-editor').then(md => md.default),
  { ssr: false }
);