quill-image-uploader icon indicating copy to clipboard operation
quill-image-uploader copied to clipboard

loading state doesn't show

Open Ahmed-Nassef opened this issue 1 year ago • 5 comments

so in the demo there is a blurred version of the image with a spinner but that doesn't show.

my question is how to add a loading state?

Ahmed-Nassef avatar Aug 12 '23 11:08 Ahmed-Nassef

I was facing the issue.

Just needed to import the stylesheet manually.

import "quill-image-uploader/dist/quill.imageUploader.min.css"

ziadevcom avatar Aug 13 '23 04:08 ziadevcom

thank u I didn't see that!

Edit: I rushed closing the issue I imported the file and still can't see the loading state

Ahmed-Nassef avatar Aug 13 '23 14:08 Ahmed-Nassef

Can you host the app code somewhere where i can see? I told you what solved it for me. Are you sure that stylesheet is even being bundled ?

ziadevcom avatar Aug 19 '23 12:08 ziadevcom

is that enought code?

import "react-quill/dist/quill.snow.css";
import "quill-image-uploader/dist/quill.imageUploader.min.css";
import {ALLOWED_EDITOR_FORMATS} from "./constants"

const Image = Quill.import("formats/image");
Image.className = "quill-image";

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

const quillModule = {
  toolbar: {
    container: TOOLBAR_OPTION,
  },

  imageUploader: {
    upload: async (file: File) => {
      return new Promise(async (resolve, reject) => {
        const formData = new FormData();

        formData.append("image", file);

        try {
          const res = await fetch("/api/decks/images", {
            method: "POST",
            body: formData,
          });

          const data= await res.json();

          if (data.success) {
            resolve(data.image_url);
          } else {
            throw Error(data.message);
          }
        } catch (error) {
          reject();
          console.error(error);
        } 
      });
    },
  },
};

const myApp = () => {
const [value, setValue] = useState('')
return (
    <ReactQuill
      value={value}
      onChange={setValue}
      formats={ALLOWED_EDITOR_FORMATS}
      modules={quillModule}
      ref={editorRef}
    />
)
}

Ahmed-Nassef avatar Aug 26 '23 10:08 Ahmed-Nassef

Try to add imageBlot in your ALLOWED_EDITOR_FORMATS.

singleseeker avatar Oct 11 '23 04:10 singleseeker