benwinding / quill-image-compress

A Quill rich text editor Module which compresses images uploaded to the editor
https://benwinding.github.io/quill-image-compress/src/demo.html
MIT License
123 stars 30 forks source link

error with angular quill #27

Open amirhosein5858 opened 2 years ago

amirhosein5858 commented 2 years ago

hi,i cant use this library with ngx-quill! could you help me please ?

Screen Shot 2022-01-15 at 7 23 56 AM
benwinding commented 2 years ago

Can you please provide more information? Example code? The versions of the libraries you are using?

berthertogen commented 2 years ago

We were experiencing the same issue after an angular upgrade (and all related packages). Current versions:

package-lock

    ...
    "@angular/common": "13.3.11",
    "@angular/compiler": "13.3.11",
    "@angular/core": "13.3.11",
    ...
    "ngx-quill": "16.2.1",
    "quill": "1.3.7",
    "quill-image-compress": "1.2.26",

What eventually solved this issue for us was to change the way we loaded the plugin.

In our component.ts we loaded the imageCompressor instead of the ImageCompress this way: import { imageCompressor } from 'quill-image-compress';

We then put that in a public variable: imageCompressImplementation = imageCompressor;

And registered the plugin in the html like so:

    <quill-editor
      id="editor"
      #editor
      sanitize="true"
      placeholder=""
      class="mat-form-field"
      [modules]="modules"
      [customModules]="[{path: 'modules/imageCompress', implementation: imageCompressImplementation}]"
    ></quill-editor>

Our modules are defined as follow in the ts file:

  modules: any = {
    toolbar: [
      ['bold', 'italic', 'underline'],
      ['link', 'image'],
      [{ 'list': 'ordered' }, { 'list': 'bullet' }],
    ],
    imageCompress: {
      quality: 0.7, // default
      maxWidth: 1024, // default
      maxHeight: 1024, // default
      imageType: 'image/jpeg', // default
      debug: false, // default
    },
  };
benwinding commented 1 year ago

Try version quill-image-compress@1.2.28 might of been fixed by https://github.com/benwinding/quill-image-compress/commit/7f1ebda29594934c8b0579a5cd6d4d4101728019