@zcomponent/core 1.21.0 → 1.21.1-beta
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.
|
@@ -23,6 +23,10 @@ export class DownloadSnapshot extends ActionBehavior {
|
|
|
23
23
|
const link = document.createElement('a');
|
|
24
24
|
link.href = dataUrl;
|
|
25
25
|
const file = snapshotContext.canvasFile.value;
|
|
26
|
+
if (!file) {
|
|
27
|
+
console.error('No file to download. Ensure a snapshot has been taken.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
26
30
|
link.download = file.name;
|
|
27
31
|
link.target = '_blank';
|
|
28
32
|
const url = URL.createObjectURL(file);
|
|
@@ -56,9 +56,11 @@ export class SnapshotContext extends Context {
|
|
|
56
56
|
* Converts the canvas image to a file.
|
|
57
57
|
*/
|
|
58
58
|
this.updateFile = async () => {
|
|
59
|
+
if (!this.canvasImage.value)
|
|
60
|
+
return;
|
|
59
61
|
const response = await fetch(this.canvasImage.value);
|
|
60
62
|
const blob = await response.blob();
|
|
61
|
-
const format =
|
|
63
|
+
const format = blob.type === 'image/png' ? 'png' : 'jpeg';
|
|
62
64
|
const fileName = `${this.fileName.value}.${format}`;
|
|
63
65
|
const file = new File([blob], fileName, { type: blob.type });
|
|
64
66
|
this.canShare.value = navigator?.canShare?.({
|