From f88a29c5f280010e58a8f523a86d9f83d12457cd Mon Sep 17 00:00:00 2001
From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr>
Date: Mon, 5 Feb 2024 15:52:25 +0100
Subject: [PATCH] WIP saving from svg

---
 src/AnnotationCreation.js      |  7 -------
 src/AnnotationCreationUtils.js | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js
index 2758ace..0b97a01 100644
--- a/src/AnnotationCreation.js
+++ b/src/AnnotationCreation.js
@@ -16,7 +16,6 @@ import LocalOfferIcon from '@mui/icons-material/LocalOffer';
 import HubIcon from '@mui/icons-material/Hub';
 import { TabContext, TabList, TabPanel } from '@mui/lab';
 import AnnotationDrawing from './annotationForm/AnnotationDrawing';
-import WebAnnotation from './WebAnnotation';
 import { secondsToHMS } from './utils';
 import AnnotationFormContent from './annotationForm/AnnotationFormContent';
 import AnnotationFormTime from './annotationForm/AnnotationFormTime';
@@ -327,11 +326,6 @@ function AnnotationCreation(props) {
       config,
     } = props;
 
-    // const dumbIimage = {
-    //   id: null,
-    //   svg,
-    //    };
-    // state.image = dumbIimage;
 
     const drawingStateSerialized = JSON.stringify(drawingState);
 
@@ -349,7 +343,6 @@ function AnnotationCreation(props) {
     const drawingImageExport = svg;
     const t = (tstart && tend) ? `${tstart},${tend}` : null;
     const body = { value: (!textBody.length && t) ? `${secondsToHMS(tstart)} -> ${secondsToHMS(tend)}` : textBody };
-
     saveAnnotation(canvases, config, receiveAnnotation, annotation, body, t, xywh, image, drawingStateSerialized, drawingImageExport, tags);
 
     props.closeCompanionWindow('annotationCreation', {
diff --git a/src/AnnotationCreationUtils.js b/src/AnnotationCreationUtils.js
index be5aa4c..669cb51 100644
--- a/src/AnnotationCreationUtils.js
+++ b/src/AnnotationCreationUtils.js
@@ -126,3 +126,22 @@ const sendFile = async (fileContent) => {
     console.error('Error uploading file:', error);
   }
 };
+
+
+// export function dataURLtoBlob(dataurl) {
+//   // Split the Data URL to get the metadata and the actual data
+//   console.log('Data URL:', dataurl);
+//   var arr = dataurl.split(','),
+//     mime = arr[0].match(/:(.*?);/)[1], // Extract MIME type
+//     bstr = atob(arr[1]), // Decode base64
+//     n = bstr.length,
+//     u8arr = new Uint8Array(n); // Create a new ArrayBuffer
+//
+//   // Convert the binary string to an ArrayBuffer
+//   while(n--){
+//     u8arr[n] = bstr.charCodeAt(n);
+//   }
+//
+//   // Return a Blob object
+//   return new Blob([u8arr], {type:mime});
+}
-- 
GitLab