Skip to content

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

fix(editor): align numbered pill headings with body text size

tianma-if807cb87d2e12
diff --git a/apps/web/src/lib/note-print-appearance.ts b/apps/web/src/lib/note-print-appearance.ts
index 73ea3d37..ed322d8d 100644
--- a/apps/web/src/lib/note-print-appearance.ts
+++ b/apps/web/src/lib/note-print-appearance.ts
@@ -109,9 +109,12 @@ const proseStyleRules = (
} else if (proseStyle.headingStyle === "numbered") {
rules.push(
".edgeever-print-content { counter-reset: note-prose-h2; }",
- `.edgeever-print-content h2 { counter-increment: note-prose-h2; padding-bottom: 6px; border-bottom: 2px solid ${divider}; }`,
+ ".edgeever-print-content h1 { font-size: calc(var(--editor-body-font-size, 16px) * 1.75); }",
+ ".edgeever-print-content h4 { font-size: var(--editor-body-font-size, 16px); }",
+ `.edgeever-print-content h2 { font-size: calc(var(--editor-body-font-size, 16px) * 1.4); counter-increment: note-prose-h2; padding-bottom: 6px; border-bottom: 2px solid ${divider}; }`,
`.edgeever-print-content h2::before { content: counter(note-prose-h2, decimal-leading-zero) " · "; color: ${accent}; font-weight: 800; letter-spacing: 0.04em; }`,
- `.edgeever-print-content h3 { border-left: 3px solid ${accent}; padding-left: 10px; }`,
+ `.edgeever-print-content h3 { position: relative; display: block; width: fit-content; max-width: 100%; box-sizing: border-box; font-size: var(--editor-body-font-size, 16px); font-weight: 700; line-height: 1.5; margin: 1.5em 0 0.6em; padding: 0.25em 0.75em 0.25em 1.5em; border: 0; border-radius: 1em; background: color-mix(in srgb, ${accent} 9%, transparent); color: ${accent}; overflow-wrap: anywhere; }`,
+ `.edgeever-print-content h3::before { content: ""; position: absolute; left: 0.75em; top: 0.8125em; width: 0.375em; height: 0.375em; border-radius: 50%; background: ${accent}; }`,
);
}
if (proseStyle.quoteStyle === "dashed") {
diff --git a/apps/web/src/lib/wechat-copy.test.mjs b/apps/web/src/lib/wechat-copy.test.mjs
index 60f0c0eb..54376ef3 100644
--- a/apps/web/src/lib/wechat-copy.test.mjs
+++ b/apps/web/src/lib/wechat-copy.test.mjs
@@ -237,7 +237,7 @@ describe("preparePublishArticle", () => {
expect(h2?.textContent).toContain("章节标题");
expect(h2?.querySelector("[data-ee-heading-number]")?.innerHTML).toContain("#059669");
const h3 = root.querySelector("h3");
- expect(css(h3)).toContain("border-radius:999px");
+ expect(css(h3)).toContain("border-radius:1em");
expect(h3?.querySelector("[data-ee-pill-dot]")).not.toBeNull();
const quote = root.querySelector("blockquote");
expect(css(quote)).toContain("border:1px dashed #d1d5db");
@@ -256,6 +256,31 @@ describe("preparePublishArticle", () => {
}
});
+ test("numbered headings follow body size while preserving the wrapping pill", () => {
+ const container = document.createElement("div");
+ container.dataset.notePalette = "native";
+ container.dataset.noteHeadingStyle = "numbered";
+ const previous = globalThis.getComputedStyle;
+ try {
+ for (const size of [14, 16, 18]) {
+ globalThis.getComputedStyle = () => ({
+ getPropertyValue: (name) => name === "--editor-body-font-size" ? `${size}px` : "",
+ });
+ const root = preparePublishArticle("<h2>章节</h2><h3>包含 <strong>强调</strong> 的长标题</h3><h4>子标题</h4><p>正文</p>", container);
+ expect(root.querySelector("h3").style.fontSize).toBe(`${size}px`);
+ expect(root.querySelector("h4").style.fontSize).toBe(`${size}px`);
+ expect(root.querySelector("p:not([data-ee-publish-chrome])").style.fontSize).toBe(`${size}px`);
+ const h2Title = Array.from(root.querySelectorAll("h2 p")).find((p) => p.textContent === "章节");
+ expect(h2Title.style.fontSize).toBe(`${size * 1.4}px`);
+ expect(css(root.querySelector("h3"))).toContain("max-width:100%");
+ expect(root.querySelector("h3 strong").textContent).toBe("强调");
+ expect(root.querySelectorAll("[data-ee-pill-dot]").length).toBe(1);
+ }
+ } finally {
+ globalThis.getComputedStyle = previous;
+ }
+ });
+
test("renders magazine cover card and toc cards only when showMagazineCover is enabled", () => {
const container = document.createElement("div");
container.dataset.notePalette = "emerald";
diff --git a/apps/web/src/lib/wechat-copy.ts b/apps/web/src/lib/wechat-copy.ts
index 6f31f151..58a8c94c 100644
--- a/apps/web/src/lib/wechat-copy.ts
+++ b/apps/web/src/lib/wechat-copy.ts
@@ -86,10 +86,10 @@ const applyLegacyWeChatStyles = (
const h3Style = proseStyle.headingStyle === "bar"
? `${h3Base.replace(/padding:\s*0;/, "padding: 0 0 0 8px;")} border-left: 3px solid ${accent};`
: proseStyle.headingStyle === "numbered"
- ? `display: inline-block; margin: 18px 0 8px; padding: 4px 12px; border-radius: 999px; background: ${surface}; color: ${accent}; font-family: ${PUBLISH_FONT}; font-size: 13px; font-weight: 700; line-height: 1.5;`
+ ? `display: block; width: fit-content; max-width: 100%; box-sizing: border-box; margin: 1.5em 0 0.6em; padding: 0.25em 0.75em 0.25em 1.5em; text-indent: -0.75em; overflow-wrap: anywhere; border-radius: 1em; background: ${surface}; color: ${accent}; font-family: ${PUBLISH_FONT}; font-size: ${fontSize}; font-weight: 700; line-height: 1.5;`
: h3Base;
const h4Style = proseStyle.headingStyle === "numbered"
- ? `display: inline-block; margin: 16px 0 8px; padding: 1px 6px; border-radius: 3px; background: #fde68a; color: #111827; font-family: ${PUBLISH_FONT}; font-size: 14px; font-weight: 800; line-height: 1.5;`
+ ? `display: inline-block; margin: 16px 0 8px; padding: 1px 6px; border-radius: 3px; background: #fde68a; color: #111827; font-family: ${PUBLISH_FONT}; font-size: ${fontSize}; font-weight: 800; line-height: 1.5;`
: headingStyle("h4", metrics);
const blockquoteStyle = proseStyle.quoteStyle === "dashed"
? `margin: 0 0 20px; padding: 12px 16px; border: 1px dashed #d1d5db; border-radius: 8px; background: #f9fafb; color: ${QUOTE_COLOR}; font-family: ${PUBLISH_FONT}; line-height: ${lineHeight};`
@@ -185,7 +185,7 @@ const applyLegacyWeChatStyles = (
`<span data-ee-publish-chrome="true" style="display: inline-block; width: 6px; height: 6px; background: ${accent}; border-radius: 50%; vertical-align: middle;"><span leaf=""><br></span></span>`,
`<span data-ee-publish-chrome="true" style="display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 3px; color: ${accent}; vertical-align: middle; margin-left: 8px;">FEATURED · 深度实测</span>`,
`</section>`,
- `<p data-ee-publish-chrome="true" style="font-size: 23px; font-weight: 900; color: #111827; margin: 0 0 14px; line-height: 1.2; letter-spacing: -0.5px;">${titleHtml}</p>`,
+ `<p data-ee-publish-chrome="true" style="font-size: ${metrics.fontSize * 1.75}px; font-weight: 900; color: #111827; margin: 0 0 14px; line-height: 1.2; letter-spacing: -0.5px;">${titleHtml}</p>`,
`<section data-ee-publish-chrome="true" style="width: 48px; height: 3px; background: ${accent}; border-radius: 2px;"><span leaf=""><br></span></section>`,
`</section>`,
`<section data-ee-publish-chrome="true" style="${colors ? accentGradient : "background: #f3f4f6;"} padding: 10px 24px; font-size: 0;">`,
@@ -259,7 +259,7 @@ const applyLegacyWeChatStyles = (
`</section>`,
`<span data-ee-publish-chrome="true" style="display: inline-block; width: 1px; height: 36px; background: #e5e7eb; vertical-align: middle; margin: 0 16px;"><span leaf=""><br></span></span>`,
`<section data-ee-publish-chrome="true" style="display: inline-block; vertical-align: middle; max-width: calc(100% - 86px);">`,
- `<p data-ee-publish-chrome="true" style="margin: 0; font-size: 17px; font-weight: 900; color: #111827; letter-spacing: 0.3px; line-height: 1.3;">${titleHtml}</p>`,
+ `<p data-ee-publish-chrome="true" style="margin: 0; font-size: ${metrics.fontSize * 1.4}px; font-weight: 900; color: #111827; letter-spacing: 0.3px; line-height: 1.3;">${titleHtml}</p>`,
`<p data-ee-publish-chrome="true" style="margin: 3px 0 0; font-size: 11px; font-weight: 600; color: #9ca3af; letter-spacing: 1px; line-height: 1.3;">${subLabel}</p>`,
`</section>`,
].join("");
@@ -270,7 +270,7 @@ const applyLegacyWeChatStyles = (
const dot = document.createElement("span");
dot.setAttribute("data-ee-publish-chrome", "true");
dot.setAttribute("data-ee-pill-dot", "true");
- dot.style.cssText = `display: inline-block; width: 6px; height: 6px; background: ${accent}; border-radius: 50%; margin-right: 6px; vertical-align: middle;`;
+ dot.style.cssText = `display: inline-block; width: 0.375em; height: 0.375em; background: ${accent}; border-radius: 50%; margin-right: 0.375em; text-indent: 0; vertical-align: middle;`;
dot.innerHTML = "<span leaf=\"\"><br></span>";
heading.insertBefore(dot, heading.firstChild);
});
diff --git a/apps/web/src/styles/note-prose-styles.css b/apps/web/src/styles/note-prose-styles.css
index 076e9188..96b3335c 100644
--- a/apps/web/src/styles/note-prose-styles.css
+++ b/apps/web/src/styles/note-prose-styles.css
@@ -36,7 +36,7 @@
border: 1.5px solid color-mix(in srgb, var(--note-palette-accent, #374151) 18%, transparent);
border-radius: 20px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
- font-size: 24px;
+ font-size: calc(var(--editor-body-font-size, 16px) * 1.75);
font-weight: 900;
line-height: 1.25;
letter-spacing: -0.5px;
@@ -114,7 +114,7 @@
min-height: 40px;
display: block;
border: 0;
- font-size: 17px;
+ font-size: calc(var(--editor-body-font-size, 16px) * 1.4);
font-weight: 900;
color: #111827;
letter-spacing: 0.3px;
@@ -179,20 +179,23 @@
content: "SUMMARY";
}
-/* H3: Green pill badge with solid dot */
+/* H3: Body-relative pill heading; bounded corners also suit wrapped titles. */
.edgeever-editor[data-note-heading-style="numbered"] .ProseMirror h3,
.edgeever-editor[data-note-heading-style="numbered"] .markdown-content h3 {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- margin-top: 1.1rem;
- margin-bottom: 0.5rem;
- padding: 4px 12px;
+ position: relative;
+ display: block;
+ width: fit-content;
+ max-width: 100%;
+ box-sizing: border-box;
+ margin-top: 1.5em;
+ margin-bottom: 0.6em;
+ padding: 0.25em 0.75em 0.25em 1.5em;
+ overflow-wrap: anywhere;
border: 0;
- border-radius: 999px;
+ border-radius: 1em;
background: color-mix(in srgb, var(--note-palette-accent, #374151) 9%, transparent);
color: var(--note-palette-accent, #374151);
- font-size: 13px;
+ font-size: var(--editor-body-font-size, 16px);
font-weight: 700;
line-height: 1.5;
}
@@ -200,11 +203,13 @@
.edgeever-editor[data-note-heading-style="numbered"] .ProseMirror h3::before,
.edgeever-editor[data-note-heading-style="numbered"] .markdown-content h3::before {
content: "";
- width: 6px;
- height: 6px;
+ position: absolute;
+ left: 0.75em;
+ top: 0.8125em;
+ width: 0.375em;
+ height: 0.375em;
border-radius: 50%;
background: var(--note-palette-accent, #374151);
- flex-shrink: 0;
pointer-events: none;
}
@@ -218,7 +223,7 @@
border-radius: 3px;
background: #fde68a;
color: #111827;
- font-size: 14px;
+ font-size: var(--editor-body-font-size, 16px);
font-weight: 800;
}