mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add an EventTarget for transforming the book
And use it to do paginator-specific CSS replacements. And use it to catch loading errors in reader.js. Fixes #14 Closes #18
This commit is contained in:
@@ -111,6 +111,12 @@ class Reader {
|
||||
this.view.addEventListener('relocate', this.#onRelocate.bind(this))
|
||||
|
||||
const { book } = this.view
|
||||
book.transformTarget?.addEventListener('data', ({ detail }) => {
|
||||
detail.data = Promise.resolve(detail.data).catch(e => {
|
||||
console.error(new Error(`Failed to load ${detail.name}`, { cause: e }))
|
||||
return ''
|
||||
})
|
||||
})
|
||||
this.view.renderer.setStyles?.(getCSS(this.style))
|
||||
this.view.renderer.next()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user