-
Notifications
You must be signed in to change notification settings - Fork 6
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
Vault helper for Choice #159
Comments
This will require a pre-requisite vault helper for painting annotations (as they are tied together). That API currently has the following surface: getPaintingAnnotations(vault, canvas): AnnotationNormalized[];
getPaintables(vault, paintingAnnotations, enabledChoices): { types, items, choice } The concept is that you can get a flat list of painting annotations from If you call With these lower level tools, helpers could further add: function containsChoice(vault, canvas) {
const { choice } = getPaintables(vault, getPaintingAnnotations(vault, canvas));
return choice !== null;
}
function extractChoices(vault, canvas) {
const { choice } = getPaintables(vault, getPaintingAnnotations(vault, canvas));
return choice;
} Although that might feel a bit redundant, and we could simplify to just extract choices and update the example: const choiceSets = vault.extractChoiceSets(canvas);
if (choiceSets) {
// Render UI for choices.
// When I'm ready, I can insert a web component onto the page:
// <canvas-panel canvas-id=" ... " choice-id=" ... " />
} else {
// Render normal component
// <canvas-panel canvas-id=" ... " ... />
} |
Docs will be updated, implementation here: IIIF-Commons/vault-helpers#11 const helper = createPaintingAnnotationsHelper(vault);
helper.getAllPaintingAnnotations(canvas); // returns flattened list of annotations
helper.getPaintables(canvas); // returns list of types, choices and items
helper.extractChoices(canvas); // returns just choices |
This has been expanded in #246 so that you can listen for choice events on multiple canvases in a sequence and make choices on both images. The current implementation is documented though. |
Broken out of #156, extending #106
Current proposal is https://iiif-canvas-panel.netlify.app/docs/examples/handling-choice#additional-choice-helper-api
but it doesn't have to look like that.
The text was updated successfully, but these errors were encountered: