mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Merge branch 'johnfactotum:main' into main
This commit is contained in:
@@ -351,6 +351,7 @@ export const makeFB2 = async blob => {
|
|||||||
}
|
}
|
||||||
book.splitTOCHref = href => href?.split('#')?.map(x => Number(x)) ?? []
|
book.splitTOCHref = href => href?.split('#')?.map(x => Number(x)) ?? []
|
||||||
book.getTOCFragment = (doc, id) => doc.querySelector(`[${dataID}="${id}"]`)
|
book.getTOCFragment = (doc, id) => doc.querySelector(`[${dataID}="${id}"]`)
|
||||||
|
book.isExternal = uri => /^\w+:/i.test(uri)
|
||||||
|
|
||||||
book.destroy = () => {
|
book.destroy = () => {
|
||||||
for (const url of urls) URL.revokeObjectURL(url)
|
for (const url of urls) URL.revokeObjectURL(url)
|
||||||
|
|||||||
@@ -357,8 +357,8 @@ export class View extends HTMLElement {
|
|||||||
const href_ = a.getAttribute('href')
|
const href_ = a.getAttribute('href')
|
||||||
const href = section?.resolveHref?.(href_) ?? href_
|
const href = section?.resolveHref?.(href_) ?? href_
|
||||||
if (book?.isExternal?.(href))
|
if (book?.isExternal?.(href))
|
||||||
Promise.resolve(this.#emit('external-link', { a, href }, true))
|
Promise.resolve(this.#emit('external-link', { a, href_ }, true))
|
||||||
.then(x => x ? globalThis.open(href, '_blank') : null)
|
.then(x => x ? globalThis.open(href_, '_blank') : null)
|
||||||
.catch(e => console.error(e))
|
.catch(e => console.error(e))
|
||||||
else Promise.resolve(this.#emit('link', { a, href }, true))
|
else Promise.resolve(this.#emit('link', { a, href }, true))
|
||||||
.then(x => x ? this.goTo(href) : null)
|
.then(x => x ? this.goTo(href) : null)
|
||||||
|
|||||||
Reference in New Issue
Block a user