mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Allow getting page/TOC item for ranges
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user