Skip to content

Commit

Permalink
Ignore pasting images when image format is disallowed (#4202)
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored May 13, 2024
1 parent dd62291 commit 8040680
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/quill/src/modules/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ class Uploader extends Module<UploaderOptions> {
Uploader.DEFAULTS = {
mimetypes: ['image/png', 'image/jpeg'],
handler(range: Range, files: File[]) {
const promises = files.map((file) => {
if (!this.quill.scroll.query('image')) {
return;
}
const promises = files.map<Promise<string>>((file) => {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e) => {
// @ts-expect-error Fix me later
resolve(e.target.result);
reader.onload = () => {
resolve(reader.result as string);
};
reader.readAsDataURL(file);
});
Expand Down

0 comments on commit 8040680

Please sign in to comment.