Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading state doesn't show #94

Open
Ahmed-Nassef opened this issue Aug 12, 2023 · 5 comments
Open

loading state doesn't show #94

Ahmed-Nassef opened this issue Aug 12, 2023 · 5 comments

Comments

@Ahmed-Nassef
Copy link

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?

@ziadevcom
Copy link

I was facing the issue.

Just needed to import the stylesheet manually.

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

@Ahmed-Nassef
Copy link
Author

Ahmed-Nassef commented Aug 13, 2023

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

@ziadevcom
Copy link

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 ?

@Ahmed-Nassef
Copy link
Author

Ahmed-Nassef commented Aug 26, 2023

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}
    />
)
}

@singleseeker
Copy link

Try to add imageBlot in your ALLOWED_EDITOR_FORMATS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants