diff --git a/src/components/camera/views/editor/CameraWidgetEditorView.tsx b/src/components/camera/views/editor/CameraWidgetEditorView.tsx index 8e7ac59..b05da0e 100644 --- a/src/components/camera/views/editor/CameraWidgetEditorView.tsx +++ b/src/components/camera/views/editor/CameraWidgetEditorView.tsx @@ -112,18 +112,27 @@ export const CameraWidgetEditorView: FC = props => return; } case 'clear_effects': - setSelectedEffectName(null); - setSelectedEffects([]); + onCancel(); return; case 'download': { - if(!currentPictureUrl || !currentPictureUrl.startsWith('data:image/')) return; + if(!currentPictureUrl) return; + + const parts = currentPictureUrl.split(','); + const mime = parts[0].match(/:(.*?);/)?.[1] || 'image/png'; + const binary = atob(parts[1]); + const bytes = new Uint8Array(binary.length); + for(let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i); + const blob = new Blob([ bytes ], { type: mime }); + const blobUrl = URL.createObjectURL(blob); + + const w = window.open('', '_blank'); + if(w) + { + w.document.title = 'camera_photo.png'; + w.document.body.style.margin = '0'; + w.document.body.innerHTML = ``; + } - const link = document.createElement('a'); - link.href = currentPictureUrl; - link.download = 'camera_photo.png'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); return; } case 'zoom':