ProjectMirador / mirador-annotations

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

annotation target should use "source" instead of "id" for the canvas uri when it has a "selector" #25

Closed robcast closed 4 years ago

robcast commented 4 years ago

The current annotation model uses the target's id property for the canvas uri when the target has a selector.

According to the WebAnno spec the target is a SpecificResource when it has a selector and the resource uri should go into the source property (the id is of the SpecificResource object itself).

This concerns WebAnnotation.js and possible some adapters.

robcast commented 4 years ago

The last change in Mirador to accept extended target sources

https://github.com/ProjectMirador/mirador/blob/982cd2c0b4e44a67201770e93e695af9bf6812c2/src/lib/AnnotationItem.js#L32

should also be amended to accept target.source without target.source.id.

Should we keep target.id for backward-compatibility?

mejackreed commented 4 years ago

I'm not following exactly here. What is the change you would propose there? I thought we were targeting something like this: https://github.com/ProjectMirador/mirador-annotations/issues/20#issuecomment-665531532

robcast commented 4 years ago

target.source.id is fine in case source is an object with additional information like partOf:

  "target": {
    "type": "SpecificResource",
    "source": {
          "id": "http://example.org/manifest/1/canvas/1",
          "type": "Canvas",
          "label": { "en": [ "Page 1" ] } },
          "partOf": [
             {
                   "id": ""http://example.org/manifest/1.json",
                   "type": "Manifest",
                   "label": { "en": [ "Manifest title" ] } }
             }
          ]
    },
    "selector": [{
       "type": "FragmentSelector",
       "conformsTo": "http://www.w3.org/TR/media-frags/",
       "value": "xywh=10,10,100,100"
     },
     {
        "type": "SvgSelector",
        "value": "<svg:svg> ... </svg:svg>"
     }]

If we don't need that information target.source should be the URI that is currently in target.id:

  "target": {
    "type": "SpecificResource",
    "source": "http://example.org/manifest/1/canvas/1",
    "selector": [{
       "type": "FragmentSelector",
       "conformsTo": "http://www.w3.org/TR/media-frags/",
       "value": "xywh=10,10,100,100"
     },
     {
        "type": "SvgSelector",
        "value": "<svg:svg> ... </svg:svg>"
     }]
    }
robcast commented 4 years ago

I guess https://github.com/ProjectMirador/mirador/blob/982cd2c0b4e44a67201770e93e695af9bf6812c2/src/lib/AnnotationItem.js#L32

should become

return (target.source && target.source.id) || target.source || target.id;