From 2c8661d10f241f52afad88b21503863daf39a7f6 Mon Sep 17 00:00:00 2001
From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr>
Date: Mon, 5 Feb 2024 07:59:07 +0100
Subject: [PATCH] WIP Saving fake data

---
 demo/src/index.js         |  1 +
 src/AnnotationCreation.js |  8 +++++++-
 src/WebAnnotation.js      | 11 +++++------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/demo/src/index.js b/demo/src/index.js
index 8799874..2284b30 100644
--- a/demo/src/index.js
+++ b/demo/src/index.js
@@ -11,6 +11,7 @@ const config = {
     exportLocalStorageAnnotations: false, // display annotation JSON export button
   },
   catalog: [
+    { manifestId: 'https://files.tetras-libre.fr/dev/Hakanai/manifest/manifest.json' },
     { manifestId: 'https://dzkimgs.l.u-tokyo.ac.jp/videos/iiif_in_japan_2017/manifest.json' },
     { manifestId: 'https://iiif.io/api/cookbook/recipe/0219-using-caption-file/manifest.json' },
     { manifestId: 'https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/manifest.json' },
diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js
index d228815..ba4ee96 100644
--- a/src/AnnotationCreation.js
+++ b/src/AnnotationCreation.js
@@ -53,6 +53,7 @@ function AnnotationCreation(props) {
     let tend;
     const annoState = {};
     if (props.annotation) {
+      console.log('props.annotation', props.annotation);
       // annotation body
       if (Array.isArray(props.annotation.body)) {
         annoState.tags = [];
@@ -100,6 +101,12 @@ function AnnotationCreation(props) {
        setDrawingState(JSON.parse(props.annotation.drawingState));
       }
     }
+    // TODO add a case where no annotation
+
+
+    if(!annoState?.textBody) {
+      annoState.textBody = '';
+    }
 
     // If we don't have tstart setted, we are creating a new annotation.
     // If we don't have tend setted, we set it at the end of the video.
@@ -114,7 +121,6 @@ function AnnotationCreation(props) {
       mediaVideo: props.mediaVideo,
       ...annoState,
       tend,
-      textBody: '',
       textEditorStateBustingKey: 0,
       tstart,
       valueTime: [0, 1],
diff --git a/src/WebAnnotation.js b/src/WebAnnotation.js
index 2267a98..90acaac 100644
--- a/src/WebAnnotation.js
+++ b/src/WebAnnotation.js
@@ -11,7 +11,7 @@ export default class WebAnnotation {
     this.tags = tags;
     this.svg = svg;
     //this.image = image;
-    this.image = null;
+    this.image = image;
     this.manifestId = manifestId;
     this.drawingState = drawingStateSerialized;
 
@@ -52,11 +52,10 @@ export default class WebAnnotation {
       };
       //bodies.push(imgBody);
       const testImageBody = {
-        "id": "http://iiif.tetras-libre.fr/data/Hakanai/media/10_HKN-Garges_A2B4243.JPG",
-        "type": "Image",
-        "format": "image/jpg",
-        "value": "<a href=\"http://iiif.tetras-libre.fr/data/Hakanai/media/10_HKN-Garges_A2B4243.JPG\" target=\"_blank\">Dispositif</a>"
-      };
+            "id": "https://files.tetras-libre.fr/dev/Hakanai/media/10_HKN-Garges_A2B4243.JPG",
+            "type": "Image",
+            "format": "image/jpg"
+          };
       bodies.push(testImageBody);
     }
 
-- 
GitLab