ProjectMirador / mirador-annotations

a Mirador 3 plugin that adds annotation creation tools to the user interface
https://mirador-annotations.netlify.app/
38 stars 37 forks source link

AnnototAdapter response format of "annotationPageId()" request #32

Closed daynewss closed 3 years ago

daynewss commented 3 years ago

Is there any info how response should look like to Mirador viewer would show annotations? I am returning such JSON:

{"annotation":{"canvas":"canvas-1","data":"{\"body\":{\"type\":\"TextualBody\",\"value\":\"<p>TEST<\/p>\"},\"id\":\"c744ec4a-67f1-48a4-871e-c896d4ccb17c\",\"motivation\":\"commenting\",\"target\":{\"source\":\"canvas-1\",\"selector\":[{\"type\":\"FragmentSelector\",\"value\":\"xywh=765,808,659,708\"},{\"type\":\"SvgSelector\",\"value\":\"<svg xmlns='http:\/\/www.w3.org\/2000\/svg'><path xmlns=\\\"http:\/\/www.w3.org\/2000\/svg\\\" d=\\\"M765.17188,1517.375v-708.9375h659.1875v708.9375z\\\" data-paper-data=\\\"{&quot;state&quot;:null}\\\" fill=\\\"none\\\" fill-rule=\\\"nonzero\\\" stroke=\\\"#00bfff\\\" stroke-width=\\\"1\\\" stroke-linecap=\\\"butt\\\" stroke-linejoin=\\\"miter\\\" stroke-miterlimit=\\\"10\\\" stroke-dasharray=\\\"\\\" stroke-dashoffset=\\\"0\\\" font-family=\\\"none\\\" font-weight=\\\"none\\\" font-size=\\\"none\\\" text-anchor=\\\"none\\\" style=\\\"mix-blend-mode: normal\\\"\/><\/svg>\"}]},\"type\":\"Annotation\"}","uuid":"c744ec4a-67f1-48a4-871e-c896d4ccb17c"}}

but no annotations are shown.

mejackreed commented 3 years ago

It looks like the selector may not be matching onto the canvas id which is needed to relate the annotation to the given canvas. Can you look into that?

daynewss commented 3 years ago

Canvas id is correct. It's hardcoded. OCR text search works perfectly with these ids (canvas-1, canvas-2 and so on, counter increases with every page). Maybe there are examples or demos, where AnnototAdapter is in use? So, I could get correct response exampe. annotations

mejackreed commented 3 years ago

Got it thanks, I think I understand how your canvasIds work now.

annotationPageId should return the id of the AnnotationPage resource in which your Annotation resides. So perhaps based off of your example, the XHR request should return the AnnotationPage wrapping the annotations? (Or at least you could dynamically create that).

Here is how it works in Annotot:

Screen Shot 2020-11-10 at 6 17 55 AM

GET | http://127.0.0.1:3000/annotations/pages?uri=https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896

Response:

{
  "@context": "http://iiif.io/api/presentation/3/context.json",
  "id": "http://127.0.0.1:3000/annotations/pages?uri=https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896",
  "type": "AnnotationPage",
  "items": [
    {
      "body": {
        "type": "TextualBody",
        "value": "<p>test123</p>"
      },
      "id": "13005b86-6b8c-41dc-b685-42cd4ed578fc",
      "motivation": "commenting",
      "target": {
        "source": "https://iiif.harvardartmuseums.org/manifests/object/299843/canvas/canvas-47174896",
        "selector": [
          {
            "type": "FragmentSelector",
            "value": "xywh=726,881,337,134"
          },
          {
            "type": "SvgSelector",
            "value": "<svg xmlns='http://www.w3.org/2000/svg'><path xmlns=\"http://www.w3.org/2000/svg\" d=\"M726.16539,1016.40338v-134.42467h337.20087v134.42467z\" data-paper-data=\"{&quot;state&quot;:null}\" fill=\"none\" fill-rule=\"nonzero\" stroke=\"#00bfff\" stroke-width=\"1\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\" stroke-dasharray=\"\" stroke-dashoffset=\"0\" font-family=\"none\" font-weight=\"none\" font-size=\"none\" text-anchor=\"none\" style=\"mix-blend-mode: normal\"/></svg>"
          }
        ]
      },
      "type": "Annotation"
    }
  ]
}
daynewss commented 3 years ago

Thank you very much. The response JSON is exactly what I needed.