mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Restore config.pdfjsPath override and options plumbing
Reverts the pdf.js/view.js API change that removed the exported 'config' (pdfjsPath) and the makePDF/open options parameter. bookhoard overrides config.pdfjsPath to point at its own served /static/vendor/pdfjs/ assets, so the override + options must stay. Keep the unrelated external-link href fix in view.js.
This commit is contained in:
@@ -76,7 +76,7 @@ const fetchFile = async url => {
|
||||
return new File([await res.blob()], new URL(res.url).pathname)
|
||||
}
|
||||
|
||||
export const makeBook = async file => {
|
||||
export const makeBook = async (file, options = {}) => {
|
||||
if (typeof file === 'string') file = await fetchFile(file)
|
||||
let book
|
||||
if (file.isDirectory) {
|
||||
@@ -105,7 +105,7 @@ export const makeBook = async file => {
|
||||
}
|
||||
else if (await isPDF(file)) {
|
||||
const { makePDF } = await import('./pdf.js')
|
||||
book = await makePDF(file)
|
||||
book = await makePDF(file, options.pdf)
|
||||
}
|
||||
else {
|
||||
const { isMOBI, MOBI } = await import('./mobi.js')
|
||||
@@ -230,10 +230,10 @@ export class View extends HTMLElement {
|
||||
this.renderer.goTo(resolved)
|
||||
})
|
||||
}
|
||||
async open(book) {
|
||||
async open(book, options = {}) {
|
||||
if (typeof book === 'string'
|
||||
|| typeof book.arrayBuffer === 'function'
|
||||
|| book.isDirectory) book = await makeBook(book)
|
||||
|| book.isDirectory) book = await makeBook(book, options)
|
||||
this.book = book
|
||||
this.language = languageInfo(book.metadata?.language)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user