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
feat(web): add letter, guide, blueprint, and journal editor themes
tianma-if50dbd3878790
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 1340ed56..8c9dbb59 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -91,7 +91,7 @@ import {type NoteLinkSuggestionLabels,} from "./editor/NoteLinkSuggestion";import { WeChatIcon } from "./WeChatIcon";-import { useEditorTheme, useMarkdownTheme } from "./ThemeProvider";+import { isNamedEditorTheme, useEditorTheme, useMarkdownTheme } from "./ThemeProvider";import type { MarkdownSourceEditorRef } from "./editor/MarkdownSourceEditor";const MarkdownSourceEditor = lazy(() =>@@ -161,6 +161,7 @@ import {type ShortcutSettings,} from "@/lib/app-helpers";import { copyEditorToWeChat, copyMarkdownToWeChat } from "@/lib/wechat-copy";+import { isPaperEditorTheme, publishEditorCssVars, resolvePaperEditorTheme } from "@/lib/publish-layout";import { ThemeBlock } from "./ThemeBlock";import { downloadMarkdownFile } from "@/lib/note-markdown-export";import { NOTE_HTML_FULL_STYLES } from "@/lib/note-html-export-assets";@@ -4196,27 +4197,17 @@ const RichEditorPane = ({<divref={setEditorScrollContainerRef}- data-editor-theme={- editorTheme === "default" ||- editorTheme === "minimal-emerald" ||- editorTheme === "outline-emerald" ||- editorTheme === "wechat-green" ||- editorTheme === "modern-mint" ||- editorTheme === "marxico"- ? editorTheme- : "custom"- }+ data-editor-theme={isNamedEditorTheme(editorTheme) ? editorTheme : "custom"}style={{- "--editor-body-font-size": `${MEMO_CONTENT_STYLE.body.fontSize}px`,- "--editor-body-line-height": String(MEMO_CONTENT_STYLE.body.lineHeight / MEMO_CONTENT_STYLE.body.fontSize),- "--editor-paragraph-spacing": `${MEMO_CONTENT_STYLE.body.paragraphSpacing}px`,+ ...(isPaperEditorTheme(editorTheme)+ ? publishEditorCssVars(editorTheme, resolvePaperEditorTheme(editorTheme)?.palette ?? "emerald")+ : {+ "--editor-body-font-size": `${MEMO_CONTENT_STYLE.body.fontSize}px`,+ "--editor-body-line-height": String(MEMO_CONTENT_STYLE.body.lineHeight / MEMO_CONTENT_STYLE.body.fontSize),+ "--editor-paragraph-spacing": `${MEMO_CONTENT_STYLE.body.paragraphSpacing}px`,+ }),"--memo-content-divider-spacing": `${MEMO_CONTENT_STYLE.divider.marginVertical}px`,- ...(editorTheme !== "default" &&- editorTheme !== "minimal-emerald" &&- editorTheme !== "outline-emerald" &&- editorTheme !== "wechat-green" &&- editorTheme !== "modern-mint" &&- editorTheme !== "marxico"+ ...(!isNamedEditorTheme(editorTheme)? {"--editor-theme-light-bg": customEditorTheme.light.background,"--editor-theme-light-text": customEditorTheme.light.text,@@ -4247,13 +4238,7 @@ const RichEditorPane = ({: "overflow-y-auto")}>- {editorTheme !== "default" &&- editorTheme !== "minimal-emerald" &&- editorTheme !== "outline-emerald" &&- editorTheme !== "wechat-green" &&- editorTheme !== "modern-mint" &&- editorTheme !== "marxico" &&- customEditorTheme.customCss && (+ {!isNamedEditorTheme(editorTheme) && customEditorTheme.customCss && (<styledata-theme-custom-cssdata-original-css={customEditorTheme.customCss}diff --git a/apps/web/src/components/ThemeProvider.tsx b/apps/web/src/components/ThemeProvider.tsxindex d8bcb458..e7a71f6b 100644--- a/apps/web/src/components/ThemeProvider.tsx+++ b/apps/web/src/components/ThemeProvider.tsx@@ -98,6 +98,10 @@ export const isMarkdownLightTheme = (theme: MarkdownThemeName): boolean =>export const EDITOR_THEME_NAMES = ["default",+ "letter",+ "guide",+ "blueprint",+ "journal","minimal-emerald","outline-emerald","wechat-green",@@ -107,6 +111,9 @@ export const EDITOR_THEME_NAMES = [] as const;export type EditorThemeName = string;+export const isNamedEditorTheme = (theme: string) =>+ (EDITOR_THEME_NAMES as readonly string[]).includes(theme) && theme !== "custom";+interface AppearanceThemeContextValue {preference: ThemePreference;resolvedTheme: ResolvedTheme;diff --git a/apps/web/src/components/settings/PreferenceCard.test.mjs b/apps/web/src/components/settings/PreferenceCard.test.mjsindex 6048ffe8..96ce7d58 100644--- a/apps/web/src/components/settings/PreferenceCard.test.mjs+++ b/apps/web/src/components/settings/PreferenceCard.test.mjs@@ -24,6 +24,19 @@ describe("appearance preference", () => {});});+describe("paper editor themes", () => {+ test("offers letter, guide, blueprint, and journal as editor themes", () => {+ const preferenceCard = readFileSync(new URL("./PreferenceCard.tsx", import.meta.url), "utf8");++ expect(preferenceCard).not.toContain('t("settings.publishLayoutTitle")');+ expect(preferenceCard).toContain('value="letter"');+ expect(preferenceCard).toContain('t("settings.editorThemes.letter")');+ expect(preferenceCard).toContain('t("settings.editorThemes.guide")');+ expect(preferenceCard).toContain('t("settings.editorThemes.blueprint")');+ expect(preferenceCard).toContain('t("settings.editorThemes.journal")');+ });+});+describe("custom editor theme portability", () => {test("offers import and export while keeping contrast as a warning", () => {const dialog = readFileSync(new URL("./CustomEditorThemeDialog.tsx", import.meta.url), "utf8");diff --git a/apps/web/src/components/settings/PreferenceCard.tsx b/apps/web/src/components/settings/PreferenceCard.tsxindex ddfaf70a..ed02ad93 100644--- a/apps/web/src/components/settings/PreferenceCard.tsx+++ b/apps/web/src/components/settings/PreferenceCard.tsx@@ -48,6 +48,7 @@ import {useMermaidTheme,DEFAULT_CUSTOM_LIGHT_COLORS,DEFAULT_CUSTOM_DARK_COLORS,+ isNamedEditorTheme,type CustomEditorTheme,type ThemePreference,} from "../ThemeProvider";@@ -150,7 +151,7 @@ export const PreferenceCard = ({}, []);const activeCustom = customEditorThemes.find((t) => t.id === editorTheme);- const isPreset = editorTheme === "default" || editorTheme === "minimal-emerald" || editorTheme === "outline-emerald" || editorTheme === "wechat-green" || editorTheme === "modern-mint" || editorTheme === "marxico";+ const isPreset = isNamedEditorTheme(editorTheme);const handleEditClick = () => {if (activeCustom) {@@ -309,6 +310,10 @@ export const PreferenceCard = ({</SelectTrigger><SelectContent><SelectItem value="default">{t("settings.editorThemes.default")}</SelectItem>+ <SelectItem value="letter">{t("settings.editorThemes.letter")}</SelectItem>+ <SelectItem value="guide">{t("settings.editorThemes.guide")}</SelectItem>+ <SelectItem value="blueprint">{t("settings.editorThemes.blueprint")}</SelectItem>+ <SelectItem value="journal">{t("settings.editorThemes.journal")}</SelectItem><SelectItem value="minimal-emerald">{t("settings.editorThemes.minimal-emerald")}</SelectItem><SelectItem value="outline-emerald">{t("settings.editorThemes.outline-emerald")}</SelectItem><SelectItem value="wechat-green">{t("settings.editorThemes.wechat-green")}</SelectItem>diff --git a/apps/web/src/lib/publish-layout.test.mjs b/apps/web/src/lib/publish-layout.test.mjsnew file mode 100644index 00000000..b644a7b8--- /dev/null+++ b/apps/web/src/lib/publish-layout.test.mjs@@ -0,0 +1,102 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";+import {+ DEFAULT_PUBLISH_LAYOUT,+ DEFAULT_PUBLISH_PALETTE,+ PUBLISH_LAYOUT_IDS,+ PUBLISH_LAYOUT_RHYTHM,+ PUBLISH_PALETTE_IDS,+ PUBLISH_PALETTES,+ assertWeChatSafeCss,+ buildPublishStyles,+ collectPublishStyleText,+ formatChapterIndex,+ planHeadingDecoration,+ publishEditorCssVars,+ resolvePaperEditorTheme,+ resolveStoredPublishLayout,+ resolveStoredPublishPalette,+} from "./publish-layout.ts";++describe("publish layout catalog", () => {+ test("keeps four original skeletons and eight palettes", () => {+ expect(PUBLISH_LAYOUT_IDS).toEqual(["letter", "guide", "blueprint", "journal"]);+ expect(PUBLISH_PALETTE_IDS).toHaveLength(8);+ expect(DEFAULT_PUBLISH_LAYOUT).toBe("letter");+ expect(DEFAULT_PUBLISH_PALETTE).toBe("emerald");+ expect(PUBLISH_PALETTES.emerald.accent).toBe("#16A06E");+ });++ test("maps paper editor themes to a fixed layout and palette", () => {+ expect(resolvePaperEditorTheme("letter")).toEqual({ layout: "letter", palette: "dawn" });+ expect(resolvePaperEditorTheme("guide")).toEqual({ layout: "guide", palette: "emerald" });+ expect(resolvePaperEditorTheme("default")).toBeNull();+ });++ test("falls back to defaults for unknown stored values", () => {+ expect(resolveStoredPublishLayout(null)).toBe("letter");+ expect(resolveStoredPublishLayout("sunlit-ledger")).toBe("letter");+ expect(resolveStoredPublishPalette("morning-cream")).toBe("emerald");+ expect(resolveStoredPublishPalette("dawn")).toBe("dawn");+ });++ test("numbers letter and blueprint chapters without CSS counters", () => {+ expect(formatChapterIndex(0)).toBe("01");+ expect(planHeadingDecoration("h2", "letter", 0)).toEqual({ kind: "chapter", chapterLabel: "01" });+ expect(planHeadingDecoration("h2", "blueprint", 1)).toEqual({ kind: "chapter", chapterLabel: "02" });+ expect(planHeadingDecoration("h2", "guide", 0)).toEqual({ kind: "none" });+ expect(planHeadingDecoration("h1", "letter", 0)).toEqual({ kind: "title" });+ });+});++describe("publish layout CSS", () => {+ test("uses a looser reading rhythm than the note editor contract", () => {+ const letter = buildPublishStyles("letter", PUBLISH_PALETTES.emerald);+ const guide = buildPublishStyles("guide", PUBLISH_PALETTES.emerald);++ expect(letter.p).toContain("line-height: 1.9");+ expect(letter.p).toContain("margin: 0 0 24px");+ expect(letter.h1).toContain("text-align: center");+ expect(guide.h2).toContain("border-left: 4px solid #16A06E");+ expect(letter.blockquote).toContain("border-radius: 12px");+ expect(letter.strong).toContain("color: #16A06E");+ });++ test("keeps WeChat-safe inline CSS for every layout and palette", () => {+ for (const layout of PUBLISH_LAYOUT_IDS) {+ for (const paletteId of PUBLISH_PALETTE_IDS) {+ const css = collectPublishStyleText(buildPublishStyles(layout, PUBLISH_PALETTES[paletteId]));+ expect(assertWeChatSafeCss(css)).toBe(true);+ }+ }+ });+});++describe("copy pipeline wiring", () => {+ test("wechat copy follows paper editor themes and keeps compact copy for other themes", () => {+ const source = readFileSync(new URL("./wechat-copy.ts", import.meta.url), "utf8");+ const preferenceCard = readFileSync(new URL("../components/settings/PreferenceCard.tsx", import.meta.url), "utf8");++ expect(source).toContain("resolvePaperEditorTheme");+ expect(source).toContain("applyPublishLayout");+ expect(source).toContain("MEMO_CONTENT_STYLE");+ expect(preferenceCard).not.toContain('t("settings.publishLayoutTitle")');+ expect(preferenceCard).toContain('t("settings.editorThemes.letter")');+ });++ test("drives the rich editor rhythm from paper editor themes", () => {+ const editorPane = readFileSync(new URL("../components/EditorPane.tsx", import.meta.url), "utf8");+ const css = readFileSync(new URL("../styles/publish-layout.css", import.meta.url), "utf8");+ const vars = publishEditorCssVars("letter", "dawn");++ expect(PUBLISH_LAYOUT_RHYTHM.letter.lineHeight).toBe("1.9");+ expect(PUBLISH_LAYOUT_RHYTHM.letter.paragraphSpacing).toBe("24px");+ expect(vars["--editor-body-line-height"]).toBe("1.9");+ expect(vars["--publish-accent"]).toBe("#C49A3C");+ expect(editorPane).toContain("isPaperEditorTheme(editorTheme)");+ expect(editorPane).toContain("publishEditorCssVars");+ expect(css).toContain("counter-increment: publish-h2");+ expect(css).toContain('[data-editor-theme="letter"]');+ expect(css).not.toMatch(/\.ProseMirror p\s*\{[^}]*line-height\s*:/);+ });+});diff --git a/apps/web/src/lib/publish-layout.ts b/apps/web/src/lib/publish-layout.tsnew file mode 100644index 00000000..19bedf17--- /dev/null+++ b/apps/web/src/lib/publish-layout.ts@@ -0,0 +1,641 @@+export const PAPER_EDITOR_THEME_IDS = ["letter", "guide", "blueprint", "journal"] as const;+export type PublishLayoutId = (typeof PAPER_EDITOR_THEME_IDS)[number];+export const PUBLISH_LAYOUT_IDS = PAPER_EDITOR_THEME_IDS;++export const PUBLISH_PALETTE_IDS = [+ "emerald",+ "ink",+ "dawn",+ "clay",+ "navy",+ "slate",+ "plum",+ "forest",+] as const;+export type PublishPaletteId = (typeof PUBLISH_PALETTE_IDS)[number];++export const DEFAULT_PUBLISH_LAYOUT: PublishLayoutId = "letter";+export const DEFAULT_PUBLISH_PALETTE: PublishPaletteId = "emerald";++export const PAPER_EDITOR_THEME_PALETTES = {+ letter: "dawn",+ guide: "emerald",+ blueprint: "navy",+ journal: "slate",+} as const satisfies Record<PublishLayoutId, PublishPaletteId>;++export const isPaperEditorTheme = (value: string | null | undefined): value is PublishLayoutId =>+ Boolean(value && (PAPER_EDITOR_THEME_IDS as readonly string[]).includes(value));++export const resolvePaperEditorTheme = (theme: string | null | undefined) => {+ if (!isPaperEditorTheme(theme)) return null;+ return { layout: theme, palette: PAPER_EDITOR_THEME_PALETTES[theme] };+};++export const PUBLISH_LAYOUT_STORAGE_KEY = "edgeever.publish-layout";+export const PUBLISH_PALETTE_STORAGE_KEY = "edgeever.publish-palette";+export const PUBLISH_LAYOUT_CHANGED_EVENT = "edgeever:publish-layout-changed";++export type PublishPalette = {+ id: PublishPaletteId;+ accent: string;+ accentSoft: string;+ accentBorder: string;+ text: string;+ textStrong: string;+ textMuted: string;+ surface: string;+ divider: string;+ link: string;+ codeBg: string;+ codeText: string;+ bg: string;+};++export const PUBLISH_PALETTES: Record<PublishPaletteId, PublishPalette> = {+ emerald: {+ id: "emerald",+ accent: "#16A06E",+ accentSoft: "#E8F6F0",+ accentBorder: "#B7E0CC",+ text: "#2C3A34",+ textStrong: "#14241C",+ textMuted: "#5C6F66",+ surface: "#F4FBF7",+ divider: "#D7EBE1",+ link: "#0F7A54",+ codeBg: "#F3F7F5",+ codeText: "#0F7A54",+ bg: "#FFFFFF",+ },+ ink: {+ id: "ink",+ accent: "#1A5C4A",+ accentSoft: "#E7F2EE",+ accentBorder: "#B5D2C8",+ text: "#24332E",+ textStrong: "#12201B",+ textMuted: "#5A6C65",+ surface: "#F3F8F6",+ divider: "#D3E3DD",+ link: "#164C3E",+ codeBg: "#EEF4F1",+ codeText: "#164C3E",+ bg: "#FFFFFF",+ },+ dawn: {+ id: "dawn",+ accent: "#C49A3C",+ accentSoft: "#FBF6EA",+ accentBorder: "#E8D7A8",+ text: "#3D3426",+ textStrong: "#2A2418",+ textMuted: "#7A6E58",+ surface: "#FFFCF6",+ divider: "#EFE3C8",+ link: "#8A6420",+ codeBg: "#FBF6EA",+ codeText: "#8A6420",+ bg: "#FFFFFF",+ },+ clay: {+ id: "clay",+ accent: "#C45C3E",+ accentSoft: "#FBEFEA",+ accentBorder: "#E8C4B6",+ text: "#3D2E29",+ textStrong: "#271C18",+ textMuted: "#7A635B",+ surface: "#FDF8F6",+ divider: "#EEDDD6",+ link: "#9A3E28",+ codeBg: "#F8EEE9",+ codeText: "#9A3E28",+ bg: "#FFFFFF",+ },+ navy: {+ id: "navy",+ accent: "#3B6B9A",+ accentSoft: "#EAF1F8",+ accentBorder: "#B7C9DC",+ text: "#2C3640",+ textStrong: "#162029",+ textMuted: "#5C6A78",+ surface: "#F5F8FB",+ divider: "#D7E1EB",+ link: "#2A5278",+ codeBg: "#EEF3F8",+ codeText: "#2A5278",+ bg: "#FFFFFF",+ },+ slate: {+ id: "slate",+ accent: "#5A6B73",+ accentSoft: "#EEF1F2",+ accentBorder: "#C5CED2",+ text: "#2F373B",+ textStrong: "#1A2023",+ textMuted: "#66747B",+ surface: "#F7F8F9",+ divider: "#DEE3E6",+ link: "#3E4C53",+ codeBg: "#F0F2F3",+ codeText: "#3E4C53",+ bg: "#FFFFFF",+ },+ plum: {+ id: "plum",+ accent: "#7A4E6E",+ accentSoft: "#F5EEF3",+ accentBorder: "#D4BCCB",+ text: "#3A2E36",+ textStrong: "#241820",+ textMuted: "#746068",+ surface: "#FBF7F9",+ divider: "#E8D7E0",+ link: "#5E3A54",+ codeBg: "#F4ECF1",+ codeText: "#5E3A54",+ bg: "#FFFFFF",+ },+ forest: {+ id: "forest",+ accent: "#4A7C4E",+ accentSoft: "#EAF3EB",+ accentBorder: "#BDD4BF",+ text: "#2E3A2F",+ textStrong: "#172017",+ textMuted: "#5E6E5F",+ surface: "#F5F9F5",+ divider: "#D6E4D7",+ link: "#37633B",+ codeBg: "#EEF4EE",+ codeText: "#37633B",+ bg: "#FFFFFF",+ },+};++export const isPublishLayoutId = (value: string | null | undefined): value is PublishLayoutId =>+ Boolean(value && (PUBLISH_LAYOUT_IDS as readonly string[]).includes(value));++export const isPublishPaletteId = (value: string | null | undefined): value is PublishPaletteId =>+ Boolean(value && (PUBLISH_PALETTE_IDS as readonly string[]).includes(value));++export const resolveStoredPublishLayout = (stored: string | null): PublishLayoutId =>+ isPublishLayoutId(stored) ? stored : DEFAULT_PUBLISH_LAYOUT;++export const resolveStoredPublishPalette = (stored: string | null): PublishPaletteId =>+ isPublishPaletteId(stored) ? stored : DEFAULT_PUBLISH_PALETTE;++const readStorage = (key: string): string | null => {+ if (typeof window === "undefined") return null;+ try {+ return window.localStorage?.getItem(key) ?? null;+ } catch {+ return null;+ }+};++const writeStorage = (key: string, value: string) => {+ if (typeof window === "undefined") return;+ try {+ window.localStorage?.setItem(key, value);+ } catch {+ // Private mode / blocked storage — preference stays session-only via the event.+ }+};++export const readPublishLayoutPreference = (): PublishLayoutId =>+ resolveStoredPublishLayout(readStorage(PUBLISH_LAYOUT_STORAGE_KEY));++export const readPublishPalettePreference = (): PublishPaletteId =>+ resolveStoredPublishPalette(readStorage(PUBLISH_PALETTE_STORAGE_KEY));++const notifyPublishLayoutChanged = () => {+ if (typeof window === "undefined") return;+ window.dispatchEvent(new Event(PUBLISH_LAYOUT_CHANGED_EVENT));+};++export const writePublishLayoutPreference = (layout: PublishLayoutId) => {+ writeStorage(PUBLISH_LAYOUT_STORAGE_KEY, layout);+ notifyPublishLayoutChanged();+};++export const writePublishPalettePreference = (palette: PublishPaletteId) => {+ writeStorage(PUBLISH_PALETTE_STORAGE_KEY, palette);+ notifyPublishLayoutChanged();+};++export const formatChapterIndex = (index: number) => String(index + 1).padStart(2, "0");++export type PublishHeadingKind = "title" | "chapter" | "small" | "none";++export const planHeadingDecoration = (+ tag: string,+ layout: PublishLayoutId,+ chapterIndex: number,+): { kind: PublishHeadingKind; chapterLabel?: string } => {+ if (tag === "h1") return { kind: "title" };+ if (tag === "h3") return { kind: "small" };+ if (tag === "h2" && (layout === "letter" || layout === "blueprint")) {+ return { kind: "chapter", chapterLabel: formatChapterIndex(chapterIndex) };+ }+ return { kind: "none" };+};++export type PublishRhythm = {+ fontSize: string;+ lineHeight: string;+ paragraphSpacing: string;+ headingAlign: "left" | "center";+};++export const PUBLISH_LAYOUT_RHYTHM: Record<PublishLayoutId, PublishRhythm> = {+ letter: { fontSize: "15px", lineHeight: "1.9", paragraphSpacing: "24px", headingAlign: "center" },+ guide: { fontSize: "15px", lineHeight: "1.8", paragraphSpacing: "16px", headingAlign: "left" },+ blueprint: { fontSize: "16px", lineHeight: "1.8", paragraphSpacing: "20px", headingAlign: "left" },+ journal: { fontSize: "16px", lineHeight: "1.9", paragraphSpacing: "26px", headingAlign: "left" },+};++export const publishEditorCssVars = (+ layout: PublishLayoutId,+ paletteId: PublishPaletteId,+): Record<string, string> => {+ const rhythm = PUBLISH_LAYOUT_RHYTHM[layout] ?? PUBLISH_LAYOUT_RHYTHM[DEFAULT_PUBLISH_LAYOUT];+ const palette = PUBLISH_PALETTES[paletteId] ?? PUBLISH_PALETTES[DEFAULT_PUBLISH_PALETTE];+ return {+ "--editor-body-font-size": rhythm.fontSize,+ "--editor-body-line-height": rhythm.lineHeight,+ "--editor-paragraph-spacing": rhythm.paragraphSpacing,+ "--publish-accent": palette.accent,+ "--publish-accent-soft": palette.accentSoft,+ "--publish-accent-border": palette.accentBorder,+ "--publish-text": palette.text,+ "--publish-text-strong": palette.textStrong,+ "--publish-text-muted": palette.textMuted,+ "--publish-surface": palette.surface,+ "--publish-divider": palette.divider,+ "--publish-link": palette.link,+ "--publish-code-bg": palette.codeBg,+ "--publish-code-text": palette.codeText,+ "--publish-bg": palette.bg,+ };+};++const css = (declarations: Record<string, string | undefined>) =>+ Object.entries(declarations)+ .filter((entry): entry is [string, string] => typeof entry[1] === "string" && entry[1].length > 0)+ .map(([property, value]) => `${property}: ${value}`)+ .join("; ");++export type PublishTagStyles = Record<string, string>;++export const buildPublishStyles = (+ layout: PublishLayoutId,+ palette: PublishPalette,+): PublishTagStyles => {+ const rhythm = PUBLISH_LAYOUT_RHYTHM[layout];+ const align = rhythm.headingAlign;+ const h1AlignRules =+ layout === "letter"+ ? {+ "text-align": "center",+ "border-bottom": `3px solid ${palette.accent}`,+ "padding-bottom": "10px",+ }+ : layout === "blueprint"+ ? {+ "text-align": "left",+ "border-top": `3px solid ${palette.accent}`,+ "padding-top": "10px",+ }+ : { "text-align": align };++ const h2Rules =+ layout === "guide" || layout === "blueprint"+ ? {+ "border-left": `4px solid ${palette.accent}`,+ "padding-left": "12px",+ }+ : layout === "journal"+ ? {+ "border-bottom": `1px solid ${palette.divider}`,+ "padding-bottom": "8px",+ }+ : {};++ const h3Rules =+ layout === "letter"+ ? {+ "text-align": "center",+ "border-bottom": `2px solid ${palette.accentBorder}`,+ "padding-bottom": "8px",+ }+ : layout === "blueprint"+ ? {+ "border-bottom": `2px solid ${palette.accent}`,+ "padding-bottom": "6px",+ }+ : {};++ const quoteRules =+ layout === "letter"+ ? {+ margin: "0 0 28px",+ padding: "16px 18px",+ border: `1px solid ${palette.accentBorder}`,+ "border-radius": "12px",+ background: palette.surface,+ color: palette.textMuted,+ }+ : layout === "journal"+ ? {+ margin: "0 0 28px",+ padding: "4px 0 4px 16px",+ "border-left": `2px solid ${palette.divider}`,+ background: "transparent",+ color: palette.textMuted,+ "font-style": "italic",+ }+ : {+ margin: "0 0 24px",+ padding: "12px 16px",+ "border-left": `4px solid ${palette.accent}`,+ background: palette.accentSoft,+ color: palette.textMuted,+ };++ return {+ root: css({+ "font-family": "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif",+ "font-size": rhythm.fontSize,+ "line-height": rhythm.lineHeight,+ color: palette.text,+ "background-color": palette.bg,+ "word-break": "break-word",+ }),+ p: css({+ margin: `0 0 ${rhythm.paragraphSpacing}`,+ padding: "0",+ "line-height": rhythm.lineHeight,+ "font-size": rhythm.fontSize,+ color: palette.text,+ }),+ h1: css({+ margin: "0 0 24px",+ "font-size": layout === "journal" ? "26px" : "24px",+ "line-height": "1.35",+ "font-weight": "800",+ color: palette.textStrong,+ ...h1AlignRules,+ }),+ h2: css({+ margin: "28px 0 16px",+ "font-size": "20px",+ "line-height": "1.4",+ "font-weight": "700",+ color: palette.textStrong,+ "text-align": "left",+ ...h2Rules,+ }),+ h3: css({+ margin: "24px 0 12px",+ "font-size": layout === "letter" ? "15px" : "16px",+ "line-height": "1.45",+ "font-weight": "700",+ color: palette.textStrong,+ ...h3Rules,+ }),+ blockquote: css({+ "line-height": rhythm.lineHeight,+ ...quoteRules,+ }),+ ul: css({+ margin: "0 0 1em",+ "padding-left": "1.6em",+ "line-height": rhythm.lineHeight,+ color: palette.text,+ }),+ ol: css({+ margin: "0 0 1em",+ "padding-left": "1.6em",+ "line-height": rhythm.lineHeight,+ color: palette.text,+ }),+ li: css({+ margin: "0.25em 0",+ "line-height": rhythm.lineHeight,+ color: palette.text,+ }),+ a: css({+ color: palette.link,+ "text-decoration": "underline",+ }),+ strong: css({+ "font-weight": "700",+ color: palette.accent,+ }),+ em: css({+ "font-style": "italic",+ color: palette.textMuted,+ }),+ del: css({+ "text-decoration": "line-through",+ color: palette.textMuted,+ }),+ code: css({+ padding: "0.15em 0.35em",+ "border-radius": "3px",+ background: palette.codeBg,+ color: palette.codeText,+ "font-family": "Menlo, Consolas, monospace",+ "font-size": "0.9em",+ }),+ pre: css({+ margin: "1em 0",+ padding: "12px 14px",+ overflow: "hidden",+ "border-radius": "6px",+ background: palette.codeBg,+ color: palette.text,+ "line-height": "1.6",+ "text-align": "left",+ border: `1px solid ${palette.accentBorder}`,+ }),+ hr: css({+ margin: "28px auto",+ border: "0",+ "border-top": `1px solid ${palette.divider}`,+ width: layout === "letter" ? "42%" : "100%",+ }),+ table: css({+ width: "100%",+ margin: "1em 0",+ "border-collapse": "collapse",+ "font-size": "14px",+ "line-height": "1.6",+ }),+ th: css({+ padding: "8px",+ border: `1px solid ${palette.accentBorder}`,+ background: palette.accentSoft,+ "font-weight": "700",+ "text-align": "left",+ color: palette.textStrong,+ }),+ td: css({+ padding: "8px",+ border: `1px solid ${palette.divider}`,+ "text-align": "left",+ color: palette.text,+ }),+ img: css({+ display: "block",+ "max-width": "100%",+ height: "auto",+ margin: "1em auto",+ }),+ };+};++const THEME_BLOCK_LABELS: Record<string, string> = {+ intro: "引言",+ "key-point": "重点观点",+ callout: "提示",+ chapter: "章节",+};++const themeBlockStyles = (kind: string, palette: PublishPalette, layout: PublishLayoutId) => {+ const label = `padding: 10px 14px 0; color: ${palette.accent}; font-size: 12px; font-weight: 700; letter-spacing: 1px; margin: 0;`;+ if (kind === "chapter") {+ return {+ block: `margin: 28px 0 16px; padding: 0 0 4px; border-top: 3px solid ${palette.accent}; color: ${palette.textStrong};`,+ label: `padding: 10px 0 0; color: ${palette.accent}; font-size: 12px; font-weight: 700; letter-spacing: 2px; margin: 0;`,+ };+ }+ if (layout === "letter" || kind === "key-point") {+ return {+ block: `margin: 20px 0; padding: 0 0 4px; border: 1px solid ${palette.accentBorder}; border-radius: 12px; background: ${palette.surface}; color: ${palette.text};`,+ label,+ };+ }+ if (kind === "callout") {+ return {+ block: `margin: 20px 0; padding: 0 0 4px; border: 1px dashed ${palette.accentBorder}; background: ${palette.accentSoft}; color: ${palette.text};`,+ label,+ };+ }+ return {+ block: `margin: 20px 0; padding: 0 0 4px; border-left: 5px solid ${palette.accent}; background: ${palette.accentSoft}; color: ${palette.text};`,+ label,+ };+};++const isChromeElement = (element: HTMLElement) => element.getAttribute("data-ee-publish-chrome") === "true";++const wrapHeading = (heading: HTMLElement) => {+ if (heading.parentElement?.getAttribute("data-ee-publish-heading")) {+ return heading.parentElement;+ }+ const document = heading.ownerDocument;+ const wrapper = document.createElement("section");+ wrapper.setAttribute("data-ee-publish-heading", heading.tagName.toLowerCase());+ heading.parentNode?.insertBefore(wrapper, heading);+ wrapper.appendChild(heading);+ return wrapper;+};++const decorateHeadings = (root: HTMLElement, layout: PublishLayoutId, palette: PublishPalette) => {+ const headings = Array.from(root.querySelectorAll<HTMLElement>("h1, h2, h3")).filter((heading) => {+ if (heading.closest("table, pre, [data-edgeever-theme-block]")) return false;+ if (heading.closest("[data-ee-publish-heading]")) return false;+ return true;+ });++ let chapterIndex = 0;+ for (const heading of headings) {+ const tag = heading.tagName.toLowerCase();+ const plan = planHeadingDecoration(tag, layout, chapterIndex);+ if (plan.kind === "chapter") chapterIndex += 1;+ if (plan.kind !== "chapter" || !plan.chapterLabel) continue;++ const wrapper = wrapHeading(heading);+ wrapper.style.cssText = "margin: 0; padding: 0;";+ const label = heading.ownerDocument.createElement("p");+ label.setAttribute("data-ee-publish-chrome", "true");+ label.textContent = plan.chapterLabel;+ label.style.cssText = css({+ margin: "28px 0 0",+ padding: "0",+ color: palette.accent,+ "font-size": layout === "letter" ? "28px" : "13px",+ "line-height": "1.1",+ "font-weight": "700",+ "font-style": layout === "letter" ? "italic" : "normal",+ "letter-spacing": layout === "blueprint" ? "0.12em" : "0",+ });+ wrapper.insertBefore(label, heading);+ heading.style.margin = "6px 0 16px";+ }+};++const applyThemeBlocks = (root: HTMLElement, layout: PublishLayoutId, palette: PublishPalette) => {+ root.querySelectorAll<HTMLElement>("[data-edgeever-theme-block]").forEach((block) => {+ const kind = block.getAttribute("data-theme-block-kind") || "intro";+ const styles = themeBlockStyles(kind, palette, layout);+ block.style.cssText = `${styles.block}${block.style.cssText}`;+ const label = root.ownerDocument.createElement("p");+ label.setAttribute("data-ee-publish-chrome", "true");+ label.textContent = THEME_BLOCK_LABELS[kind] || "主题组件";+ label.style.cssText = styles.label;+ block.insertBefore(label, block.firstChild);+ });+};++export const collectPublishStyleText = (styles: PublishTagStyles) => Object.values(styles).join(" ");++export const assertWeChatSafeCss = (source: string) => {+ const forbidden = [+ /var\s*\(/i,+ /\bdisplay\s*:\s*flex\b/i,+ /\bdisplay\s*:\s*grid\b/i,+ /\bposition\s*:\s*(absolute|fixed|sticky)\b/i,+ /::?(?:before|after)\b/i,+ /url\s*\(/i,+ ];+ return forbidden.every((pattern) => !pattern.test(source));+};++export const applyPublishLayout = (+ root: HTMLElement,+ layout: PublishLayoutId = readPublishLayoutPreference(),+ paletteId: PublishPaletteId = readPublishPalettePreference(),+) => {+ const palette = PUBLISH_PALETTES[paletteId] ?? PUBLISH_PALETTES[DEFAULT_PUBLISH_PALETTE];+ const styles = buildPublishStyles(layout, palette);+ root.style.cssText = styles.root;++ root.querySelectorAll<HTMLElement>("*").forEach((element) => {+ if (isChromeElement(element)) return;+ if (element.closest("pre") && element.tagName.toLowerCase() !== "pre") return;+ const tagName = element.tagName.toLowerCase();+ const style = styles[tagName];+ if (style) element.style.cssText = `${style}${element.style.cssText}`;+ });++ root.querySelectorAll<HTMLElement>("pre code").forEach((element) => {+ element.style.cssText =+ "padding: 0; background: transparent; color: inherit; font-family: Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap;";+ });++ root.querySelectorAll<HTMLElement>("hr[data-edgeever-merge-divider], hr.edgeever-merge-divider").forEach((divider) => {+ divider.style.cssText = css({+ margin: "1.75em 0",+ border: "0",+ "border-top": `2px solid ${palette.accent}`,+ });+ });++ decorateHeadings(root, layout, palette);+ applyThemeBlocks(root, layout, palette);+};diff --git a/apps/web/src/lib/wechat-copy.ts b/apps/web/src/lib/wechat-copy.tsindex 24823956..07a6cab3 100644--- a/apps/web/src/lib/wechat-copy.ts+++ b/apps/web/src/lib/wechat-copy.ts@@ -4,6 +4,7 @@ import { marked } from "marked";import { MERMAID_THEME_PALETTES } from "@/components/ThemeProvider";import { copyHtmlToClipboard } from "@/lib/clipboard";import { parseCustomCssToStyles } from "@/lib/css-sandbox";+import { applyPublishLayout, resolvePaperEditorTheme } from "@/lib/publish-layout";const BODY_LINE_HEIGHT = MEMO_CONTENT_STYLE.body.lineHeight / MEMO_CONTENT_STYLE.body.fontSize;const BODY_FONT_SIZE = `${MEMO_CONTENT_STYLE.body.fontSize}px`;@@ -31,37 +32,9 @@ const WECHAT_STYLES: Record<string, string> = {img: "display: block; max-width: 100%; height: auto; margin: 1em auto;",};-const THEME_BLOCK_LABELS: Record<string, string> = {- intro: "引言",- "key-point": "重点观点",- callout: "提示",- chapter: "章节",-};--const THEME_BLOCK_STYLES: Record<string, { block: string; label: string }> = {- intro: {- block: "margin: 20px 0; padding: 0 0 4px; border-left: 5px solid #059669; background: #f0fdf4; color: #374151;",- label: "padding: 10px 14px 0; color: #059669; font-size: 12px; font-weight: 700; letter-spacing: 1px;",- },- "key-point": {- block: "margin: 20px 0; padding: 0 0 4px; border: 1px solid #a7f3d0; border-radius: 8px; background: #f0fdf4; color: #374151;",- label: "padding: 10px 14px 0; color: #047857; font-size: 12px; font-weight: 700; letter-spacing: 1px;",- },- callout: {- block: "margin: 20px 0; padding: 0 0 4px; border: 1px dashed #6ee7b7; background: #ecfdf5; color: #374151;",- label: "padding: 10px 14px 0; color: #059669; font-size: 12px; font-weight: 700; letter-spacing: 1px;",- },- chapter: {- block: "margin: 28px 0 16px; padding: 0 0 4px; border-top: 3px solid #059669; color: #111827;",- label: "padding: 10px 0 0; color: #059669; font-size: 12px; font-weight: 700; letter-spacing: 2px;",- },-};--const applyInlineStyles = (+const applyLegacyWeChatStyles = (root: HTMLElement,- editorTheme?: string,customColors?: { bg: string; text: string; accent: string; soft: string; codeBackground: string; border: string } | null,- customCss?: string) => {const textColor = customColors ? customColors.text : "#333";const bgColors = customColors ? customColors.bg : "#ffffff";@@ -70,8 +43,6 @@ const applyInlineStyles = (const codeBackground = customColors ? customColors.codeBackground : "#f6f8fa";const border = customColors ? customColors.border : "#e5e7eb";- const customStyles = customCss ? parseCustomCssToStyles(customCss) : null;-root.style.cssText = `font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: ${BODY_FONT_SIZE}; line-height: ${BODY_LINE_HEIGHT}; color: ${textColor}; background-color: ${bgColors}; word-break: break-word;`;root.querySelectorAll<HTMLElement>("*").forEach((element) => {@@ -104,59 +75,34 @@ const applyInlineStyles = (}}- if (customStyles && customStyles[tagName]) {- style = `${style} ${customStyles[tagName]}`;- }-if (style) element.style.cssText = `${style}${element.style.cssText}`;});- root.querySelectorAll<HTMLElement>("p").forEach((paragraph) => {- paragraph.style.margin = `0 0 ${PARAGRAPH_SPACING}`;- paragraph.style.padding = "0";- paragraph.style.lineHeight = String(BODY_LINE_HEIGHT);- });-- root.querySelectorAll<HTMLElement>("ul, ol, li, blockquote").forEach((bodyBlock) => {- bodyBlock.style.lineHeight = String(BODY_LINE_HEIGHT);- });-root.querySelectorAll<HTMLElement>("pre code").forEach((element) => {element.style.cssText = "padding: 0; background: transparent; color: inherit; font-family: Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap;";});+};- root.querySelectorAll<HTMLElement>("[data-edgeever-theme-block]").forEach((block) => {- const kind = block.getAttribute("data-theme-block-kind") || "intro";- const themeStyles = THEME_BLOCK_STYLES[kind] || THEME_BLOCK_STYLES.intro;-- let blockStyle = themeStyles.block;- let labelStyle = themeStyles.label;-- if (customColors) {- if (kind === "intro") {- blockStyle = `margin: 20px 0; padding: 0 0 4px; border-left: 5px solid ${accent}; background: ${soft}; color: ${textColor};`;- labelStyle = `padding: 10px 14px 0; color: ${accent}; font-size: 12px; font-weight: 700; letter-spacing: 1px;`;- } else if (kind === "key-point") {- blockStyle = `margin: 20px 0; padding: 0 0 4px; border: 1px solid ${border}; border-radius: 8px; background: ${soft}; color: ${textColor};`;- labelStyle = `padding: 10px 14px 0; color: ${accent}; font-size: 12px; font-weight: 700; letter-spacing: 1px;`;- } else if (kind === "callout") {- blockStyle = `margin: 20px 0; padding: 0 0 4px; border: 1px dashed ${border}; background: ${soft}; color: ${textColor};`;- labelStyle = `padding: 10px 14px 0; color: ${accent}; font-size: 12px; font-weight: 700; letter-spacing: 1px;`;- } else if (kind === "chapter") {- blockStyle = `margin: 28px 0 16px; padding: 0 0 4px; border-top: 3px solid ${accent}; color: ${textColor};`;- labelStyle = `padding: 10px 0 0; color: ${accent}; font-size: 12px; font-weight: 700; letter-spacing: 2px;`;- }- } else {- blockStyle = `${blockStyle} border-left-color: ${accent};`;- labelStyle = `${labelStyle} color: ${accent};`;- }+const applyInlineStyles = (+ root: HTMLElement,+ editorTheme?: string,+ customColors?: { bg: string; text: string; accent: string; soft: string; codeBackground: string; border: string } | null,+ customCss?: string,+) => {+ const paperTheme = resolvePaperEditorTheme(editorTheme);+ if (paperTheme) {+ applyPublishLayout(root, paperTheme.layout, paperTheme.palette);+ } else {+ applyLegacyWeChatStyles(root, customColors);+ }- block.style.cssText = `${blockStyle}${block.style.cssText}`;+ const customStyles = customCss ? parseCustomCssToStyles(customCss) : null;+ if (!customStyles) return;- const label = document.createElement("p");- label.textContent = THEME_BLOCK_LABELS[kind] || "主题组件";- label.style.cssText = `${labelStyle} margin: 0;`;- block.insertBefore(label, block.firstChild);+ root.querySelectorAll<HTMLElement>("*").forEach((element) => {+ if (element.getAttribute("data-ee-publish-chrome") === "true") return;+ const extra = customStyles[element.tagName.toLowerCase()];+ if (extra) element.style.cssText = `${element.style.cssText}; ${extra}`;});};@@ -397,13 +343,10 @@ const convertImageGalleriesForWeChat = (root: HTMLElement) => {});};-export const buildWeChatClipboardHtml = async (editor: Editor) => {- const container = document.createElement("div");- container.innerHTML = editor.getHTML();-- const closestContainer = editor.view.dom.closest<HTMLElement>("[data-editor-theme]");+const readEditorCopyContext = (from?: HTMLElement | null) => {+ const closestContainer = from?.closest<HTMLElement>("[data-editor-theme]")+ ?? document.querySelector<HTMLElement>("[data-editor-theme]");const editorTheme = closestContainer?.dataset.editorTheme;-let customColors: { bg: string; text: string; accent: string; soft: string; codeBackground: string; border: string } | null = null;if (closestContainer && editorTheme === "custom") {const colors = getComputedStyle(closestContainer);@@ -416,9 +359,18 @@ export const buildWeChatClipboardHtml = async (editor: Editor) => {border: colors.getPropertyValue("--editor-theme-border") || "#a7f3d0",};}-const customStyleTag = closestContainer?.querySelector<HTMLStyleElement>("style[data-theme-custom-css]");- const customCss = customStyleTag?.dataset.originalCss || "";+ return {+ editorTheme,+ customColors,+ customCss: customStyleTag?.dataset.originalCss || "",+ };+};++export const buildWeChatClipboardHtml = async (editor: Editor) => {+ const container = document.createElement("div");+ container.innerHTML = editor.getHTML();+ const { editorTheme, customColors, customCss } = readEditorCopyContext(editor.view.dom);applyInlineStyles(container, editorTheme, customColors, customCss);convertImageGalleriesForWeChat(container);@@ -434,25 +386,7 @@ export const copyEditorToWeChat = async (editor: Editor) =>export const copyMarkdownToWeChat = async (markdown: string) => {const container = document.createElement("div");container.innerHTML = marked.parse(markdown, { async: false, gfm: true, breaks: false });-- const closestContainer = document.querySelector<HTMLElement>("[data-editor-theme]");- const editorTheme = closestContainer?.dataset.editorTheme;-- let customColors: { bg: string; text: string; accent: string; soft: string; codeBackground: string; border: string } | null = null;- if (closestContainer && editorTheme === "custom") {- const colors = getComputedStyle(closestContainer);- customColors = {- bg: colors.getPropertyValue("--editor-theme-bg") || "#ffffff",- text: colors.getPropertyValue("--editor-theme-text") || "#1f2937",- accent: colors.getPropertyValue("--editor-theme-accent") || "#059669",- soft: colors.getPropertyValue("--editor-theme-soft") || "#ecfdf5",- codeBackground: colors.getPropertyValue("--editor-theme-code-bg") || "#e0ece9",- border: colors.getPropertyValue("--editor-theme-border") || "#a7f3d0",- };- }-- const customStyleTag = closestContainer?.querySelector<HTMLStyleElement>("style[data-theme-custom-css]");- const customCss = customStyleTag?.dataset.originalCss || "";+ const { editorTheme, customColors, customCss } = readEditorCopyContext();applyInlineStyles(container, editorTheme, customColors, customCss);await embedMermaidForWeChat(container);diff --git a/apps/web/src/styles/editor-typography.test.mjs b/apps/web/src/styles/editor-typography.test.mjsindex 08ab3f57..23964e99 100644--- a/apps/web/src/styles/editor-typography.test.mjs+++ b/apps/web/src/styles/editor-typography.test.mjs@@ -24,6 +24,16 @@ describe("editor typography contract", () => {expect(MEMO_CONTENT_STYLE.body.paragraphSpacing).toBe(6);});+ test("keeps compact rhythm unless a paper editor theme is selected", () => {+ const editorPane = readStyle("../components/EditorPane.tsx");+ const publishLayout = readStyle("./publish-layout.css");++ expect(editorPane).toContain("isPaperEditorTheme(editorTheme)");+ expect(editorPane).toContain("MEMO_CONTENT_STYLE.body.lineHeight");+ expect(publishLayout).toContain('[data-editor-theme="letter"]');+ expect(publishLayout).not.toContain("[data-publish-layout]");+ });+test("styles default-theme external hyperlinks so they are distinct from body text", () => {const globals = readStyle("./globals.css");const linkRules = declarationsForSelector(globals, ".ProseMirror a");diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex ad0f07b6..bd69a79b 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -1,5 +1,6 @@@import "highlight.js/styles/github.css";@import "./editor-themes/index.css";+@import "./publish-layout.css";@import "./code-highlight-dark.css";@tailwind base;diff --git a/apps/web/src/styles/publish-layout.css b/apps/web/src/styles/publish-layout.cssnew file mode 100644index 00000000..dec574b3--- /dev/null+++ b/apps/web/src/styles/publish-layout.css@@ -0,0 +1,284 @@+/* Paper editor themes: writing canvas matches Copy to WeChat. */++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror {+ color: var(--publish-text);+ counter-reset: publish-h2;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror p {+ color: var(--publish-text);+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror h1,+.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror h2,+.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror h3 {+ color: var(--publish-text-strong);+ border: 0;+ padding-left: 0;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror strong {+ color: var(--publish-accent);+ font-weight: 700;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror em {+ color: var(--publish-text-muted);+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror a:not(.edgeever-attachment-link) {+ color: var(--publish-link);+ text-decoration: underline;+ text-decoration-color: color-mix(in srgb, var(--publish-link) 42%, transparent);+ text-underline-offset: 0.15em;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror li::marker {+ color: var(--publish-accent);+ font-weight: 700;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror code {+ background: var(--publish-code-bg);+ color: var(--publish-code-text);+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror pre {+ border-color: var(--publish-accent-border);+ background: var(--publish-code-bg);+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror hr:not([data-edgeever-merge-divider]) {+ background: var(--publish-divider);+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror hr:not([data-edgeever-merge-divider]) {+ width: 42%;+ margin-left: auto;+ margin-right: auto;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror th {+ background: var(--publish-accent-soft);+ color: var(--publish-text-strong);+ border-color: var(--publish-accent-border);+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror td {+ border-color: var(--publish-divider);+ color: var(--publish-text);+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h1 {+ text-align: center;+ font-weight: 800;+ border-bottom: 3px solid var(--publish-accent);+ padding-bottom: 0.55rem;+ margin: 0 0 1.5rem;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h2,+.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h2 {+ counter-increment: publish-h2;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h2::before {+ content: counter(publish-h2, decimal-leading-zero);+ display: block;+ color: var(--publish-accent);+ font-size: 1.75rem;+ font-style: italic;+ font-weight: 700;+ line-height: 1.1;+ margin: 0 0 0.35rem;+}++.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h2::before {+ content: counter(publish-h2, decimal-leading-zero);+ display: block;+ color: var(--publish-accent);+ font-size: 0.8rem;+ font-weight: 700;+ letter-spacing: 0.12em;+ margin: 0 0 0.25rem;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h2.is-empty,+.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h2.is-empty {+ counter-increment: none;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h2.is-empty::before,+.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h2.is-empty::before {+ content: none;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror h3 {+ text-align: center;+ font-size: 0.95rem;+ border-bottom: 2px solid var(--publish-accent-border);+ padding-bottom: 0.45rem;+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror blockquote {+ margin: 0 0 1.5rem;+ padding: 1rem 1.1rem;+ border: 1px solid var(--publish-accent-border);+ border-radius: 12px;+ background: var(--publish-surface);+ color: var(--publish-text-muted);+}++.edgeever-editor[data-editor-theme="guide"]:not([data-editor-theme="default"]) .ProseMirror h2,+.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h2 {+ border-left: 4px solid var(--publish-accent);+ padding-left: 0.75rem;+}++.edgeever-editor[data-editor-theme="guide"]:not([data-editor-theme="default"]) .ProseMirror blockquote,+.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror blockquote {+ margin: 0 0 1.5rem;+ padding: 0.75rem 1rem;+ border-left: 4px solid var(--publish-accent);+ background: var(--publish-accent-soft);+ color: var(--publish-text-muted);+}++.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h1 {+ text-align: left;+ border-top: 3px solid var(--publish-accent);+ padding-top: 0.55rem;+}++.edgeever-editor[data-editor-theme="blueprint"]:not([data-editor-theme="default"]) .ProseMirror h3 {+ border-bottom: 2px solid var(--publish-accent);+ padding-bottom: 0.35rem;+}++.edgeever-editor[data-editor-theme="journal"]:not([data-editor-theme="default"]) .ProseMirror h1 {+ text-align: left;+ font-weight: 700;+}++.edgeever-editor[data-editor-theme="journal"]:not([data-editor-theme="default"]) .ProseMirror h2 {+ border-bottom: 1px solid var(--publish-divider);+ padding-bottom: 0.45rem;+}++.edgeever-editor[data-editor-theme="journal"]:not([data-editor-theme="default"]) .ProseMirror blockquote {+ margin: 0 0 1.5rem;+ padding: 0.25rem 0 0.25rem 1rem;+ border-left: 2px solid var(--publish-divider);+ background: transparent;+ color: var(--publish-text-muted);+ font-style: italic;+}++.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror .edgeever-theme-block[data-theme-block-kind="intro"],+.edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+):not([data-editor-theme="default"]) .ProseMirror .edgeever-theme-block[data-theme-block-kind="key-point"] {+ border-color: var(--publish-accent-border);+ background: var(--publish-surface);+}++.edgeever-editor[data-editor-theme="letter"]:not([data-editor-theme="default"]) .ProseMirror .edgeever-theme-block[data-theme-block-kind="intro"] {+ border-radius: 12px;+}++:root.dark .edgeever-editor:is(+ [data-editor-theme="letter"],+ [data-editor-theme="guide"],+ [data-editor-theme="blueprint"],+ [data-editor-theme="journal"]+) {+ --publish-text: #d7ded9;+ --publish-text-strong: #f3f6f4;+ --publish-text-muted: #9aa69e;+ --publish-bg: transparent;+ --publish-surface: color-mix(in srgb, var(--publish-accent) 16%, var(--workspace-editor));+ --publish-accent-soft: color-mix(in srgb, var(--publish-accent) 14%, var(--workspace-editor));+ --publish-accent-border: color-mix(in srgb, var(--publish-accent) 36%, var(--workspace-editor));+ --publish-divider: color-mix(in srgb, var(--publish-accent) 26%, var(--workspace-editor));+ --publish-code-bg: color-mix(in srgb, var(--publish-accent) 10%, var(--workspace-editor));+ --publish-code-text: var(--publish-accent);+ --publish-link: var(--publish-accent);+}diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 8f6d5339..175219b3 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -592,7 +592,7 @@ export const enUS = {markdownThemeTitle: "Markdown source theme",markdownThemeDescription: "Follow the app appearance or choose a fixed syntax highlighting theme for Markdown source editing.",editorThemeTitle: "Editor theme",- editorThemeDescription: "Choose a writing style for the note editor. Saved in this browser.",+ editorThemeDescription: "Choose a writing style for the note editor. Saved in this browser. Copy to WeChat uses the same style.",editorContentAlignmentTitle: "Note content layout",editorContentAlignmentDescription: "Choose how note content is displayed across all notes on desktop. Saved in this browser.",editorContentAlignments: {@@ -601,6 +601,10 @@ export const enUS = {},editorThemes: {default: "System default",+ letter: "Letter",+ guide: "Guide",+ blueprint: "Blueprint",+ journal: "Journal","minimal-emerald": "Minimal Emerald","outline-emerald": "Outline Emerald","wechat-green": "WeChat Classic Green",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex bf4c7f69..516a6cf8 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -592,7 +592,7 @@ export const zhCN = {markdownThemeTitle: "Markdown 源码主题",markdownThemeDescription: "跟随应用外观,或为 Markdown 源码编辑模式选择固定的代码高亮配色。",editorThemeTitle: "编辑器主题",- editorThemeDescription: "选择正文编辑区的排版风格,偏好会保存在当前浏览器中。",+ editorThemeDescription: "选择正文编辑区的排版风格,偏好会保存在当前浏览器中。复制到公众号时使用同一套风格。",editorContentAlignmentTitle: "笔记正文布局",editorContentAlignmentDescription: "选择桌面端所有笔记的正文显示方式,偏好会保存在当前浏览器中。",editorContentAlignments: {@@ -601,6 +601,10 @@ export const zhCN = {},editorThemes: {default: "系统默认",+ letter: "暖笺",+ guide: "教程",+ blueprint: "蓝图",+ journal: "刊物","minimal-emerald": "minimal品牌绿","outline-emerald": "Outline 品牌绿","wechat-green": "微信经典绿",