Skip to content

Changes to suit Annotations from parent to iframe#4

Merged
cubap merged 18 commits into
mainfrom
view-full-page-iframe
Oct 1, 2025
Merged

Changes to suit Annotations from parent to iframe#4
cubap merged 18 commits into
mainfrom
view-full-page-iframe

Conversation

@mepripri
Copy link
Copy Markdown
Collaborator

No description provided.

@mepripri mepripri requested review from cubap and thehabes September 26, 2025 23:42
Comment thread iiif-data-service.js Outdated

// Check if this is manifest data that contains canvases
if (this.isManifestData(data)) {
Copy link
Copy Markdown
Member

@thehabes thehabes Sep 29, 2025

Choose a reason for hiding this comment

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

Do we need this.isManifestData? if (manifestUrl) would be cheaper

Comment thread iiif-data-service.js Outdated
// Check if this is manifest data that contains canvases
if (this.isManifestData(data)) {
return await this.extractCanvasFromManifest(data, canvasUrl)
const pageData = await fetch(pageId)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we never want to use the AnnotationPage embedded in the Manifest's Canvas? It could save us a fetch().

Comment thread iiif-data-service.js Outdated

// Check for sequences (IIIF v2) or items with canvases (IIIF v3)
return !!(data.sequences || (data.items && Array.isArray(data.items)))
return !!(data.sequences || (data.items && Array.isArray(data.items) && data.items.some(item => item.type === "Canvas")))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we need this. The check for the type is enough.

Copy link
Copy Markdown
Member

@thehabes thehabes left a comment

Choose a reason for hiding this comment

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

Had a paired review at standup that resulted in some cleanup. Tested manually in the interface and this is working good. The messaging system is nice and plays nice with TPEN Interfaces.

Copy link
Copy Markdown
Member

@cubap cubap left a comment

Choose a reason for hiding this comment

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

This is excellent. I have asked for some logic organization that I think will make this easier to maintain as we start adding parts and extra checks/conversions.

Comment thread iiif-data-service.js Outdated
if (manifestData) {
if (annotationPageData) {
return await this.extractCanvasFromManifest(manifestData, canvasData, annotationPageData)
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this else follows a return so it isn't needed.

Comment thread iiif-data-service.js Outdated
} else {
return await this.extractCanvasFromManifest(manifestData, canvasData, { items: [] })
}
} else if (canvasData) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that makes this just an if

Comment thread iiif-data-service.js Outdated
} else if (canvasData) {
if (annotationPageData) {
return await this.processDirectCanvasData(canvasData, annotationPageData)
} else if (canvasData.items && canvasData.items.length > 0 && canvasData.items[0].target) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and this just an if

Comment thread iiif-data-service.js Outdated
return await this.processDirectCanvasData(canvasData, annotationPageData)
} else if (canvasData.items && canvasData.items.length > 0 && canvasData.items[0].target) {
return await this.processPageData(canvasData)
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this can go

Comment thread iiif-data-service.js Outdated
return await this.processDirectCanvasData(canvasData, { items: [] })
}
} else {
throw new Error("Unsupported IIIF data structure")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this ought to be a guard clause at the top

Comment thread ui-manager.js
Comment thread viewer.js Outdated
this.uiManager.renderAnnotations(annotations, imgWidth, imgHeight)


let idx = null
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this block 54-71 feel like a function that should be extracted or at least separately defined. With some returns, you could clean it up a little as well.

Comment thread viewer.js Outdated
}

if (annotationId !== null) {
document.querySelector(`.overlayBox[data-lineid="${annotationId}"]`).classList.add('clicked')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe this needs a ?. to prevent calling classlist on null if it isn't there. It is not immediately in my mind how this happens.

Comment thread viewer.js Outdated
document.querySelector(`.overlayBox[data-lineid="${annotationId}"]`).classList.add('clicked')
document.querySelector(`.overlayBox[data-lineid="${annotationId}"]`).setAttribute('aria-selected', 'true')
history.replaceState(null, '', `?${manifest ? `manifest=${manifest}&` : ''}canvas=${canvas}${annotationPage ? `&annotationPage=${annotationPage}` : ''}${annotation ? `&annotation=${annotation}` : ''}`)
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with a return we can unbury these elses

Comment thread viewer.js Outdated
this.loadPage(canvas, manifest, annotationPage, annotation)
} else {
this.uiManager.showLoading("Waiting for canvas URL from parent window...")
this.uiManager.showLoading("Waiting for manifest URL or page URL from parent window...")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this feels like a guard clause

@cubap cubap merged commit c7279fe into main Oct 1, 2025
3 checks passed
@cubap cubap deleted the view-full-page-iframe branch October 1, 2025 15:21
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.

3 participants