From 3ea54e67250fecbc97508f3d1b5ac2f24e3476ad Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Tue, 26 Aug 2025 18:45:12 +0800 Subject: [PATCH] fix: display hidden footnotes, closes #1847 (#1907) --- apps/readest-app/src/libs/document.ts | 14 +++++++++++++- apps/readest-app/src/services/appService.ts | 1 + apps/readest-app/src/types/book.ts | 2 +- apps/readest-app/src/utils/style.ts | 13 +++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/readest-app/src/libs/document.ts b/apps/readest-app/src/libs/document.ts index 2ec2a7b4..18a23c35 100644 --- a/apps/readest-app/src/libs/document.ts +++ b/apps/readest-app/src/libs/document.ts @@ -101,6 +101,8 @@ export const EXTS: Record = { EPUB: 'epub', PDF: 'pdf', MOBI: 'mobi', + AZW: 'azw', + AZW3: 'azw3', CBZ: 'cbz', FB2: 'fb2', FBZ: 'fbz', @@ -228,7 +230,17 @@ export class DocumentLoader { const fflate = await import('foliate-js/vendor/fflate.js'); const { MOBI } = await import('foliate-js/mobi.js'); book = await new MOBI({ unzlib: fflate.unzlibSync }).open(this.file); - format = 'MOBI'; + const ext = this.file.name.split('.').pop()?.toLowerCase(); + switch (ext) { + case 'azw': + format = 'AZW'; + break; + case 'azw3': + format = 'AZW3'; + break; + default: + format = 'MOBI'; + } } else if (this.isFB2()) { const { makeFB2 } = await import('foliate-js/fb2.js'); book = await makeFB2(this.file); diff --git a/apps/readest-app/src/services/appService.ts b/apps/readest-app/src/services/appService.ts index 723800d9..f5b0533b 100644 --- a/apps/readest-app/src/services/appService.ts +++ b/apps/readest-app/src/services/appService.ts @@ -218,6 +218,7 @@ export abstract class BaseAppService implements AppService { }; // update book metadata when reimporting the same book if (existingBook) { + existingBook.format = book.format; existingBook.title = existingBook.title ?? book.title; existingBook.sourceTitle = existingBook.sourceTitle ?? book.sourceTitle; existingBook.author = existingBook.author ?? book.author; diff --git a/apps/readest-app/src/types/book.ts b/apps/readest-app/src/types/book.ts index f2daec21..2c0d72de 100644 --- a/apps/readest-app/src/types/book.ts +++ b/apps/readest-app/src/types/book.ts @@ -1,6 +1,6 @@ import { BookMetadata } from '@/libs/document'; -export type BookFormat = 'EPUB' | 'PDF' | 'MOBI' | 'CBZ' | 'FB2' | 'FBZ'; +export type BookFormat = 'EPUB' | 'PDF' | 'MOBI' | 'AZW' | 'AZW3' | 'CBZ' | 'FB2' | 'FBZ'; export type BookNoteType = 'bookmark' | 'annotation' | 'excerpt'; export type HighlightStyle = 'highlight' | 'underline' | 'squiggly'; export type HighlightColor = 'red' | 'yellow' | 'green' | 'blue' | 'violet'; diff --git a/apps/readest-app/src/utils/style.ts b/apps/readest-app/src/utils/style.ts index 2eea40c0..76b0d91c 100644 --- a/apps/readest-app/src/utils/style.ts +++ b/apps/readest-app/src/utils/style.ts @@ -363,6 +363,19 @@ export const getFootnoteStyles = () => ` margin: unset !important; text-indent: unset !important; } + + div { + margin: unset !important; + padding: unset !important; + } + + .epubtype-footnote, + aside[epub|type~="endnote"], + aside[epub|type~="footnote"], + aside[epub|type~="note"], + aside[epub|type~="rearnote"] { + display: block; + } `; const getTranslationStyles = (showSource: boolean) => `