mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
PDF: fix links
This commit is contained in:
@@ -51,6 +51,7 @@ const render = async (page, doc, zoom) => {
|
|||||||
await new pdfjsLib.AnnotationLayer({ page, viewport, div }).render({
|
await new pdfjsLib.AnnotationLayer({ page, viewport, div }).render({
|
||||||
annotations: await page.getAnnotations(),
|
annotations: await page.getAnnotations(),
|
||||||
linkService: {
|
linkService: {
|
||||||
|
goToDestination: () => {},
|
||||||
getDestinationHash: dest => JSON.stringify(dest),
|
getDestinationHash: dest => JSON.stringify(dest),
|
||||||
addLinkAttributes: (link, url) => link.href = url,
|
addLinkAttributes: (link, url) => link.href = url,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -229,8 +229,9 @@ export class View extends HTMLElement {
|
|||||||
#handleLinks(doc, index) {
|
#handleLinks(doc, index) {
|
||||||
const { book } = this
|
const { book } = this
|
||||||
const section = book.sections[index]
|
const section = book.sections[index]
|
||||||
for (const a of doc.querySelectorAll('a[href]'))
|
doc.addEventListener('click', e => {
|
||||||
a.addEventListener('click', e => {
|
const a = e.target.closest('a[href]')
|
||||||
|
if (!a) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const href_ = a.getAttribute('href')
|
const href_ = a.getAttribute('href')
|
||||||
const href = section?.resolveHref?.(href_) ?? href_
|
const href = section?.resolveHref?.(href_) ?? href_
|
||||||
|
|||||||
Reference in New Issue
Block a user