react-iiif-vault 0.9.16 → 0.9.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,7 +132,8 @@ const defaultResourceContext = {
132
132
  manifest: void 0,
133
133
  range: void 0,
134
134
  canvas: void 0,
135
- annotation: void 0
135
+ annotation: void 0,
136
+ annotationPage: void 0
136
137
  };
137
138
  const ResourceReactContext = React__default.createContext(defaultResourceContext);
138
139
  const useResourceContext = () => {
@@ -968,8 +969,11 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
968
969
  let choice = null;
969
970
  const items = [];
970
971
  for (const annotation of paintingAnnotations) {
971
- const bodies = vault.get(annotation.body);
972
+ const bodies = vault.get(annotation.body, { skipSelfReturn: false });
972
973
  for (const unknownBody of bodies) {
974
+ if (!unknownBody) {
975
+ continue;
976
+ }
973
977
  const [body, { selector }] = parseSpecificResource(unknownBody);
974
978
  const type = (body.type || "unknown").toLowerCase();
975
979
  if (type === "choice") {
@@ -1225,11 +1229,15 @@ function useLoadImageService() {
1225
1229
  return [loadImageService, imageServiceStatus];
1226
1230
  }
1227
1231
  function usePaintingAnnotations(options = {}) {
1232
+ const annotation = useAnnotation();
1228
1233
  const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
1229
1234
  return useVaultSelector((state, vault) => {
1230
1235
  if (!canvas) {
1231
1236
  return [];
1232
1237
  }
1238
+ if (annotation && options.enableSingleAnnotation) {
1239
+ return [annotation];
1240
+ }
1233
1241
  const annotationPages = vault.get(canvas.items);
1234
1242
  const flatAnnotations = [];
1235
1243
  for (const page of annotationPages) {
@@ -1240,7 +1248,7 @@ function usePaintingAnnotations(options = {}) {
1240
1248
  }
1241
1249
  function usePaintables(options, deps = []) {
1242
1250
  const vault = useVault();
1243
- const paintingAnnotations = usePaintingAnnotations();
1251
+ const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options == null ? void 0 : options.enableSingleAnnotation });
1244
1252
  const [enabledChoices, setEnabledChoices] = useState((options == null ? void 0 : options.defaultChoices) || []);
1245
1253
  const paintables = useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
1246
1254
  const makeChoice = useCallback((id, { deselectOthers = true, deselect = false } = {}) => {