Allow getting page/TOC item for ranges

This commit is contained in:
John Factotum
2023-09-24 02:37:33 +08:00
parent 495aef0064
commit 0a9c418711
+7 -2
View File
@@ -241,7 +241,7 @@ export class View extends HTMLElement {
doc.addEventListener('click', e => {
const [value, range] = overlayer.hitTest(e)
if (value && !value.startsWith(SEARCH_PREFIX)) {
this.#emit('show-annotation', { value, range })
this.#emit('show-annotation', { value, index, range })
}
}, false)
@@ -258,7 +258,7 @@ export class View extends HTMLElement {
const { index, anchor } = resolved
const { doc } = this.#getOverlayer(index)
const range = anchor(doc)
this.#emit('show-annotation', { value, range })
this.#emit('show-annotation', { value, index, range })
}
}
getCFI(index, range) {
@@ -320,6 +320,11 @@ export class View extends HTMLElement {
for (const { doc } of this.renderer.getContents())
doc.defaultView.getSelection().removeAllRanges()
}
getProgressOf(index, range) {
const tocItem = this.#tocProgress?.getProgress(index, range)
const pageItem = this.#pageProgress?.getProgress(index, range)
return { tocItem, pageItem }
}
async getTOCItemOf(target) {
try {
const { index, anchor } = await this.resolveNavigation(target)