react-iiif-vault 0.9.18 → 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.
@@ -969,8 +969,11 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
969
969
  let choice = null;
970
970
  const items = [];
971
971
  for (const annotation of paintingAnnotations) {
972
- const bodies = vault.get(annotation.body);
972
+ const bodies = vault.get(annotation.body, { skipSelfReturn: false });
973
973
  for (const unknownBody of bodies) {
974
+ if (!unknownBody) {
975
+ continue;
976
+ }
974
977
  const [body, { selector }] = parseSpecificResource(unknownBody);
975
978
  const type = (body.type || "unknown").toLowerCase();
976
979
  if (type === "choice") {
@@ -1226,11 +1229,15 @@ function useLoadImageService() {
1226
1229
  return [loadImageService, imageServiceStatus];
1227
1230
  }
1228
1231
  function usePaintingAnnotations(options = {}) {
1232
+ const annotation = useAnnotation();
1229
1233
  const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
1230
1234
  return useVaultSelector((state, vault) => {
1231
1235
  if (!canvas) {
1232
1236
  return [];
1233
1237
  }
1238
+ if (annotation && options.enableSingleAnnotation) {
1239
+ return [annotation];
1240
+ }
1234
1241
  const annotationPages = vault.get(canvas.items);
1235
1242
  const flatAnnotations = [];
1236
1243
  for (const page of annotationPages) {
@@ -1241,7 +1248,7 @@ function usePaintingAnnotations(options = {}) {
1241
1248
  }
1242
1249
  function usePaintables(options, deps = []) {
1243
1250
  const vault = useVault();
1244
- const paintingAnnotations = usePaintingAnnotations();
1251
+ const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options == null ? void 0 : options.enableSingleAnnotation });
1245
1252
  const [enabledChoices, setEnabledChoices] = useState((options == null ? void 0 : options.defaultChoices) || []);
1246
1253
  const paintables = useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
1247
1254
  const makeChoice = useCallback((id, { deselectOthers = true, deselect = false } = {}) => {