diff --git a/build/root.mjs b/build/root.mjs index 0f85d2d6..6b7c07ac 100644 --- a/build/root.mjs +++ b/build/root.mjs @@ -5,7 +5,6 @@ import Slider from "./slider"; import Viewer from "./viewer"; import { parseAnnotationTarget, - parseAnnotationsFromAnnotationResources, } from "./annotation-helpers"; import { createOpenSeadragonRect } from "./openseadragon-helpers"; @@ -16,7 +15,6 @@ export { Slider, Viewer, parseAnnotationTarget, - parseAnnotationsFromAnnotationResources, createOpenSeadragonRect }; diff --git a/build/root.umd.js b/build/root.umd.js index f6605100..3e2ea451 100644 --- a/build/root.umd.js +++ b/build/root.umd.js @@ -7,7 +7,6 @@ const Slider = require("./slider"); const Viewer = require("./viewer"); const { parseAnnotationTarget, - parseAnnotationsFromAnnotationResources } = require("./annotation_helpers"); const { createOpenSeadragonRect } = require("./openseadragon-helpers"); @@ -19,6 +18,5 @@ module.exports = { Slider, Viewer, parseAnnotationTarget, - parseAnnotationsFromAnnotationResources, createOpenSeadragonRect }; diff --git a/src/components/Viewer/Viewer/Content.tsx b/src/components/Viewer/Viewer/Content.tsx index 92eb4af5..5d68744a 100644 --- a/src/components/Viewer/Viewer/Content.tsx +++ b/src/components/Viewer/Viewer/Content.tsx @@ -18,8 +18,6 @@ import Media from "src/components/Viewer/Media/Media"; import Painting from "../Painting/Painting"; import React from "react"; import { useViewerState } from "src/context/viewer-context"; -import ErrorFallback from "src/components/UI/ErrorFallback/ErrorFallback"; -import { ErrorBoundary } from "react-error-boundary"; export interface ViewerContentProps { activeCanvas: string; @@ -87,15 +85,13 @@ const ViewerContent: React.FC = ({ {(isAside || isForcedAside) && ( )} diff --git a/src/context/viewer-context.tsx b/src/context/viewer-context.tsx index 54430e4d..978c17d9 100644 --- a/src/context/viewer-context.tsx +++ b/src/context/viewer-context.tsx @@ -30,7 +30,6 @@ export type ViewerConfigOptions = { overlays?: OverlayOptions; }; ignoreCaptionLabels?: string[]; - ignoreAnnotationOverlaysLabels?: string[]; informationPanel?: { open?: boolean; renderAbout?: boolean; @@ -101,7 +100,6 @@ const defaultConfigOptions = { }, }, ignoreCaptionLabels: [], - ignoreAnnotationOverlaysLabels: [], informationPanel: { vtt: { autoScroll: { diff --git a/src/index.tsx b/src/index.tsx index e9ab5b6a..7b2a655f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,7 +5,6 @@ import Slider from "src/components/Slider"; import Viewer from "src/components/Viewer"; import { parseAnnotationTarget, - parseAnnotationsFromAnnotationResources, type AnnotationTargetExtended, } from "src/lib/annotation-helpers"; import { createOpenSeadragonRect } from "src/lib/openseadragon-helpers"; @@ -18,7 +17,6 @@ export { Slider, Viewer, parseAnnotationTarget, - parseAnnotationsFromAnnotationResources, type AnnotationTargetExtended, createOpenSeadragonRect, type Plugin, diff --git a/src/lib/annotation-helpers.test.ts b/src/lib/annotation-helpers.test.ts index 1cb50fce..8f975cea 100644 --- a/src/lib/annotation-helpers.test.ts +++ b/src/lib/annotation-helpers.test.ts @@ -1,15 +1,7 @@ import { parseAnnotationTarget, AnnotationTargetExtended, - parseAnnotationsFromAnnotationResources, } from "./annotation-helpers"; -import { Vault } from "@iiif/vault"; -import { - simpleTagging, - multiplePages, -} from "src/fixtures/use-iiif/get-annotation-resources"; - -import { getAnnotationResources } from "src/hooks/use-iiif/getAnnotationResources"; describe("parseAnnotationTarget", () => { it("handles target strings with xywh", () => { @@ -118,143 +110,3 @@ describe("parseAnnotationTarget", () => { expect(result).toEqual(expected); }); }); - -describe("parseAnnotationsFromAnnotationResources", () => { - it("returns annotations from annotation resource", async () => { - const config = {}; - const vault = new Vault(); - await vault.loadManifest("", structuredClone(simpleTagging)); - const annotationResources = await getAnnotationResources( - vault, - simpleTagging.items[0].id, - ); - - const res = parseAnnotationsFromAnnotationResources( - annotationResources, - vault, - config, - ); - - const expected = [ - { - body: [ - { - id: "vault://605b9d93", - type: "ContentResource", - }, - ], - id: "https://iiif.io/api/cookbook/recipe/0021-tagging/annotation/p0002-tag", - motivation: ["tagging"], - target: - "https://iiif.io/api/cookbook/recipe/0021-tagging/canvas/p1#xywh=265,661,1260,1239", - type: "Annotation", - }, - ]; - expect(res).toStrictEqual(expected); - }); - - it("returns annotations if annotation resource has multiple annotation pages", async () => { - const config = {}; - const vault = new Vault(); - await vault.loadManifest("", structuredClone(multiplePages)); - const annotationResources = await getAnnotationResources( - vault, - multiplePages.items[0].id, - ); - - const res = parseAnnotationsFromAnnotationResources( - annotationResources, - vault, - config, - ); - - const expected = [ - { - body: [ - { - id: "vault://772e4338", - type: "ContentResource", - }, - ], - id: "http://localhost:3000/manifest/newspaper/newspaper_issue_1-anno_p1.json-1", - motivation: ["highlighting"], - target: - "http://localhost:3000/manifest/newspaper/canvas/i1p1#xywh=839,3259,118,27", - type: "Annotation", - }, - { - body: [ - { - id: "vault://772e4338", - type: "ContentResource", - }, - ], - id: "http://localhost:3000/manifest/newspaper/newspaper_issue_1-anno_p2.json-2", - motivation: ["commenting"], - target: - "http://localhost:3000/manifest/newspaper/canvas/i1p2#xywh=161,459,1063,329", - type: "Annotation", - }, - ]; - expect(res).toStrictEqual(expected); - }); - - it("ignores annotations in ignoreAnnotationOverlaysLabels", async () => { - const config = { ignoreAnnotationOverlaysLabels: ["Clippings"] }; - const vault = new Vault(); - await vault.loadManifest("", structuredClone(multiplePages)); - const annotationResources = await getAnnotationResources( - vault, - multiplePages.items[0].id, - ); - - const res = parseAnnotationsFromAnnotationResources( - annotationResources, - vault, - config, - ); - - const expected = [ - { - body: [ - { - id: "vault://772e4338", - type: "ContentResource", - }, - ], - id: "http://localhost:3000/manifest/newspaper/newspaper_issue_1-anno_p1.json-1", - motivation: ["highlighting"], - target: - "http://localhost:3000/manifest/newspaper/canvas/i1p1#xywh=839,3259,118,27", - type: "Annotation", - }, - ]; - expect(res).toStrictEqual(expected); - }); - - it("returns empty array if annotation resource is empty array", () => { - const config = {}; - const annotationResources = []; - const vault = new Vault(); - - const res = parseAnnotationsFromAnnotationResources( - annotationResources, - vault, - config, - ); - - expect(res).toStrictEqual([]); - }); -}); - -/* -{ -selector :{ -conformsTo:"http://www.w3.org/TR/media-frags/", -type:"FragmentSelector", -value:"xywh=86.18675994873047,1189.02587890625,910.7970657348633,653.7779541015625" -} -source:"https://iiif.io/api/image/3.0/example/reference/4ce82cef49fb16798f4c2440307c3d6f-newspaper-p1" -type:"SpecificResource" -} -*/ diff --git a/src/lib/annotation-helpers.ts b/src/lib/annotation-helpers.ts index 37307cc6..2b16eae1 100644 --- a/src/lib/annotation-helpers.ts +++ b/src/lib/annotation-helpers.ts @@ -1,8 +1,5 @@ -import { AnnotationTarget, AnnotationNormalized } from "@iiif/presentation-3"; +import { AnnotationTarget } from "@iiif/presentation-3"; import { ParsedAnnotationTarget } from "src/types/annotations"; -import { getLabel } from "src/hooks/use-iiif"; -import { AnnotationResources } from "src/types/annotations"; -import { type ViewerConfigOptions } from "src/context/viewer-context"; export type AnnotationTargetExtended = AnnotationTarget & { selector?: any; @@ -82,33 +79,4 @@ const parseAnnotationTarget = (target: AnnotationTargetExtended | string) => { return parsedTarget; }; -const parseAnnotationsFromAnnotationResources = ( - annotationResources: AnnotationResources, - vault: any, - configOptions: ViewerConfigOptions, -) => { - const annotations: Array = []; - annotationResources - .filter((annotationResource) => { - if (annotationResource.label) { - const label = getLabel(annotationResource.label); - if (Array.isArray(label)) { - return !label.some((value) => - configOptions.ignoreAnnotationOverlaysLabels?.includes(value), - ); - } - } - - return true; - }) - .forEach((annotationResource) => { - annotationResource?.items?.forEach((item) => { - const annotation = vault.get(item.id); - annotations.push(annotation as unknown as AnnotationNormalized); - }); - }); - - return annotations; -}; - -export { parseAnnotationTarget, parseAnnotationsFromAnnotationResources }; +export { parseAnnotationTarget };