Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternative selectors #21

Closed
3 tasks
robcast opened this issue Jul 24, 2020 · 5 comments · Fixed by #26
Closed
3 tasks

Support alternative selectors #21

robcast opened this issue Jul 24, 2020 · 5 comments · Fixed by #26

Comments

@robcast
Copy link
Contributor

robcast commented Jul 24, 2020

Web Annotation supports multiple alternative selectors on a target, e.g. a SVG annotation and a #xywh fragment bounding box:

"Multiple Selectors SHOULD select the same content, however some Selectors will not have the same precision as others. Consuming user agents MUST pick one of the described segments, if they are different." (https://www.w3.org/TR/annotation-model/#selectors)

Mirador 2 annotations already support this using an oa:Choice selector:

  "selector": {
    "@type": "oa:Choice",
    "default": {
      "@type": "oa:FragmentSelector",
      "value": "xywh=585,1561,930,1131"
    },
    "item": {
      "@type": "oa:SvgSelector",
      "value": "<svg xmlns=http://www.w3.org/2000/svg><path xmlns=\"http://www.w3.org/2000/svg\" d=\"M585.10619,1560.88496h465.04425v0h465.04425v565.48673v565.48673h-465.04425h-465.04425v-565.48673z\" data-paper-data=\"{&quot;strokeWidth&quot;:1,&quot;rotation&quot;:0,&quot;deleteIcon&quot;:null,&quot;rotationIcon&quot;:null,&quot;group&quot;:null,&quot;editable&quot;:true,&quot;annotation&quot;:null}\" id=\"rectangle_0bd196c7-8796-4770-b793-58e2dfcf4d73\" fill-opacity=\"0\" fill=\"#00bfff\" 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>"
    }
  }

In WebAnno this could become:

  "selector": [
    {
      "@type": "FragmentSelector",
      "value": "xywh=585,1561,930,1131"
    },
    {
      "@type": "SvgSelector",
      "value": "<svg xmlns=http://www.w3.org/2000/svg><path xmlns=\"http://www.w3.org/2000/svg\" d=\"M585.10619,1560.88496h465.04425v0h465.04425v565.48673v565.48673h-465.04425h-465.04425v-565.48673z\" data-paper-data=\"{&quot;strokeWidth&quot;:1,&quot;rotation&quot;:0,&quot;deleteIcon&quot;:null,&quot;rotationIcon&quot;:null,&quot;group&quot;:null,&quot;editable&quot;:true,&quot;annotation&quot;:null}\" id=\"rectangle_0bd196c7-8796-4770-b793-58e2dfcf4d73\" fill-opacity=\"0\" fill=\"#00bfff\" 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>"
    }
  ]

The annotation plugin needs to

  • accept a list of targets for existing annotations
  • select a preferred selector from the list for display e.g. SvgSelector
  • create alternate selectors for new annotations e.g. create a bounding-box FragmentSelector for any SvgSelector
@robcast robcast changed the title Support alternative targets Support alternative selectors Jul 24, 2020
@robcast
Copy link
Contributor Author

robcast commented Jul 24, 2020

I have an implementation of WebAnnotation.js that creates JSON with an array of selectors:

https://github.com/robcast/mirador-annotations/blob/alternate-target-selector/src/WebAnnotation.js

In the last commit I decided that it is better to always create a selector, even when we only have a fragment. I can back that out if you think we should keep generating just a target with appended fragment.

@robcast
Copy link
Contributor Author

robcast commented Jul 24, 2020

@robcast
Copy link
Contributor Author

robcast commented Jul 24, 2020

I even have a test version that translates OpenAnnotations into WebAnnotations with multiple selectors:

https://github.com/robcast/mirador-annotations/blob/7218619b91d4bd1998808cd9bc9eae94af107407/src/SimpleAnnotationServerV2Adapter.js

but it crashes in Mirador's AnnotationItem.js:171 because that assumes selector can't be an array ;-(

@mejackreed
Copy link
Contributor

@robcast yep working on an upstream fix right now

@mejackreed
Copy link
Contributor

See ProjectMirador/mirador#3232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants