Skip to content

Add support for choice on canvases#82

Draft
jamesmisson wants to merge 5 commits intomainfrom
choice
Draft

Add support for choice on canvases#82
jamesmisson wants to merge 5 commits intomainfrom
choice

Conversation

@jamesmisson
Copy link
Copy Markdown
Collaborator

This PR adds support for choices on canvases, following on from IIIF-Commons/manifesto#173.

The Helper now has:

  • choiceIndex to track choice state
  • hasChoices
  • getActiveChoice
  • getChoices

And tests for the IIIF cookbook manifest.

I'll leave this in draft for now as it should be tested with a manifest with multiple canvases with choice.

@jamesmisson jamesmisson requested a review from demiankatz April 8, 2026 10:08
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Apr 8, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Copy Markdown
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jamesmisson, and sorry it has taken me a couple of days to get back to you. See below for a couple of comments. Regarding the versioning piece, we've been pretty inconsistent about semantic versioning in the past, so a minor misstep here is not a disaster, but we should aim to be more consistent in future!

Comment thread package-lock.json
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/manifesto.js/-/manifesto.js-4.3.0.tgz",
"integrity": "sha512-UhnJ/m4KrbVUrqjlJvURakAR68y3twBXecocRiWU8MIvDJdwA1clYTtHz+in0LeYIgb6yuLZ7vStQ7ixtkkEAw==",
"version": "4.3.3",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new manifesto release should probably have been 4.4.0 rather than 4.3.3 since it added a new feature rather than just fixing a bug. At very least, the package.json here should now be changed to require 4.3.3 at a minimum, because if somebody installs a lower version, the code will now break. As it is, I think it would be possible for a downstream project to include incompatible versions of manifold and manifesto without NPM catching it or complaining.

Comment thread src/Helper.ts

public hasChoices(): boolean {
const canvas = this.getCurrentCanvas();
return canvas.getChoices().length > 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use this.getChoices() here to simplify the code a little?

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 this pull request may close these issues.

2 participants