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

Image upload toolbar bug #4093

Closed
cstisa opened this issue Mar 27, 2024 · 8 comments
Closed

Image upload toolbar bug #4093

cstisa opened this issue Mar 27, 2024 · 8 comments

Comments

@cstisa
Copy link

cstisa commented Mar 27, 2024

The problem seems to be only present in version 2.0.0-rc.2 but not in 1.3.7.

When I click on upload image button, instead of the file explorer, QuillJS opens the same popup as the link upload.

Steps for Reproduction

  1. Visit quilljs.com
  2. Click on upload image button in the toolbar

Expected behavior:

When clicking on the upload image button in the toolbar, the file explorer pop-up should appear.
image

Actual behavior:
The link upload pop-up appears
image

Platforms:
Tested on Edge, Chrome and Mozilla
Each time, the QuillJS upload image button in the toolbar doesn't work in v 2.0.0-rc.2

Version: 2.0.0-rc.2

I don't need to paste some of my code, since this behaviour is happening on the QuillJS website directly.

Does someone has a solution?

@efazenda
Copy link

efazenda commented Apr 2, 2024

Up this issue

@remyd74
Copy link

remyd74 commented Apr 2, 2024

Maybe use another library ? #Joke

@anisabboud
Copy link

I encountered the same issue: When clicking the image button in the toolbar:

  • Quill v1.3.7 would open the image upload/selection window, and insert the image into the editor in Base64 format.
  • Quill v2.0.0 is opening a text input for URL instead.

Here's a video illustrating the issue (comparing https://quilljs.com vs https://v1.quilljs.com):

2024-04-17.Quill.v1.vs.v2.image.uploading.mp4

How to revert this behavior?
Thank you and congrats on the launch of Quill v2!

@anisabboud
Copy link

Related pull request ("image selector fix"): #4120

@anisabboud
Copy link

Summarizing the fix suggested in https://github.com/quilljs/quill/pull/4120/files:

Current code

https://github.com/quilljs/quill/blob/3454595a2eda53f7990001ec4e0234285ad95f1d/packages/quill/src/core/quill.ts#L800-L815

Suggested fix by @medi6 #4120

  1. Move const modules ... after the if
  2. Replace each modules inside the if with options.modules (5 occurrences)

Result

  // Special case toolbar shorthand
  if (
    options.modules != null &&
    options.modules.toolbar &&
    options.modules.toolbar.constructor !== Object
  ) {
    options.modules.toolbar = {
      container: options.modules.toolbar,
    };
  }
  const modules: ExpandedQuillOptions['modules'] = merge(
    {},
    expandModuleConfig(quillModuleDefaults),
    expandModuleConfig(themeModuleDefaults),
    expandModuleConfig(options.modules),
  );

Note

In the PR, @medi6 also cloned const userOptions = {...options}; to avoid mutating options directly.

@medi6
Copy link
Contributor

medi6 commented Apr 18, 2024

Hi @anisabboud ,

you can fix this by code in your app, also, but it' a temporary solution, waiting for a new release.

     // fix temporaire pour les handlers
    if (this.quillEditor?.theme.modules.toolbar && this.quillEditor?.options.theme) {
      if (this.quillEditor?.theme.modules.toolbar.handlers) {
        Object.keys( (<Toolbar>(<Quill>this.quillEditor).options.theme.DEFAULTS.modules.toolbar).handlers).forEach(format => {
          const handler = (<Toolbar>(<Quill>this.quillEditor).options.theme.DEFAULTS.modules.toolbar).handlers?.[format];
          if (handler) {
            (<Toolbar>(<Quill>this.quillEditor).theme.modules.toolbar).addHandler(format, handler);
          }
        });
      }
    } 

@luin
Copy link
Member

luin commented Apr 22, 2024

Closing with #4120

@luin luin closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants