NoelOConnell / quill-image-uploader

A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded
MIT License
243 stars 98 forks source link

Fix for error when cancel uploading before success #91

Open Jerome-1010 opened 1 year ago

Jerome-1010 commented 1 year ago

Since this.placeholderDelta is updated only when the image upload is successful, the following two problems were occurring.

  1. If the process was aborted before a successful upload, calculartePlaceholderInsertLength would refer to null properties and generate an error. https://github.com/NoelOConnell/quill-image-uploader/commit/6ebbba718b8829c637d9ccb1740bd216c1fb370c
  2. this.placeholderDelta was never reset, so this.placeholderDelta obtained during the last upload could be referenced at the next upload timing. https://github.com/NoelOConnell/quill-image-uploader/commit/365cc4757363b547acb79a07d985d736985adc12

These errors occur when the following functions are passed to the upload property.

options: {
  upload: async (file) => {
    if (file.size > 10 * 1024 * 1024) {
      throw new Error('A file size exceeded!');
    }
    return uploadFunc(file);
  },
},
maykon-oliveira commented 10 months ago

Close #38

victorLessa commented 5 months ago

The problem that this PR intends to solve avoids the need to force the solution presented above, not every case is resolved with the previously suggested behavior