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

Add tag creation for an annotation #9

Open mejackreed opened 4 years ago

mejackreed commented 4 years ago

Design pending for tag creation and tag display in annotation list

cc @ggeisler

ggeisler commented 4 years ago

Proposed design:

Uses the MUI Autocomplete component. There are many options for this component but none of the examples seem exactly what we want, so I'll describe the functionality we want and assume it can be done by combining various options of the component.

Add Tags section

Screen Shot 2020-05-21 at 2 48 54 PM

Tags options menu

Screen Shot 2020-05-21 at 2 59 58 PM

Allow new tag creation

Screen Shot 2020-05-21 at 3 17 56 PM

The resulting tag chip should be deletable.

Allow multiple tags

Obviously we need to allow multiple tags, so if the user starts to type again, they can enter another new tag or select one from the menu:

Screen Shot 2020-05-21 at 3 20 27 PM

Highlights

I wouldn't consider this a must-have if there is any technical drawback to using it, but the Highlights utility seems nice to help the user see where their input text matches the options.

robcast commented 4 years ago

The annotation data model would also need to support multiple bodies, including new ones with purpose: tagging.

mejackreed commented 4 years ago

Mirador already supports this upstream like so: https://github.com/ProjectMirador/mirador/blob/master/__tests__/fixtures/version-3/001.json#L277-L337

WebAnnotation.js needs the update I think?

robcast commented 4 years ago

The examples in fixtures look good.

WebAnnotation.js needs:

robcast commented 4 years ago

How does upstream Mirador store tags in annotation bodies? Maybe emulate that?

robcast commented 4 years ago

I have implemented loading multiple bodies from SAS:

https://github.com/robcast/mirador-annotations/blob/33f2dbd4c587febd2524b76c8341560545931930/src/SimpleAnnotationServerV2Adapter.js

but AnnotationCreation.js expected only a single text body so I changed it to filter out the text body:

https://github.com/robcast/mirador-annotations/commit/813e8422d3526d4d794eea6cf779fd55e8dcfbd8

(we could get by with only selecting the first body if we can make sure that the first body is the text body)

Existing tags display ok, of course they are not editable and disappear when saving.

When tags loaded from SAS are displayed I get a warning in the console:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `CanvasAnnotations`. See https://fb.me/react-warning-keys for more information.
    in WithStyles(ForwardRef(Chip)) (created by CanvasAnnotations)
    in CanvasAnnotations (at canvasAnnotationsPlugin.js:32)
    in CanvasAnnotationsWrapper (created by ConnectFunction)
...
robcast commented 4 years ago

Now the tags are correctly loaded and saved and kept (as array "tags") in the annotation object in the editor:

https://github.com/robcast/mirador-annotations/commit/cf732bceae89a393d5d58a44a6dd78cff14f8679

Now you can edit the text body content in M3 without losing the tags. We just need somebody to create the editor UI to display and change tags :-)