Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(mobile): display current theme font in image sharing

tianma-if0fa1b2131540
diff --git a/apps/mobile/src/components/MobileNoteImageFontPicker.tsx b/apps/mobile/src/components/MobileNoteImageFontPicker.tsx
index 8dfe5b80..e52d80be 100644
--- a/apps/mobile/src/components/MobileNoteImageFontPicker.tsx
+++ b/apps/mobile/src/components/MobileNoteImageFontPicker.tsx
@@ -5,7 +5,7 @@ import type { DOMProps } from "expo/dom";
import { isRemoteNoteImageFont } from "@edgeever/shared/font-catalog";
import { resolveNoteImageTypography, type NoteImageFontStyle, type NoteImageTheme } from "@edgeever/shared/note-image-card";
import { prepareNoteImageAssets } from "@edgeever/shared/note-image-fonts";
-import { MOBILE_FONT_OPTIONS } from "../lib/note-image-font-options";
+import { getMobileNoteImageFontLabel, MOBILE_FONT_OPTIONS } from "../lib/note-image-font-options";
import { noteImageAssetUrls } from "./note-image-asset-urls";
type Props = {
@@ -64,6 +64,7 @@ export default function MobileNoteImageFontPicker({ selected, theme, chinese, on
`}</style>
<div className="font-list" role="radiogroup" aria-label={chinese ? "字体风格" : "Typography"} ref={listRef}>
{MOBILE_FONT_OPTIONS.map(item => {
+ const label = getMobileNoteImageFontLabel(item.id, theme, chinese, true);
const loaded = previews[item.id] === "ready";
const failed = previews[item.id] === "error";
const needsFont = item.id === "auto" || isRemoteNoteImageFont(item.id);
@@ -73,7 +74,7 @@ export default function MobileNoteImageFontPicker({ selected, theme, chinese, on
type="button"
role="radio"
aria-checked={selected === item.id}
- aria-label={chinese ? item.labelZh : item.labelEn}
+ aria-label={label}
className="font-option"
data-font={item.id}
onClick={async () => {
@@ -83,7 +84,7 @@ export default function MobileNoteImageFontPicker({ selected, theme, chinese, on
}}
>
<span className="font-option-copy">
- <span className="font-name">{chinese ? item.labelZh : item.labelEn}</span>
+ <span className="font-name">{label}</span>
{loaded || !needsFont ? (
<span className="font-sample" style={{ fontFamily: resolveNoteImageTypography(theme, item.id).bodyFamily }}>{sampleFor(item.id)}</span>
) : (
diff --git a/apps/mobile/src/lib/note-image-font-options.ts b/apps/mobile/src/lib/note-image-font-options.ts
index 07e5c28d..70123b41 100644
--- a/apps/mobile/src/lib/note-image-font-options.ts
+++ b/apps/mobile/src/lib/note-image-font-options.ts
@@ -1,5 +1,6 @@
+import { zhCN, enUS } from "@edgeever/shared/i18n";
import { FONT_CATALOG, FONT_IDS } from "@edgeever/shared/font-catalog";
-import type { NoteImageFontStyle } from "@edgeever/shared/note-image-card";
+import { NOTE_IMAGE_TEMPLATE_TYPOGRAPHY, resolveTheme, type NoteImageTheme, type NoteImageFontStyle } from "@edgeever/shared/note-image-card";
export const MOBILE_FONT_OPTIONS: Array<{ id: NoteImageFontStyle; labelZh: string; labelEn: string }> = [
{ id: "auto", labelZh: "跟随主题", labelEn: "Follow Theme" },
@@ -9,3 +10,19 @@ export const MOBILE_FONT_OPTIONS: Array<{ id: NoteImageFontStyle; labelZh: strin
{ id: "mono", labelZh: "极客等宽", labelEn: "Mono" },
...FONT_IDS.map(id => ({ id, labelZh: FONT_CATALOG[id].zh, labelEn: FONT_CATALOG[id].en })),
];
+
+export const getMobileNoteImageFontLabel = (
+ fontStyle: NoteImageFontStyle,
+ theme: NoteImageTheme,
+ chinese: boolean,
+ includeFollowTheme = false,
+): string => {
+ const option = MOBILE_FONT_OPTIONS.find(item => item.id === fontStyle);
+ const label = option?.[chinese ? "labelZh" : "labelEn"] ?? "";
+ if (fontStyle !== "auto") return label;
+ const labels = (chinese ? zhCN : enUS).editor.imageShare.templateFonts;
+ const themeFontLabel = NOTE_IMAGE_TEMPLATE_TYPOGRAPHY[resolveTheme(undefined, theme)].body
+ .map(font => labels[font])
+ .join(" / ");
+ return includeFollowTheme ? `${label} (${themeFontLabel})` : themeFontLabel;
+};
diff --git a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
index 88fa079a..53217ecc 100644
--- a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
+++ b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
@@ -22,7 +22,7 @@ import { Alert, Pressable, Text, TextInput } from "../components/LocalizedText";
import LocalTiptapEditor, { type LocalTiptapEditorRef } from "../components/LocalTiptapEditor";
import { MobileAiAssistantModal } from "../components/MobileAiAssistantModal";
import MobileNoteImageFontPicker from "../components/MobileNoteImageFontPicker";
-import { MOBILE_FONT_OPTIONS } from "../lib/note-image-font-options";
+import { getMobileNoteImageFontLabel } from "../lib/note-image-font-options";
import { MobileResourceActions } from "../components/MobileResourceActions";
import { ZoomableImagePreview } from "../components/ZoomableImagePreview";
import type { ImageSize } from "../lib/mobile-image-zoom";
@@ -527,6 +527,7 @@ export const MemoDetailModal = ({
showNotebook: imageShareNotebook, showTags: imageShareTags, showUpdatedAt: imageShareUpdatedAt,
showBranding: imageShareBranding,
} = imageSharePreferences;
+ const imageShareFontLabel = getMobileNoteImageFontLabel(imageShareFontStyle, imageShareTheme, resolvedLocale === "zh-CN");
const [viewerNotebookPickerOpen, setViewerNotebookPickerOpen] = useState(false);
const [viewerTagsOpen, setViewerTagsOpen] = useState(false);
const [viewerTags, setViewerTags] = useState<string[]>([]);
@@ -1710,14 +1711,14 @@ export const MemoDetailModal = ({
<Pressable
accessibilityRole="button"
- accessibilityLabel={`${resolvedLocale === "zh-CN" ? "字体风格" : "Typography"}: ${MOBILE_FONT_OPTIONS.find(item => item.id === imageShareFontStyle)?.[resolvedLocale === "zh-CN" ? "labelZh" : "labelEn"] ?? ""}`}
+ accessibilityLabel={`${resolvedLocale === "zh-CN" ? "字体风格" : "Typography"}: ${imageShareFontLabel}`}
accessibilityHint={resolvedLocale === "zh-CN" ? "打开字体选择列表" : "Open font selection"}
onPress={() => setImageShareFontPickerOpen(true)}
style={imageShareStyles.fontSelector}
>
<Text style={imageShareStyles.optionLabel}>{resolvedLocale === "zh-CN" ? "字体风格" : "Typography"}</Text>
<Text style={imageShareStyles.fontSelectorValue}>
- {MOBILE_FONT_OPTIONS.find(item => item.id === imageShareFontStyle)?.[resolvedLocale === "zh-CN" ? "labelZh" : "labelEn"]}
+ {imageShareFontLabel}
</Text>
<ChevronDown color="#64748b" size={18} />
</Pressable>