bump: sync with upstream foliate-js (#1381)

This commit is contained in:
Huang Xin
2025-06-11 11:11:06 +08:00
committed by GitHub
parent 9766ec0125
commit 97d7eb659c
4 changed files with 10 additions and 6 deletions
@@ -203,6 +203,12 @@ const FoliateViewer: React.FC<{
const { book } = view;
book.transformTarget?.addEventListener('load', (event: Event) => {
const { detail } = event as CustomEvent;
if (detail.isScript) {
detail.allowScript = viewSettings.allowScript ?? false;
}
});
book.transformTarget?.addEventListener('data', getDocTransformHandler({ width, height }));
view.renderer.setStyles?.(getStyles(viewSettings));
+2 -2
View File
@@ -178,7 +178,7 @@ export class DocumentLoader {
);
}
public async open({ allowScript = false } = {}): Promise<{ book: BookDoc; format: BookFormat }> {
public async open(): Promise<{ book: BookDoc; format: BookFormat }> {
let book = null;
let format: BookFormat = 'EPUB';
if (!this.file.size) {
@@ -200,7 +200,7 @@ export class DocumentLoader {
format = 'FBZ';
} else {
const { EPUB } = await import('foliate-js/epub.js');
book = await new EPUB(loader).init({ allowScript });
book = await new EPUB(loader).init();
format = 'EPUB';
}
} else if (await this.isPDF()) {
+1 -3
View File
@@ -130,9 +130,7 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
const content = (await appService.loadBookContent(book, settings)) as BookContent;
const { file, config } = content;
console.log('Loading book', key);
const { book: bookDoc } = await new DocumentLoader(file).open({
allowScript: config.viewSettings?.allowScript,
});
const { book: bookDoc } = await new DocumentLoader(file).open();
updateToc(bookDoc, config.viewSettings?.sortedTOC ?? false);
// Set the book's language for formerly imported books, newly imported books have this field set
book.primaryLanguage =