sprintify-ui 0.1.5 → 0.1.7
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/package.json
CHANGED
|
@@ -52,6 +52,7 @@ const emit = defineEmits(['select']);
|
|
|
52
52
|
|
|
53
53
|
const showCropperModal = ref(false);
|
|
54
54
|
const cropperSource = ref('');
|
|
55
|
+
let filename = '';
|
|
55
56
|
|
|
56
57
|
const cropperInternal = computed<BaseCropperConfig | null>(() => {
|
|
57
58
|
if (!cropperSource.value) {
|
|
@@ -75,6 +76,8 @@ async function launchCropper(file: File) {
|
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
filename = file.name;
|
|
80
|
+
|
|
78
81
|
showCropperModal.value = false;
|
|
79
82
|
cropperSource.value = await blobToBase64(file);
|
|
80
83
|
|
|
@@ -87,7 +90,7 @@ async function launchCropper(file: File) {
|
|
|
87
90
|
|
|
88
91
|
async function onCropped(cropped: HTMLCanvasElement | string | Blob) {
|
|
89
92
|
if (cropped instanceof Blob) {
|
|
90
|
-
|
|
93
|
+
emitUpdate(cropped);
|
|
91
94
|
return;
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -102,15 +105,23 @@ async function onCropped(cropped: HTMLCanvasElement | string | Blob) {
|
|
|
102
105
|
});
|
|
103
106
|
});
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
emitUpdate(blob);
|
|
106
109
|
|
|
107
110
|
return;
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
if (typeof cropped === 'string') {
|
|
111
114
|
const blob = await fetch(cropped).then((r) => r.blob());
|
|
112
|
-
|
|
115
|
+
emitUpdate(blob);
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
115
118
|
}
|
|
119
|
+
|
|
120
|
+
function emitUpdate(blob: Blob) {
|
|
121
|
+
const file = new File([blob], filename, {
|
|
122
|
+
type: blob.type,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
emit('select', file);
|
|
126
|
+
}
|
|
116
127
|
</script>
|