AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix: restore template typography when switching note image themes
tianma-ifd885161b3e4b
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swiftindex e63addbc..07c289a3 100644--- a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift+++ b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift@@ -178,7 +178,15 @@ struct MemoDetailView: View {NavigationStack {Form {Section(env.preferences.t("主题风格", en: "Theme", pl: "Motyw")) {- Picker(env.preferences.t("主题风格", en: "Theme", pl: "Motyw"), selection: $preferences.noteImageShare.theme) {+ Picker(env.preferences.t("主题风格", en: "Theme", pl: "Motyw"), selection: Binding(+ get: { preferences.noteImageShare.theme },+ set: { theme in+ var share = preferences.noteImageShare+ share.theme = theme+ share.fontStyle = "auto"+ preferences.noteImageShare = share+ }+ )) {Text(env.preferences.t("默认", en: "Classic", pl: "Klasyczny")).tag("gradient")Text(env.preferences.t("透明", en: "Glass", pl: "Szkło")).tag("glass")Text(env.preferences.t("金句", en: "Quote", pl: "Cytat")).tag("quote")diff --git a/apps/mobile/src/lib/note-image-preferences.test.mjs b/apps/mobile/src/lib/note-image-preferences.test.mjsindex 553690be..0a0eac74 100644--- a/apps/mobile/src/lib/note-image-preferences.test.mjs+++ b/apps/mobile/src/lib/note-image-preferences.test.mjs@@ -8,6 +8,21 @@ const changed = {showTags: true, showUpdatedAt: false, showBranding: false,};+test('switching templates persists automatic typography and allows a later manual font', async () => {+ let raw = JSON.stringify(changed);+ const storage = { getItem: async () => raw, setItem: async (_key, value) => { raw = value; } };+ const store = createMobileNoteImagePreferenceStore(storage);+ await store.load();+ store.update('theme', 'handwritten');+ expect(store.getSnapshot()).toEqual({ ...changed, theme: 'handwritten', fontStyle: 'auto' });+ await store.flush();+ const restarted = createMobileNoteImagePreferenceStore(storage);+ await restarted.load();+ expect(restarted.getSnapshot().fontStyle).toBe('auto');+ restarted.update('fontStyle', 'sans');+ expect(restarted.getSnapshot().fontStyle).toBe('sans');+});+test('all mobile share choices survive switching views and a fresh store after restart', async () => {let raw = null;const storage = { getItem: async () => raw, setItem: async (_key, value) => { raw = value; } };diff --git a/apps/mobile/src/lib/note-image-preferences.ts b/apps/mobile/src/lib/note-image-preferences.tsindex 0893cf6a..f8b1b1a1 100644--- a/apps/mobile/src/lib/note-image-preferences.ts+++ b/apps/mobile/src/lib/note-image-preferences.ts@@ -1,6 +1,7 @@import {DEFAULT_NOTE_IMAGE_PREFERENCES,parseNoteImagePreferences,+ updateNoteImagePreference,type NoteImagePreferences,} from "@edgeever/shared/note-image-preferences";@@ -34,7 +35,7 @@ export const createMobileNoteImagePreferenceStore = (storage: PreferenceStorage)update: <K extends keyof NoteImagePreferences>(key: K, value: NoteImagePreferences[K]) => {// The sheet stays in its loading state until hydration finishes.if (!snapshot) return;- snapshot = { ...snapshot, [key]: value };+ snapshot = updateNoteImagePreference(snapshot, key, value);const raw = JSON.stringify(snapshot);notify();// Serialize writes so a slow earlier write cannot replace the latest choice.diff --git a/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx b/apps/web/src/components/dialogs/ShareNoteImageDialog.tsxindex 2f347133..9135a832 100644--- a/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx+++ b/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx@@ -2,6 +2,7 @@ import type { FontLoadStatus } from "@/lib/font-load-state";import { useFontPreviewStatus } from "@/lib/use-font-preview-status";import { FontLoadFeedback } from "@/components/FontLoadFeedback";import { FONT_CATALOG, FONT_IDS } from "@edgeever/shared/font-catalog";+import { updateNoteImagePreference } from "@edgeever/shared/note-image-preferences";import { prepareNoteImageAssets } from "@edgeever/shared/note-image-fonts";import { noteImageAssetUrls } from "@edgeever/shared/note-image-assets";import { Check, Copy, Download, LoaderCircle, Palette, Share2, Type } from "lucide-react";@@ -134,7 +135,7 @@ export const ShareNoteImageDialog = ({showUpdatedAt, showReadingTime, showAuthor, author, showBranding,} = preferences;const setPreference = <K extends keyof NoteImagePreferences>(key: K, value: NoteImagePreferences[K]) => {- setPreferences(current => ({ ...current, [key]: value }));+ setPreferences(current => updateNoteImagePreference(current, key, value));};useEffect(() => {@@ -333,7 +334,7 @@ export const ShareNoteImageDialog = ({><NoteImageThemePreviewtheme={id}- fontStyle={fontStyle}+ fontStyle="auto"title={source.title || label}body={t("editor.imageShare.previewBody")}quote={t("editor.imageShare.previewQuote")}diff --git a/packages/shared/src/note-image-preferences.test.mjs b/packages/shared/src/note-image-preferences.test.mjsnew file mode 100644index 00000000..e8fbb109--- /dev/null+++ b/packages/shared/src/note-image-preferences.test.mjs@@ -0,0 +1,16 @@+import { expect, test } from "bun:test";+import { DEFAULT_NOTE_IMAGE_PREFERENCES, updateNoteImagePreference } from "./note-image-preferences";+import { NOTE_IMAGE_THEME_OPTIONS, resolveNoteImageTypography } from "./note-image-card";++test("selecting any template restores its typography after a custom font", () => {+ const custom = { ...DEFAULT_NOTE_IMAGE_PREFERENCES, fontStyle: "heavy", showAuthor: true, author: "天马" };+ for (const theme of NOTE_IMAGE_THEME_OPTIONS) {+ const selected = updateNoteImagePreference(custom, "theme", theme);+ expect(selected).toEqual({ ...custom, theme, fontStyle: "auto" });+ expect(resolveNoteImageTypography(theme, selected.fontStyle)).toEqual(resolveNoteImageTypography(theme));+ const manual = updateNoteImagePreference(selected, "fontStyle", "serif");+ expect(manual.fontStyle).toBe("serif");+ expect(updateNoteImagePreference(manual, "fontSize", "sm").fontStyle).toBe("serif");+ expect(updateNoteImagePreference(manual, "theme", theme).fontStyle).toBe("auto");+ }+});diff --git a/packages/shared/src/note-image-preferences.ts b/packages/shared/src/note-image-preferences.tsindex 0f6912f4..92c1260f 100644--- a/packages/shared/src/note-image-preferences.ts+++ b/packages/shared/src/note-image-preferences.ts@@ -29,6 +29,17 @@ export const DEFAULT_NOTE_IMAGE_PREFERENCES: NoteImagePreferences = {showReadingTime: false, showAuthor: false, showBranding: true, author: "",};+/** Selecting a template restores its typography; later font choices override it. */+export const updateNoteImagePreference = <K extends keyof NoteImagePreferences>(+ preferences: NoteImagePreferences,+ key: K,+ value: NoteImagePreferences[K],+): NoteImagePreferences => ({+ ...preferences,+ [key]: value,+ ...(key === "theme" ? { fontStyle: "auto" as const } : {}),+});+const choices = {theme: NOTE_IMAGE_THEME_OPTIONS,fontStyle: ["auto", "kai", "serif", "sans", "mono", ...FONT_IDS],