@servicetitan/dte-unlayer 0.155.0 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor-core-source.d.ts +1 -1
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +1 -1
- package/dist/editor-core-source.js.map +1 -1
- package/dist/image-upload-error.d.ts +5 -0
- package/dist/image-upload-error.d.ts.map +1 -0
- package/dist/image-upload-error.js +8 -0
- package/dist/image-upload-error.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/fonts.js +1 -1
- package/dist/shared/fonts.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +6 -8
- package/dist/store.js.map +1 -1
- package/dist/tools.js +1 -1
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/store.image-upload.test.ts +132 -0
- package/src/editor-core-source.ts +1 -1
- package/src/image-upload-error.ts +7 -0
- package/src/index.ts +1 -0
- package/src/shared/fonts.ts +1 -1
- package/src/store.ts +8 -4
- package/src/tools.ts +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Reject `onImage` with this error to show its message to the user instead of the generic upload failure text. */
|
|
2
|
+
export class ImageUploadError extends Error {
|
|
3
|
+
constructor(message: string, options?: ErrorOptions) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = 'ImageUploadError';
|
|
6
|
+
}
|
|
7
|
+
}
|
package/src/index.ts
CHANGED
package/src/shared/fonts.ts
CHANGED
package/src/store.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { emitESignOffsetRequest } from './e-sign-offset/eSignOffsetController';
|
|
2
|
+
import { ImageUploadError } from './image-upload-error';
|
|
2
3
|
import { loadScript } from './loadScript';
|
|
3
4
|
import { logUnlayerError } from './log';
|
|
4
5
|
import { toUnlayerMergeTags, type UnlayerMergeTagsConfig } from './merge-tags';
|
|
@@ -720,8 +721,10 @@ export class UnlayerStore {
|
|
|
720
721
|
return;
|
|
721
722
|
}
|
|
722
723
|
|
|
723
|
-
|
|
724
|
-
|
|
724
|
+
/*
|
|
725
|
+
* Unlayer only leaves its "uploading" state when `done` receives a url, so `done` must not be
|
|
726
|
+
* called before the upload succeeds or after it fails, otherwise the image widget gets stuck.
|
|
727
|
+
*/
|
|
725
728
|
try {
|
|
726
729
|
const { url } = await this.onImageCB(file);
|
|
727
730
|
done({ progress: 100, url });
|
|
@@ -729,9 +732,10 @@ export class UnlayerStore {
|
|
|
729
732
|
logUnlayerError('Image upload failed', error);
|
|
730
733
|
this.onErrorCB?.(
|
|
731
734
|
'Image upload failed',
|
|
732
|
-
|
|
735
|
+
error instanceof ImageUploadError
|
|
736
|
+
? error.message
|
|
737
|
+
: 'Something went wrong while uploading the image. Please try again or select another image.',
|
|
733
738
|
);
|
|
734
|
-
done({ progress: 100 });
|
|
735
739
|
}
|
|
736
740
|
};
|
|
737
741
|
|
package/src/tools.ts
CHANGED