fix: neutralize inline code colors and refine prose palette names

This commit is contained in:
tianma-if committed 2026-10-13 14:06:34 +08:00
1 parent aebdd0993c
commit 55d56957a0
8 files changed
+32 -45

No files matched your search

+4 -1
View File
@@ -80,13 +80,16 @@ describe("preparePublishArticle", () => {
"--note-palette-accent": "#B39AE8",
"--note-palette-light-accent": "#7351CF",
"--note-palette-text": "#3F3F46",
"--note-palette-code-text": "#5B4EE0",
})[name] ?? "",
});
try {
const context = readEditorCopyContext(container);
expect(context.colors.accent).toBe("#7351CF");
const root = preparePublishArticle("<p><strong>重点</strong></p>", container);
const root = preparePublishArticle("<p><strong>重点</strong> <code>Cmd/Ctrl + E</code></p>", container);
expect(css(root.querySelector("strong"))).toContain("color:#7351CF");
expect(css(root.querySelector("code"))).toContain("color:#3d4450");
expect(css(root.querySelector("code"))).toContain("background:#f3f5f7");
} finally {
globalThis.getComputedStyle = previous;
}
+2 -2
View File
@@ -58,9 +58,9 @@ const applyLegacyWeChatStyles = (
const fontSize = `${metrics.fontSize}px`;
const lineHeight = String(metrics.lineHeight);
const codeSize = `${noteProseCodeFontSize(metrics.fontSize)}px`;
// A named hue only recolors links, inline code, and bold, matching the editor.
// A named hue only recolors links and bold, matching the editor.
const link = colors?.link ?? LINK_COLOR;
const inlineCodeColor = colors?.codeText ?? CODE_COLOR;
const inlineCodeColor = CODE_COLOR;
const accent = colors?.accent ?? BODY_COLOR;
const bold = colors ? `font-weight: 800; color: ${accent};` : "font-weight: 800;";
const textStyle = `font-family: ${PUBLISH_FONT}; font-size: ${fontSize}; line-height: ${lineHeight}; letter-spacing: -0.005em; color: ${BODY_COLOR};`;
@@ -81,15 +81,17 @@ describe("editor typography contract", () => {
expect(prose).not.toContain('data-note-palette="custom"');
});
test("named palettes recolor links, inline code, bold, and checked task boxes", () => {
test("named palettes recolor links, bold, and checked task boxes while code stays neutral", () => {
const prose = readStyle("./note-prose.css");
expect(prose).toMatch(/color:\s*var\(--note-palette-link\)/);
expect(prose).toMatch(/color:\s*var\(--note-palette-code-text\)/);
expect(prose).not.toMatch(/--note-palette-code-text/);
expect(prose).toMatch(/color:\s*var\(--note-palette-accent\)/);
expect(prose).toMatch(/accent-color:\s*var\(--note-palette-accent\)/);
expect(prose).toMatch(/ul\[data-type="taskList"\] li\[data-checked\] > label input/);
expect(prose).toMatch(/\.edgeever-code-block code/);
expect(prose).not.toMatch(/\.ProseMirror (?:code|pre code)/);
const globals = readStyle("./globals.css");
expect(declarationsForSelector(globals, ".ProseMirror code")).toContain("color: #3d4450;");
expect(prose).not.toMatch(/--note-palette-text/);
expect(prose).not.toMatch(/--note-palette-surface/);
expect(prose).not.toMatch(/--note-palette-muted/);
+1 -19
View File
@@ -1,4 +1,4 @@
/* Named hues tint links, inline code, bold, and checked task boxes. Body, quotes, rules, tables, and code chrome stay native. */
/* Named hues tint links, bold, and checked task boxes. Body, quotes, rules, tables, and code stay native. */
:root.dark .edgeever-editor[data-note-palette]:not([data-note-palette="native"]) {
/* Override the light accent supplied by inline account prose variables. */
--note-palette-accent: var(--note-palette-dark-accent) !important;
@@ -23,15 +23,6 @@
accent-color: var(--note-palette-accent);
}
.edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror code {
color: var(--note-palette-code-text);
}
.edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror pre code,
.edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror .edgeever-code-block code {
color: inherit;
}
:root.dark .edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror a:not(.edgeever-attachment-link) {
color: var(--note-palette-accent);
text-decoration-color: color-mix(in srgb, var(--note-palette-accent) 45%, transparent);
@@ -42,12 +33,3 @@
text-decoration-color: var(--note-palette-accent);
}
:root.dark .edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror code {
color: var(--note-palette-accent);
}
:root.dark .edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror pre code,
:root.dark .edgeever-editor[data-note-palette]:not([data-note-palette="native"]) .ProseMirror .edgeever-code-block code {
color: inherit;
}
+5 -5
View File
@@ -1023,12 +1023,12 @@ export const enUS = {
editorBodyPalettes: {
native: "Native",
clay: "Vermilion orange",
dawn: "Gold",
teal: "Teal",
dawn: "Ochre gold",
teal: "Jade teal",
azure: "Royal blue",
violet: "Purple",
pink: "Pink",
slate: "Gray",
violet: "Iris purple",
pink: "Rose pink",
slate: "Mauve gray",
},
editorBodyCssTitle: "Custom CSS",
editorBodyCssDescription: "One stylesheet. Light rules set spacing and color, and the following :root.dark rules only override color. Size and line height stay on the controls above.",
+5 -5
View File
@@ -1012,12 +1012,12 @@ export const ja = {
editorBodyPalettes: {
native: "標準",
clay: "朱橙",
dawn: "金",
teal: "青緑",
dawn: "オーカーゴールド",
teal: "ジェイドティール",
azure: "ロイヤルブルー",
violet: "紫",
pink: "ピンク",
slate: "グレー",
violet: "アイリスパープル",
pink: "ローズピンク",
slate: "モーヴグレー",
},
editorBodyCssTitle: "カスタム CSS",
editorBodyCssDescription: "スタイルは1つです。ライトで間隔と色を書き、直後の :root.dark は色だけを上書きします。文字サイズと行間はここでは指定しません。",
+5 -5
View File
@@ -1012,12 +1012,12 @@ export const pl = {
editorBodyPalettes: {
native: "Natywne",
clay: "Cynobrowy pomarańcz",
dawn: "Złoty",
teal: "Morski",
dawn: "Ochrowe złoto",
teal: "Jadeitowy turkus",
azure: "Królewski błękit",
violet: "Fioletowy",
pink: "Różowy",
slate: "Szary",
violet: "Irysowy fiolet",
pink: "Różany róż",
slate: "Szarość z fioletem",
},
editorBodyCssTitle: "Własny CSS",
editorBodyCssDescription: "Jeden arkusz stylów. Reguły jasne ustawiają odstępy i kolory, a następujące po nich reguły :root.dark nadpisują tylko kolory. Rozmiar i interlinia pozostają w ustawieniach powyżej.",
+5 -5
View File
@@ -1023,12 +1023,12 @@ export const zhCN = {
editorBodyPalettes: {
native: "原生",
clay: "朱橙",
dawn: "金色",
teal: "青色",
dawn: "赭金",
teal: "碧青",
azure: "宝蓝",
violet: "紫色",
pink: "粉色",
slate: "灰色",
violet: "鸢紫",
pink: "玫粉",
slate: "灰紫",
},
editorBodyCssTitle: "自定义 CSS",
editorBodyCssDescription: "同一份样式。浅色写间距和颜色,紧随的 :root.dark 只覆盖颜色。字号和行高不写在这里。",