Skip to content

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

fix(web): refine classic theme and Mermaid appearance

tianma-if30574747b281
diff --git a/README.md b/README.md
index 77066047..07c42332 100644
--- a/README.md
+++ b/README.md
@@ -256,7 +256,7 @@ Docker runs the same frontend, API routes, services, authentication, MCP impleme
- The "Minimal Emerald" theme typography layout is inspired by [obsidian-minimal](https://github.com/kepano/obsidian-minimal).
- The "Outline Emerald" theme typography layout is inspired by [Outline](https://github.com/outline/outline).
-- The "Marxico Classic" theme adapts the default typography of [Marxico](https://maxiang.io/) to EdgeEver's editor.
+- The "Classic Blue & White" theme is inspired by the early [StackEdit](https://github.com/benweet/stackedit)/[Bootstrap](https://github.com/twbs/bootstrap) Markdown typography style, with Chinese typography details informed by [Marxico](https://maxiang.io/).
## Disclaimer
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 23b9a175..f223d826 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -252,7 +252,7 @@ Docker 与 Cloudflare 共用同一套前端、API 路由、业务服务、鉴权
- “minimal品牌绿”主题排版架构借鉴于 [obsidian-minimal](https://github.com/kepano/obsidian-minimal)。
- “Outline 品牌绿”主题排版架构借鉴于 [Outline](https://github.com/outline/outline)。
-- “马克飞象经典”主题将[马克飞象](https://maxiang.io/)的默认排版适配到了 EdgeEver 编辑器。
+- “经典蓝白”主题借鉴了早期 [StackEdit](https://github.com/benweet/stackedit)/[Bootstrap](https://github.com/twbs/bootstrap) 系 Markdown 排版风格,并参考[马克飞象](https://maxiang.io/)完善中文排版细节。
## 免责声明
diff --git a/apps/web/src/components/ThemeProvider.tsx b/apps/web/src/components/ThemeProvider.tsx
index 45424efc..6dba1b6c 100644
--- a/apps/web/src/components/ThemeProvider.tsx
+++ b/apps/web/src/components/ThemeProvider.tsx
@@ -20,6 +20,8 @@ export const MERMAID_THEME_NAMES = [
"one-dark",
] as const;
export type MermaidThemeName = (typeof MERMAID_THEME_NAMES)[number];
+export const MERMAID_THEME_PREFERENCES = ["auto", ...MERMAID_THEME_NAMES] as const;
+export type MermaidThemePreference = (typeof MERMAID_THEME_PREFERENCES)[number];
export interface MermaidThemePalette {
bg: string;
@@ -114,7 +116,8 @@ interface AppearanceThemeContextValue {
interface MermaidThemeContextValue {
mermaidTheme: MermaidThemeName;
- setMermaidTheme: (theme: MermaidThemeName) => void;
+ mermaidThemePreference: MermaidThemePreference;
+ setMermaidTheme: (theme: MermaidThemePreference) => void;
}
interface EditorThemeContextValue {
@@ -163,11 +166,20 @@ export const getStoredThemePreference = (): ThemePreference => {
return stored === "light" || stored === "dark" || stored === "system" ? stored : "system";
};
-export const getStoredMermaidTheme = (): MermaidThemeName => {
+export const getStoredMermaidTheme = (): MermaidThemePreference => {
const stored = readLocalStorageItem(MERMAID_THEME_STORAGE_KEY);
- return MERMAID_THEME_NAMES.includes(stored as MermaidThemeName) ? stored as MermaidThemeName : "zinc-light";
+ return MERMAID_THEME_PREFERENCES.includes(stored as MermaidThemePreference)
+ ? stored as MermaidThemePreference
+ : "auto";
};
+export const resolveMermaidTheme = (
+ preference: MermaidThemePreference,
+ appearance: ResolvedTheme,
+): MermaidThemeName => preference === "auto"
+ ? appearance === "dark" ? "zinc-dark" : "zinc-light"
+ : preference;
+
export const getStoredEditorTheme = (): string => {
return readLocalStorageItem(EDITOR_THEME_STORAGE_KEY) || "default";
};
@@ -256,7 +268,7 @@ export const initializeTheme = () => {
export const ThemeProvider = ({ children }: ThemeProviderProps) => {
const [preference, setPreferenceState] = useState<ThemePreference>(getStoredThemePreference);
const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolveTheme(preference));
- const [mermaidTheme, setMermaidThemeState] = useState<MermaidThemeName>(getStoredMermaidTheme);
+ const [mermaidThemePreference, setMermaidThemePreference] = useState<MermaidThemePreference>(getStoredMermaidTheme);
const [editorTheme, setEditorThemeState] = useState<string>(getStoredEditorTheme);
const [customEditorThemes, setCustomEditorThemesState] = useState<CustomEditorTheme[]>(getStoredCustomEditorThemes);
@@ -307,8 +319,10 @@ export const ThemeProvider = ({ children }: ThemeProviderProps) => {
window.localStorage.setItem(CUSTOM_EDITOR_THEMES_STORAGE_KEY, JSON.stringify(nextThemes));
}, []);
- const setMermaidTheme = useCallback((nextTheme: MermaidThemeName) => {
- setMermaidThemeState(nextTheme);
+ const mermaidTheme = resolveMermaidTheme(mermaidThemePreference, resolvedTheme);
+
+ const setMermaidTheme = useCallback((nextTheme: MermaidThemePreference) => {
+ setMermaidThemePreference(nextTheme);
window.localStorage.setItem(MERMAID_THEME_STORAGE_KEY, nextTheme);
}, []);
@@ -329,9 +343,10 @@ export const ThemeProvider = ({ children }: ThemeProviderProps) => {
const mermaidValue = useMemo(
() => ({
mermaidTheme,
+ mermaidThemePreference,
setMermaidTheme,
}),
- [mermaidTheme, setMermaidTheme]
+ [mermaidTheme, mermaidThemePreference, setMermaidTheme]
);
const editorValue = useMemo(
diff --git a/apps/web/src/components/settings/PreferenceCard.tsx b/apps/web/src/components/settings/PreferenceCard.tsx
index bccd4f53..5efd12c8 100644
--- a/apps/web/src/components/settings/PreferenceCard.tsx
+++ b/apps/web/src/components/settings/PreferenceCard.tsx
@@ -32,7 +32,7 @@ import {
import { ShortcutSettingsItem } from "./ShortcutSettingsItem";
import { CustomEditorThemeDialog } from "./CustomEditorThemeDialog";
import {
- MERMAID_THEME_NAMES,
+ MERMAID_THEME_PREFERENCES,
useEditorTheme,
useMermaidTheme,
DEFAULT_CUSTOM_LIGHT_COLORS,
@@ -68,7 +68,7 @@ export const PreferenceCard = ({
setCustomEditorThemes,
setEditorTheme,
} = useEditorTheme();
- const { mermaidTheme, setMermaidTheme } = useMermaidTheme();
+ const { mermaidThemePreference, setMermaidTheme } = useMermaidTheme();
const [customThemeDialogOpen, setCustomThemeDialogOpen] = useState(false);
const [editingTheme, setEditingTheme] = useState<CustomEditorTheme | null>(null);
const [activeLocalePreference, setActiveLocalePreference] = useState<AppLocalePreference>(() => getAppLocalePreference());
@@ -315,12 +315,12 @@ export const PreferenceCard = ({
</div>
</div>
<div className="w-full shrink-0 sm:w-80">
- <Select value={mermaidTheme} onValueChange={(value) => setMermaidTheme(value as typeof mermaidTheme)}>
+ <Select value={mermaidThemePreference} onValueChange={(value) => setMermaidTheme(value as typeof mermaidThemePreference)}>
<SelectTrigger aria-label={t("settings.mermaidThemeTitle")} className="h-9 bg-white">
<SelectValue />
</SelectTrigger>
<SelectContent>
- {MERMAID_THEME_NAMES.map((theme) => (
+ {MERMAID_THEME_PREFERENCES.map((theme) => (
<SelectItem key={theme} value={theme}>
{t(`settings.mermaidThemes.${theme}`)}
</SelectItem>
diff --git a/apps/web/src/lib/dark-theme.test.mjs b/apps/web/src/lib/dark-theme.test.mjs
index b0aeec6f..7c7cc5e2 100644
--- a/apps/web/src/lib/dark-theme.test.mjs
+++ b/apps/web/src/lib/dark-theme.test.mjs
@@ -1,7 +1,11 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { contrastRatio } from "./color-contrast";
-import { DEFAULT_CUSTOM_DARK_COLORS, DEFAULT_CUSTOM_LIGHT_COLORS } from "../components/ThemeProvider";
+import {
+ DEFAULT_CUSTOM_DARK_COLORS,
+ DEFAULT_CUSTOM_LIGHT_COLORS,
+ resolveMermaidTheme,
+} from "../components/ThemeProvider";
describe("dark theme contracts", () => {
test("default custom editor themes meet their contrast thresholds", () => {
@@ -30,6 +34,12 @@ describe("dark theme contracts", () => {
expect(contrastRatio("#e7edf2", "#19222b")).toBeGreaterThanOrEqual(4.5);
});
+ test("automatic Mermaid themes follow the resolved appearance", () => {
+ expect(resolveMermaidTheme("auto", "light")).toBe("zinc-light");
+ expect(resolveMermaidTheme("auto", "dark")).toBe("zinc-dark");
+ expect(resolveMermaidTheme("dracula", "light")).toBe("dracula");
+ });
+
test("appearance changes stay out of the editor React render path", () => {
const editorPane = readFileSync(new URL("../components/EditorPane.tsx", import.meta.url), "utf8");
const editorThemeCss = readFileSync(new URL("../styles/editor-themes/base.css", import.meta.url), "utf8");
diff --git a/apps/web/src/styles/editor-themes/marxico.css b/apps/web/src/styles/editor-themes/marxico.css
index dfddf1fb..b5cb3ce7 100644
--- a/apps/web/src/styles/editor-themes/marxico.css
+++ b/apps/web/src/styles/editor-themes/marxico.css
@@ -1,4 +1,4 @@
-/* Marxico's default reading theme, mapped from its live computed styles. */
+/* Classic StackEdit/Bootstrap-era Markdown typography, adapted for EdgeEver with Marxico as a Chinese presentation reference. */
.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) {
--editor-theme-bg: #ffffff;
@@ -188,7 +188,6 @@
.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) .ProseMirror pre code,
.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) .ProseMirror .edgeever-code-source {
- display: block;
border: 0;
border-radius: 0;
background: #23241f;
@@ -200,6 +199,14 @@
white-space: pre-wrap;
}
+.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) .ProseMirror pre code {
+ display: block;
+}
+
+.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) .ProseMirror .edgeever-mermaid-code-block:not(.is-source-visible) .edgeever-mermaid-source {
+ display: none;
+}
+
.edgeever-editor[data-editor-theme="marxico"]:not([data-editor-theme="default"]) .ProseMirror .edgeever-code-copy-button {
border-color: rgb(255 255 255 / 18%);
background: rgb(35 36 31 / 88%);
diff --git a/apps/web/src/styles/mermaid-layout.test.mjs b/apps/web/src/styles/mermaid-layout.test.mjs
index 340abe4d..b49debb4 100644
--- a/apps/web/src/styles/mermaid-layout.test.mjs
+++ b/apps/web/src/styles/mermaid-layout.test.mjs
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
const globals = readFileSync(new URL("./globals.css", import.meta.url), "utf8");
+const marxico = readFileSync(new URL("./editor-themes/marxico.css", import.meta.url), "utf8");
describe("Mermaid editor layout", () => {
test("caps wide-screen diagram blocks without narrowing compact viewports", () => {
@@ -15,4 +16,10 @@ describe("Mermaid editor layout", () => {
/\.ProseMirror \.edgeever-mermaid-svg svg\s*{[^}]*width: auto;[^}]*max-width: 100%;[^}]*max-height: 30rem;/s,
);
});
+
+ test("keeps Mermaid source collapsed in the classic blue and white theme", () => {
+ expect(marxico).toMatch(
+ /\.edgeever-mermaid-code-block:not\(\.is-source-visible\) \.edgeever-mermaid-source\s*{[^}]*display:\s*none;/s,
+ );
+ });
});
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index a5e542b4..879b351d 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -203,7 +203,7 @@ export const enUS = {
syncIntervalDescription: "Sync edits to the server automatically while keeping local drafts available immediately.",
syncIntervals: { "30s": "Every 30 seconds", "5m": "Every 5 minutes", "15m": "Every 15 minutes", "30m": "Every 30 minutes", "1h": "Every hour", "2h": "Every 2 hours" },
mermaidThemeTitle: "Diagram theme",
- mermaidThemeDescription: "Choose the visual theme for diagrams in notes.",
+ mermaidThemeDescription: "Follow the app appearance or choose a fixed visual theme for diagrams.",
editorThemeTitle: "Editor theme",
editorThemeDescription: "Choose a writing style for the note editor. Saved in this browser.",
editorContentAlignmentTitle: "Note content layout",
@@ -218,7 +218,7 @@ export const enUS = {
"outline-emerald": "Outline Emerald",
"wechat-green": "WeChat Classic Green",
"modern-mint": "Modern Mint",
- marxico: "Marxico Classic",
+ marxico: "Classic Blue & White",
custom: "Custom",
},
customEditorTheme: {
@@ -241,6 +241,7 @@ export const enUS = {
contrastWarning: "Body, muted, heading, or accent colors need more contrast before saving.",
},
mermaidThemes: {
+ auto: "Follow app appearance",
"zinc-light": "Zinc Light",
"zinc-dark": "Zinc Dark",
"tokyo-night": "Tokyo Night",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 4853e19d..62fca6a5 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -203,7 +203,7 @@ export const zhCN = {
syncIntervalDescription: "定期将编辑内容同步到服务器,本地草稿仍会即时保留。",
syncIntervals: { "30s": "每 30 秒", "5m": "每 5 分钟", "15m": "每 15 分钟", "30m": "每 30 分钟", "1h": "每 1 小时", "2h": "每 2 小时" },
mermaidThemeTitle: "图表主题",
- mermaidThemeDescription: "选择笔记中图表的视觉主题。",
+ mermaidThemeDescription: "跟随应用外观,或为笔记图表选择固定主题。",
editorThemeTitle: "编辑器主题",
editorThemeDescription: "选择正文编辑区的排版风格,偏好会保存在当前浏览器中。",
editorContentAlignmentTitle: "笔记正文布局",
@@ -218,7 +218,7 @@ export const zhCN = {
"outline-emerald": "Outline 品牌绿",
"wechat-green": "微信经典绿",
"modern-mint": "极客薄荷绿",
- marxico: "马克飞象经典",
+ marxico: "经典蓝白",
custom: "自定义",
},
customEditorTheme: {
@@ -241,6 +241,7 @@ export const zhCN = {
contrastWarning: "正文、辅助文字、标题或强调色的对比度不足,请调整后保存。",
},
mermaidThemes: {
+ auto: "跟随应用外观",
"zinc-light": "Zinc 浅色",
"zinc-dark": "Zinc 深色",
"tokyo-night": "Tokyo Night",