Skip to content

Commit de81f7e

Browse files
committed
fixes
1 parent da8be53 commit de81f7e

2 files changed

Lines changed: 8 additions & 17 deletions

File tree

components/annotorious-annotator/line-parser.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ class AnnotoriousAnnotator extends HTMLElement {
761761
*/
762762
formatAnnotations(annotations) {
763763
if (!annotations || annotations.length === 0) return annotations
764-
let orig_xywh, converted_xywh = []
765764
return annotations.map(annotation => {
766765
if (!annotation.hasOwnProperty("target") || !annotation.hasOwnProperty("body")) return annotation
767766
if (typeof annotation.target === "string") {
@@ -1037,7 +1036,7 @@ class AnnotoriousAnnotator extends HTMLElement {
10371036
if (typeof pageTarget === "object") {
10381037
// An embedded object, a referenced object, or a {source:"", selector:{}} object
10391038
try {
1040-
JSON.parse(JSON.stringify(target))
1039+
JSON.parse(JSON.stringify(pageTarget))
10411040
} catch (err) {
10421041
throw new Error(`The AnnotationPage target is not processable.`, { "cause": "AnnotationPage.target is not JSON." })
10431042
}

components/create-column/index.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TpenCreateColumn extends HTMLElement {
147147
.disable-other {
148148
pointer-events: none;
149149
user-select: none;
150-
opcacity: 0.5;
150+
opacity: 0.5;
151151
color: gray !important;
152152
}
153153
.disable-button {
@@ -247,7 +247,7 @@ class TpenCreateColumn extends HTMLElement {
247247
this.showLoading()
248248
let { imgUrl, annotations, imgWidth, imgHeight } = await this.fetchPageViewerData(pageID)
249249
await this.renderImage(imgUrl)
250-
const page = await TPEN.activeProject.layers.flatMap(layer => layer.pages || []).find(p => p.id.split('/').pop() === this.annotationPageID)
250+
const page = TPEN.activeProject.layers.flatMap(layer => layer.pages || []).find(p => p.id.split('/').pop() === this.annotationPageID)
251251
this.existingColumns = page?.columns?.map(column => ({ label: column.label, lines: column.lines })) || []
252252
const assignedAnnotationIds = []
253253
await this.columnLabelCheck()
@@ -350,7 +350,10 @@ class TpenCreateColumn extends HTMLElement {
350350
} else {
351351
btn.style.backgroundColor = 'var(--primary-color)'
352352
btn.style.color = 'white'
353-
columnLabelsToMerge.pop(columnLabels.indexOf(label) !== -1 ? columnLabels.indexOf(label) : '')
353+
const index = columnLabelsToMerge.indexOf(columnLabels.indexOf(label))
354+
if (index > -1) {
355+
columnLabelsToMerge.splice(index, 1)
356+
}
354357
}
355358
})
356359
workspaceToolbar.appendChild(btn)
@@ -510,23 +513,14 @@ class TpenCreateColumn extends HTMLElement {
510513
return false
511514
}
512515
}
513-
isValidJSON(input) {
514-
try {
515-
(typeof input === "string") ? JSON.parse(input) : JSON.parse(JSON.stringify(input))
516-
return true
517-
} catch {
518-
return false
519-
}
520-
}
521516

522517
async getSpecificTypeData(type) {
523518
if (!type) throw new Error("No IIIF resource provided")
524519
if (typeof type === "string" && this.isValidUrl(type)) {
525520
const res = await fetch(type, { cache: "no-store" })
526521
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`)
527522
return await res.json()
528-
} else if (typeof type === "object" && this.isValidJSON(type)) return type
529-
else throw new Error("Invalid IIIF input")
523+
}
530524
}
531525

532526
async fetchPageViewerData(pageID = null) {
@@ -724,7 +718,6 @@ class TpenCreateColumn extends HTMLElement {
724718
})
725719
window.location.reload()
726720
} catch (err) {
727-
console.error("Column creation failed:", err)
728721
TPEN.eventDispatcher.dispatch("tpen-toast", {
729722
status: "error", message: 'Failed to create column.'
730723
})
@@ -746,7 +739,6 @@ class TpenCreateColumn extends HTMLElement {
746739
})
747740
window.location.reload()
748741
} catch (err) {
749-
console.error("Failed to clear columns:", err)
750742
TPEN.eventDispatcher.dispatch("tpen-toast", {
751743
status: "error", message: 'Failed to clear columns.'
752744
})

0 commit comments

Comments
 (0)