mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix going to annotation
This commit is contained in:
@@ -220,11 +220,14 @@ export class View extends HTMLElement {
|
|||||||
}
|
}
|
||||||
async showAnnotation(annotation) {
|
async showAnnotation(annotation) {
|
||||||
const { value } = annotation
|
const { value } = annotation
|
||||||
const { index, anchor } = await this.goTo(value)
|
const resolved = await this.goTo(value)
|
||||||
|
if (resolved) {
|
||||||
|
const { index, anchor } = resolved
|
||||||
const { doc } = this.#getOverlayer(index)
|
const { doc } = this.#getOverlayer(index)
|
||||||
const range = anchor(doc)
|
const range = anchor(doc)
|
||||||
this.#emit('show-annotation', { value, range })
|
this.#emit('show-annotation', { value, range })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
getCFI(index, range) {
|
getCFI(index, range) {
|
||||||
const baseCFI = this.book.sections[index].cfi ?? CFI.fake.fromIndex(index)
|
const baseCFI = this.book.sections[index].cfi ?? CFI.fake.fromIndex(index)
|
||||||
if (!range) return baseCFI
|
if (!range) return baseCFI
|
||||||
@@ -259,6 +262,7 @@ export class View extends HTMLElement {
|
|||||||
try {
|
try {
|
||||||
await this.renderer.goTo(resolved)
|
await this.renderer.goTo(resolved)
|
||||||
this.history.pushState(target)
|
this.history.pushState(target)
|
||||||
|
return resolved
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
console.error(`Could not go to ${target}`)
|
console.error(`Could not go to ${target}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user