From 28ef414c3db0af8c219150cecc76c57accbd1bcd Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Mon, 20 Oct 2025 16:38:46 +0800 Subject: [PATCH] feat: supported footnotes for definition list, closes #2278 (#2279) --- .../src/app/reader/components/FootnotePopup.tsx | 7 ++++++- apps/readest-app/src/components/settings/ColorPanel.tsx | 2 +- apps/readest-app/src/utils/style.ts | 5 +++++ packages/foliate-js | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/readest-app/src/app/reader/components/FootnotePopup.tsx b/apps/readest-app/src/app/reader/components/FootnotePopup.tsx index d3f86f09..20833306 100644 --- a/apps/readest-app/src/app/reader/components/FootnotePopup.tsx +++ b/apps/readest-app/src/app/reader/components/FootnotePopup.tsx @@ -4,10 +4,11 @@ import { BookDoc } from '@/libs/document'; import { useReaderStore } from '@/store/readerStore'; import { useBookDataStore } from '@/store/bookDataStore'; import { useFoliateEvents } from '../hooks/useFoliateEvents'; +import { useCustomFontStore } from '@/store/customFontStore'; import { getFootnoteStyles, getStyles, getThemeCode } from '@/utils/style'; import { getPopupPosition, getPosition, Position } from '@/utils/sel'; import { FootnoteHandler } from 'foliate-js/footnotes.js'; -import { mountAdditionalFonts } from '@/styles/fonts'; +import { mountAdditionalFonts, mountCustomFont } from '@/styles/fonts'; import { eventDispatcher } from '@/utils/event'; import { FoliateView } from '@/types/view'; import { isCJKLang } from '@/utils/lang'; @@ -32,6 +33,7 @@ const FootnotePopup: React.FC = ({ bookKey, bookDoc }) => { const { getBookData } = useBookDataStore(); const { getView, getViewSettings } = useReaderStore(); + const { getLoadedFonts } = useCustomFontStore(); const view = getView(bookKey); const viewSettings = getViewSettings(bookKey)!; const footnoteHandler = new FootnoteHandler(); @@ -62,6 +64,9 @@ const FootnotePopup: React.FC = ({ bookKey, bookDoc }) => { const { doc } = e.detail; const bookData = getBookData(bookKey)!; mountAdditionalFonts(doc, isCJKLang(bookData.book?.primaryLanguage)); + getLoadedFonts().forEach((font) => { + mountCustomFont(doc, font); + }); }); footnoteViewRef.current = view; footnoteRef.current?.replaceChildren(view); diff --git a/apps/readest-app/src/components/settings/ColorPanel.tsx b/apps/readest-app/src/components/settings/ColorPanel.tsx index 7afc5a32..d70272dc 100644 --- a/apps/readest-app/src/components/settings/ColorPanel.tsx +++ b/apps/readest-app/src/components/settings/ColorPanel.tsx @@ -26,10 +26,10 @@ import { SettingsPanelPanelProp } from './SettingsDialog'; import { useFileSelector } from '@/hooks/useFileSelector'; import { PREDEFINED_TEXTURES } from '@/styles/textures'; import { HighlightColor } from '@/types/book'; +import { HIGHLIGHT_COLOR_HEX } from '@/services/constants'; import Select from '@/components/Select'; import ThemeEditor from './ThemeEditor'; import ColorInput from './ColorInput'; -import { HIGHLIGHT_COLOR_HEX } from '@/services/constants'; const ColorPanel: React.FC = ({ bookKey, onRegisterReset }) => { const _ = useTranslation(); diff --git a/apps/readest-app/src/utils/style.ts b/apps/readest-app/src/utils/style.ts index 75d721b9..5acb30c9 100644 --- a/apps/readest-app/src/utils/style.ts +++ b/apps/readest-app/src/utils/style.ts @@ -400,6 +400,11 @@ export const getFootnoteStyles = () => ` padding: unset !important; } + dt { + font-weight: bold; + line-height: 1.6; + } + .epubtype-footnote, aside[epub|type~="endnote"], aside[epub|type~="footnote"], diff --git a/packages/foliate-js b/packages/foliate-js index 7d1693dd..3ffb3316 160000 --- a/packages/foliate-js +++ b/packages/foliate-js @@ -1 +1 @@ -Subproject commit 7d1693ddd1a6834e3b02532c8c84c4ba4acbab6c +Subproject commit 3ffb3316203a8fed8978b268e1b76a53bf42136a