Skip to content

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

feat(editor): add independent body spacing and alignment settings

tianma-ifb913b1fe5954
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 5dd5038a..0a073325 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -141,6 +141,7 @@ import {
docToMarkdown,
MEMO_CONTENT_STYLE,
noteProseCssVariables,
+ noteProseStyleCssVariables,
markdownToDoc,
normalizeImageGalleries,
PLUGIN_EMBED_NODE_TYPE,
@@ -4549,6 +4550,7 @@ const RichEditorPane = ({
data-note-title={title || getEditableMemoTitle(memo?.title)}
style={{
...noteProseCssVariables(noteProse),
+ ...noteProseStyleCssVariables(noteProseStyle),
"--memo-content-divider-spacing": `${MEMO_CONTENT_STYLE.divider.marginVertical}px`,
} as CSSProperties}
className={cn(
diff --git a/apps/web/src/components/EditorPhonePreview.tsx b/apps/web/src/components/EditorPhonePreview.tsx
index aa100351..63931750 100644
--- a/apps/web/src/components/EditorPhonePreview.tsx
+++ b/apps/web/src/components/EditorPhonePreview.tsx
@@ -68,7 +68,7 @@ export const EditorPhonePreview = ({ editor, title, noteProse, scrollContainer,
const { t } = useTranslation();
const { mermaidTheme } = useMermaidTheme();
const noteProseStyle = useNoteProseStylePreference();
- const proseKey = `${noteProse.palette}:${noteProse.fontSize}:${noteProse.lineHeight}:${noteProse.customCss}:${noteProseStyle.headingStyle}:${noteProseStyle.quoteStyle}:${noteProseStyle.emphasisStyle}:${noteProseStyle.showMagazineCover}`;
+ const proseKey = `${noteProse.palette}:${noteProse.fontSize}:${noteProse.lineHeight}:${noteProse.customCss}:${noteProseStyle.headingStyle}:${noteProseStyle.quoteStyle}:${noteProseStyle.emphasisStyle}:${noteProseStyle.showMagazineCover}:${noteProseStyle.paragraphSpacing}:${noteProseStyle.textAlign}:${noteProseStyle.letterSpacing}`;
const previewSyncGeneration = useRef(0);
const [markup, setMarkup] = useState({ html: "", style: "" });
const [follow, setFollow] = useState(readEditorPhonePreviewFollowPreference);
diff --git a/apps/web/src/components/settings/PreferenceCard.tsx b/apps/web/src/components/settings/PreferenceCard.tsx
index 69624f5c..5debdef9 100644
--- a/apps/web/src/components/settings/PreferenceCard.tsx
+++ b/apps/web/src/components/settings/PreferenceCard.tsx
@@ -22,6 +22,12 @@ import {
NOTE_PROSE_EMPHASIS_STYLES,
NOTE_PROSE_FONT_SIZES,
NOTE_PROSE_HEADING_STYLES,
+ NOTE_PROSE_PARAGRAPH_SPACINGS,
+ NOTE_PROSE_TEXT_ALIGNS,
+ NOTE_PROSE_LETTER_SPACINGS,
+ parseNoteProseParagraphSpacing,
+ parseNoteProseTextAlign,
+ parseNoteProseLetterSpacing,
NOTE_PROSE_PALETTE_CHOICES,
NOTE_PROSE_PALETTES,
NOTE_PROSE_QUOTE_STYLES,
@@ -507,6 +513,45 @@ export const PreferenceCard = ({
</div>
</div>
+ {[
+ {
+ id: "paragraphSpacing",
+ title: t("settings.editorParagraphSpacingTitle"),
+ value: String(noteProseStyle.paragraphSpacing),
+ options: NOTE_PROSE_PARAGRAPH_SPACINGS.map((value) => ({ value: String(value), label: `${value}px` })),
+ onChange: (value: string) => writeNoteProseStylePreference({ paragraphSpacing: parseNoteProseParagraphSpacing(Number(value)) ?? 8 }),
+ },
+ {
+ id: "textAlign",
+ title: t("settings.editorTextAlignTitle"),
+ value: noteProseStyle.textAlign,
+ options: NOTE_PROSE_TEXT_ALIGNS.map((value) => ({ value, label: t(`settings.editorTextAlignOptions.${value}`) })),
+ onChange: (value: string) => writeNoteProseStylePreference({ textAlign: parseNoteProseTextAlign(value) ?? "left" }),
+ },
+ {
+ id: "letterSpacing",
+ title: t("settings.editorLetterSpacingTitle"),
+ value: noteProseStyle.letterSpacing,
+ options: NOTE_PROSE_LETTER_SPACINGS.map((value) => ({ value, label: value === "default" ? t("settings.editorLetterSpacingDefault") : value })),
+ onChange: (value: string) => writeNoteProseStylePreference({ letterSpacing: parseNoteProseLetterSpacing(value) ?? "default" }),
+ },
+ ].map((setting) => (
+ <div key={setting.id} className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
+ <div className="flex min-w-0 items-center gap-3">
+ <Type className="h-4 w-4 shrink-0 text-slate-500" />
+ <div className={SETTINGS_ITEM_TITLE_CLASSNAME}>{setting.title}</div>
+ </div>
+ <div className="w-full shrink-0 sm:w-80">
+ <Select value={setting.value} onValueChange={setting.onChange}>
+ <SelectTrigger aria-label={setting.title} className="h-9 bg-card"><SelectValue /></SelectTrigger>
+ <SelectContent>
+ {setting.options.map((option) => <SelectItem key={option.value} value={option.value}>{option.label}</SelectItem>)}
+ </SelectContent>
+ </Select>
+ </div>
+ </div>
+ ))}
+
<div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
<div className="flex min-w-0 items-center gap-3">
<Palette className="h-4 w-4 shrink-0 text-slate-500" />
diff --git a/apps/web/src/lib/note-print-appearance.test.mjs b/apps/web/src/lib/note-print-appearance.test.mjs
index 08d9ef6b..77a347fd 100644
--- a/apps/web/src/lib/note-print-appearance.test.mjs
+++ b/apps/web/src/lib/note-print-appearance.test.mjs
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test";
import { resolveNoteProse } from "@edgeever/shared";
+import { DEFAULT_NOTE_PROSE_STYLE_PREFERENCES } from "./note-prose-style-preference.ts";
import { notePrintAppearanceCss, notePrintAppearanceFromProse } from "./note-print-appearance.ts";
describe("note print appearance", () => {
@@ -30,6 +31,18 @@ describe("note print appearance", () => {
expect(css).not.toContain("color: #");
});
+ test("print uses the selected body rhythm with any heading style", () => {
+ for (const headingStyle of ["default", "bar", "numbered"]) {
+ const appearance = notePrintAppearanceFromProse(resolveNoteProse({}), "github-light",
+ { choice: "system", customFamily: "" },
+ { ...DEFAULT_NOTE_PROSE_STYLE_PREFERENCES, headingStyle, paragraphSpacing: 16, textAlign: "justify", letterSpacing: "1px" });
+ const css = notePrintAppearanceCss(appearance);
+ expect(css).toContain("--editor-paragraph-spacing: 16px");
+ expect(css).toContain("--editor-body-text-align: justify");
+ expect(css).toContain("--editor-body-letter-spacing: 1px");
+ }
+ });
+
test("tints links, bold, checked boxes, and tables with the account palette", () => {
const css = notePrintAppearanceCss(notePrintAppearanceFromProse(resolveNoteProse({
palette: "teal",
diff --git a/apps/web/src/lib/note-print-appearance.ts b/apps/web/src/lib/note-print-appearance.ts
index ed322d8d..00d82214 100644
--- a/apps/web/src/lib/note-print-appearance.ts
+++ b/apps/web/src/lib/note-print-appearance.ts
@@ -1,6 +1,7 @@
import {
NOTE_PROSE_PALETTES,
noteProseCssVariables,
+ noteProseStyleCssVariables,
type NoteProsePaletteChoice,
type NoteProseStylePreferences,
type ResolvedNoteProse,
@@ -48,7 +49,7 @@ export const notePrintAppearanceFromProse = (
): NotePrintAppearance => ({
palette: prose.palette,
proseStyle,
- cssVariables: noteProseCssVariables(prose),
+ cssVariables: { ...noteProseCssVariables(prose), ...noteProseStyleCssVariables(proseStyle) },
customCss: sanitizeAndScopeCss(prose.customCss),
fontFamily: resolveEditorBodyFontStack(font) ?? null,
fontId: loadableBodyFontId(font.choice),
diff --git a/apps/web/src/lib/note-prose-style-preference.test.mjs b/apps/web/src/lib/note-prose-style-preference.test.mjs
new file mode 100644
index 00000000..6cae6a64
--- /dev/null
+++ b/apps/web/src/lib/note-prose-style-preference.test.mjs
@@ -0,0 +1,41 @@
+import { describe, expect, test } from "bun:test";
+import { noteProseStyleCssVariables } from "@edgeever/shared";
+import { resolveStoredNoteProseStylePreference } from "./note-prose-style-preference.ts";
+
+describe("independent body rhythm preferences", () => {
+ test("all heading styles use the same body defaults without migration", () => {
+ for (const headingStyle of ["default", "bar", "numbered"]) {
+ const preference = resolveStoredNoteProseStylePreference(JSON.stringify({ headingStyle }));
+ expect(preference.paragraphSpacing).toBe(8);
+ expect(preference.textAlign).toBe("left");
+ expect(preference.letterSpacing).toBe("default");
+ expect(noteProseStyleCssVariables(preference)).toEqual({
+ "--editor-paragraph-spacing": "8px",
+ "--editor-body-text-align": "left",
+ "--editor-body-letter-spacing": "-0.005em",
+ });
+ }
+ });
+
+ test("round trips supported choices independently from headings", () => {
+ for (const paragraphSpacing of [8, 12, 16]) {
+ for (const textAlign of ["left", "justify"]) {
+ for (const letterSpacing of ["default", "0.5px", "1px"]) {
+ const values = { paragraphSpacing, textAlign, letterSpacing, headingStyle: "numbered" };
+ const preference = resolveStoredNoteProseStylePreference(JSON.stringify(values));
+ expect(preference).toMatchObject(values);
+ expect(noteProseStyleCssVariables(preference)["--editor-paragraph-spacing"]).toBe(`${paragraphSpacing}px`);
+ }
+ }
+ }
+ });
+
+ test("invalid values fall back to body defaults", () => {
+ const preference = resolveStoredNoteProseStylePreference(JSON.stringify({
+ paragraphSpacing: -1, textAlign: "center", letterSpacing: "99px",
+ }));
+ expect(preference.paragraphSpacing).toBe(8);
+ expect(preference.textAlign).toBe("left");
+ expect(preference.letterSpacing).toBe("default");
+ });
+});
diff --git a/apps/web/src/lib/note-prose-style-preference.ts b/apps/web/src/lib/note-prose-style-preference.ts
index 786fd4e0..93145a14 100644
--- a/apps/web/src/lib/note-prose-style-preference.ts
+++ b/apps/web/src/lib/note-prose-style-preference.ts
@@ -3,12 +3,12 @@ import {
DEFAULT_NOTE_PROSE_EMPHASIS_STYLE,
DEFAULT_NOTE_PROSE_HEADING_STYLE,
DEFAULT_NOTE_PROSE_QUOTE_STYLE,
+ parseNoteProseParagraphSpacing,
+ parseNoteProseTextAlign,
+ parseNoteProseLetterSpacing,
parseNoteProseEmphasisStyle,
parseNoteProseHeadingStyle,
parseNoteProseQuoteStyle,
- type NoteProseEmphasisStyle,
- type NoteProseHeadingStyle,
- type NoteProseQuoteStyle,
type NoteProseStylePreferences,
} from "@edgeever/shared";
@@ -18,6 +18,9 @@ export const NOTE_PROSE_STYLE_CHANGED_EVENT = "edgeever:note-prose-style-changed
let unsavedNoteProseStylePreference: NoteProseStylePreferences | null = null;
export const DEFAULT_NOTE_PROSE_STYLE_PREFERENCES: NoteProseStylePreferences = {
+ paragraphSpacing: 8,
+ textAlign: "left",
+ letterSpacing: "default",
headingStyle: DEFAULT_NOTE_PROSE_HEADING_STYLE,
quoteStyle: DEFAULT_NOTE_PROSE_QUOTE_STYLE,
emphasisStyle: DEFAULT_NOTE_PROSE_EMPHASIS_STYLE,
@@ -30,6 +33,9 @@ export const resolveStoredNoteProseStylePreference = (
if (!stored) return DEFAULT_NOTE_PROSE_STYLE_PREFERENCES;
try {
const parsed = JSON.parse(stored) as {
+ paragraphSpacing?: unknown;
+ textAlign?: unknown;
+ letterSpacing?: unknown;
headingStyle?: unknown;
quoteStyle?: unknown;
emphasisStyle?: unknown;
@@ -39,6 +45,9 @@ export const resolveStoredNoteProseStylePreference = (
return DEFAULT_NOTE_PROSE_STYLE_PREFERENCES;
}
return {
+ paragraphSpacing: parseNoteProseParagraphSpacing(parsed.paragraphSpacing) ?? 8,
+ textAlign: parseNoteProseTextAlign(parsed.textAlign) ?? "left",
+ letterSpacing: parseNoteProseLetterSpacing(parsed.letterSpacing) ?? "default",
headingStyle: parseNoteProseHeadingStyle(parsed.headingStyle) ?? DEFAULT_NOTE_PROSE_HEADING_STYLE,
quoteStyle: parseNoteProseQuoteStyle(parsed.quoteStyle) ?? DEFAULT_NOTE_PROSE_QUOTE_STYLE,
emphasisStyle: parseNoteProseEmphasisStyle(parsed.emphasisStyle) ?? DEFAULT_NOTE_PROSE_EMPHASIS_STYLE,
@@ -62,15 +71,13 @@ export const readNoteProseStylePreference = (): NoteProseStylePreferences => {
};
export const writeNoteProseStylePreference = (
- patch: Partial<{
- headingStyle: NoteProseHeadingStyle;
- quoteStyle: NoteProseQuoteStyle;
- emphasisStyle: NoteProseEmphasisStyle;
- showMagazineCover: boolean;
- }>,
+ patch: Partial<NoteProseStylePreferences>,
): NoteProseStylePreferences => {
const current = readNoteProseStylePreference();
const next: NoteProseStylePreferences = {
+ paragraphSpacing: parseNoteProseParagraphSpacing(patch.paragraphSpacing) ?? current.paragraphSpacing,
+ textAlign: parseNoteProseTextAlign(patch.textAlign) ?? current.textAlign,
+ letterSpacing: parseNoteProseLetterSpacing(patch.letterSpacing) ?? current.letterSpacing,
headingStyle: parseNoteProseHeadingStyle(patch.headingStyle) ?? current.headingStyle,
quoteStyle: parseNoteProseQuoteStyle(patch.quoteStyle) ?? current.quoteStyle,
emphasisStyle: parseNoteProseEmphasisStyle(patch.emphasisStyle) ?? current.emphasisStyle,
@@ -101,6 +108,9 @@ export const useNoteProseStylePreference = (): NoteProseStylePreferences => {
const detail = (event as CustomEvent<NoteProseStylePreferences | undefined>).detail;
if (detail && typeof detail === "object") {
setPreference({
+ paragraphSpacing: parseNoteProseParagraphSpacing(detail.paragraphSpacing) ?? 8,
+ textAlign: parseNoteProseTextAlign(detail.textAlign) ?? "left",
+ letterSpacing: parseNoteProseLetterSpacing(detail.letterSpacing) ?? "default",
headingStyle: parseNoteProseHeadingStyle(detail.headingStyle) ?? DEFAULT_NOTE_PROSE_HEADING_STYLE,
quoteStyle: parseNoteProseQuoteStyle(detail.quoteStyle) ?? DEFAULT_NOTE_PROSE_QUOTE_STYLE,
emphasisStyle: parseNoteProseEmphasisStyle(detail.emphasisStyle) ?? DEFAULT_NOTE_PROSE_EMPHASIS_STYLE,
diff --git a/apps/web/src/lib/wechat-copy.test.mjs b/apps/web/src/lib/wechat-copy.test.mjs
index 54376ef3..a668221a 100644
--- a/apps/web/src/lib/wechat-copy.test.mjs
+++ b/apps/web/src/lib/wechat-copy.test.mjs
@@ -281,6 +281,32 @@ describe("preparePublishArticle", () => {
}
});
+ test("exports body rhythm independently of headings and keeps table cells compact", () => {
+ const container = document.createElement("div");
+ container.dataset.notePalette = "native";
+ const previous = globalThis.getComputedStyle;
+ try {
+ for (const headingStyle of ["default", "bar", "numbered"]) {
+ container.dataset.noteHeadingStyle = headingStyle;
+ globalThis.getComputedStyle = () => ({ getPropertyValue: (name) => ({
+ "--editor-paragraph-spacing": "12px",
+ "--editor-body-text-align": "justify",
+ "--editor-body-letter-spacing": "0.5px",
+ })[name] ?? "" });
+ const root = preparePublishArticle("<h3>标题</h3><p>正文</p><table><tbody><tr><td><p>单元格</p></td></tr></tbody></table>", container);
+ const body = root.querySelector(":scope > p");
+ expect(body.style.margin).toBe("0 0 12px");
+ expect(body.style.textAlign).toBe("justify");
+ expect(body.style.letterSpacing).toBe("0.5px");
+ const cell = root.querySelector("td p");
+ expect(cell.style.margin).toBe("0");
+ expect(cell.style.textAlign).toBe("inherit");
+ }
+ } 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 58a8c94c..e7c77e6e 100644
--- a/apps/web/src/lib/wechat-copy.ts
+++ b/apps/web/src/lib/wechat-copy.ts
@@ -4,8 +4,11 @@ import {
DEFAULT_NOTE_PROSE_LINE_HEIGHT,
flattenDetailsForLinearHtml,
NOTE_PROSE_HEADING_SCALE,
- NOTE_PROSE_PARAGRAPH_SPACING_PX,
noteProseCodeFontSize,
+ noteProseStyleCssVariables,
+ parseNoteProseParagraphSpacing,
+ parseNoteProseTextAlign,
+ parseNoteProseLetterSpacing,
parseNoteProseEmphasisStyle,
parseNoteProseHeadingStyle,
parseNoteProseLineHeight,
@@ -27,7 +30,6 @@ import {
readNoteProseStylePreference,
} from "@/lib/note-prose-style-preference";
-const PARAGRAPH_SPACING = `${NOTE_PROSE_PARAGRAPH_SPACING_PX}px`;
const PUBLISH_FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif";
const PUBLISH_MONO = "'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace";
const BODY_COLOR = "#27272a";
@@ -62,6 +64,7 @@ const applyLegacyWeChatStyles = (
_accentOnly = false,
proseStyle: NoteProseStylePreferences = DEFAULT_NOTE_PROSE_STYLE_PREFERENCES,
) => {
+ const rhythm = noteProseStyleCssVariables(proseStyle);
const fontSize = `${metrics.fontSize}px`;
const lineHeight = String(metrics.lineHeight);
const codeSize = `${noteProseCodeFontSize(metrics.fontSize)}px`;
@@ -75,7 +78,7 @@ const applyLegacyWeChatStyles = (
const bold = colors ? `font-weight: 800; color: ${accent};` : "font-weight: 800;";
const thBackground = colors ? colors.accent : "#f3f4f6";
const thColor = colors ? "#ffffff" : "#111827";
- const textStyle = `font-family: ${PUBLISH_FONT}; font-size: ${fontSize}; line-height: ${lineHeight}; letter-spacing: -0.005em; color: ${BODY_COLOR};`;
+ const textStyle = `font-family: ${PUBLISH_FONT}; font-size: ${fontSize}; line-height: ${lineHeight}; letter-spacing: ${rhythm["--editor-body-letter-spacing"]}; color: ${BODY_COLOR};`;
const h2Base = headingStyle("h2", metrics);
const h3Base = headingStyle("h3", metrics);
const h2Style = proseStyle.headingStyle === "bar"
@@ -107,9 +110,9 @@ const applyLegacyWeChatStyles = (
const thStyle = `padding: 8px 13px; border: 1px solid #e5e5e5; background: ${thBackground}; color: ${thColor}; font-weight: 700; font-size: ${tableHeaderSize}; text-align: left; vertical-align: top;`;
const imgStyle =
"display: block; max-width: 100%; height: auto; margin: 16px 0; padding: 6px; box-sizing: border-box; background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 4px 12px -2px rgba(0,0,0,0.08);";
- const paragraphBottom = proseStyle.headingStyle === "numbered" ? "16px" : PARAGRAPH_SPACING;
+ const paragraphBottom = rhythm["--editor-paragraph-spacing"];
const styles: Record<string, string> = {
- p: `margin: 0 0 ${paragraphBottom}; padding: 0; ${textStyle}`,
+ p: `margin: 0 0 ${paragraphBottom}; padding: 0; text-align: ${rhythm["--editor-body-text-align"]}; ${textStyle}`,
h1: headingStyle("h1", metrics),
h2: h2Style,
h3: h3Style,
@@ -153,7 +156,7 @@ const applyLegacyWeChatStyles = (
const quoted = (tagName === "p" || tagName === "li") && element.closest("blockquote");
const cell = tagName === "p" ? element.closest("th, td") : null;
const baseStyle = cell
- ? `margin: 0; padding: 0; font-family: ${PUBLISH_FONT}; font-size: ${cell.tagName.toLowerCase() === "th" ? tableHeaderSize : fontSize}; line-height: 1.45; letter-spacing: inherit; color: ${cell.tagName.toLowerCase() === "th" ? thColor : BODY_COLOR};`
+ ? `margin: 0; padding: 0; font-family: ${PUBLISH_FONT}; font-size: ${cell.tagName.toLowerCase() === "th" ? tableHeaderSize : fontSize}; line-height: 1.45; text-align: inherit; letter-spacing: inherit; color: ${cell.tagName.toLowerCase() === "th" ? thColor : BODY_COLOR};`
: styles[tagName] || "";
// One color declaration. A second `color` later in the attribute is easy for WeChat to drop.
const style = isMergeDivider
@@ -1254,6 +1257,9 @@ export const readEditorCopyContext = (from?: HTMLElement | null) => {
const customStyleTag = container?.querySelector<HTMLStyleElement>("style[data-theme-custom-css]");
const storedStyle = readNoteProseStylePreference();
const proseStyle: NoteProseStylePreferences = {
+ paragraphSpacing: parseNoteProseParagraphSpacing(readCssNumber(style?.getPropertyValue("--editor-paragraph-spacing"), storedStyle.paragraphSpacing)) ?? storedStyle.paragraphSpacing,
+ textAlign: parseNoteProseTextAlign(style?.getPropertyValue("--editor-body-text-align").trim()) ?? storedStyle.textAlign,
+ letterSpacing: parseNoteProseLetterSpacing(style?.getPropertyValue("--editor-body-letter-spacing").trim()) ?? storedStyle.letterSpacing,
headingStyle: parseNoteProseHeadingStyle(container?.dataset.noteHeadingStyle) ?? storedStyle.headingStyle,
quoteStyle: parseNoteProseQuoteStyle(container?.dataset.noteQuoteStyle) ?? storedStyle.quoteStyle,
emphasisStyle: parseNoteProseEmphasisStyle(container?.dataset.noteEmphasisStyle) ?? storedStyle.emphasisStyle,
diff --git a/apps/web/src/styles/note-print.css b/apps/web/src/styles/note-print.css
index 8b95a1e0..46e2a19a 100644
--- a/apps/web/src/styles/note-print.css
+++ b/apps/web/src/styles/note-print.css
@@ -106,6 +106,7 @@
}
.edgeever-print-content p {
+ text-align: var(--editor-body-text-align, left);
margin: 0 0 var(--editor-paragraph-spacing, 8px);
orphans: 3;
widows: 3;
@@ -483,3 +484,10 @@
.edgeever-print-content .edgeever-mermaid-source {
display: none !important;
}
+
+.edgeever-print-content {
+ letter-spacing: var(--editor-body-letter-spacing, -0.005em);
+}
+.edgeever-print-content :is(th, td) p {
+ text-align: inherit;
+}
diff --git a/apps/web/src/styles/note-prose-styles.css b/apps/web/src/styles/note-prose-styles.css
index 96b3335c..3b0c2ddb 100644
--- a/apps/web/src/styles/note-prose-styles.css
+++ b/apps/web/src/styles/note-prose-styles.css
@@ -1,3 +1,22 @@
+/* Independent body rhythm applies to every heading style. */
+.edgeever-editor .ProseMirror,
+.edgeever-editor .markdown-content {
+ letter-spacing: var(--editor-body-letter-spacing, -0.005em);
+}
+
+.edgeever-editor .ProseMirror p,
+.edgeever-editor .markdown-content p {
+ margin-bottom: var(--editor-paragraph-spacing, 8px);
+ text-align: var(--editor-body-text-align, left);
+}
+
+/* Table cells keep their own compact rhythm and alignment. */
+.edgeever-editor .ProseMirror :is(th, td) p,
+.edgeever-editor .markdown-content :is(th, td) p {
+ margin: 0;
+ text-align: inherit;
+}
+
/* Composable reading styles for headings, blockquotes, and inline emphasis. */
/* 1. Heading style: Left bar ("bar") */
@@ -17,13 +36,6 @@
.edgeever-editor[data-note-heading-style="numbered"] .ProseMirror,
.edgeever-editor[data-note-heading-style="numbered"] .markdown-content {
counter-reset: note-prose-h2;
- letter-spacing: 0.5px;
-}
-
-.edgeever-editor[data-note-heading-style="numbered"] .ProseMirror p,
-.edgeever-editor[data-note-heading-style="numbered"] .markdown-content p {
- margin-bottom: 16px;
- text-align: justify;
}
/* H1: Magazine cover-breaking card */
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 373c9747..59772bc8 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -1151,6 +1151,11 @@ export const enUS = {
start: "Align left",
},
editorBodyFontSizeTitle: "Text size",
+ editorParagraphSpacingTitle: "Paragraph spacing",
+ editorTextAlignTitle: "Body alignment",
+ editorLetterSpacingTitle: "Letter spacing",
+ editorTextAlignOptions: { left: "Left", justify: "Justified" },
+ editorLetterSpacingDefault: "Default",
editorBodyLineHeightTitle: "Line height",
accountSyncDescription: "Syncs to the cloud.",
editorBodyLineHeights: {
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 6706b48b..25243de6 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -1159,6 +1159,11 @@ export const ja = {
start: "左揃え",
},
editorBodyFontSizeTitle: "本文の文字サイズ",
+ editorParagraphSpacingTitle: "段落間隔",
+ editorTextAlignTitle: "本文の配置",
+ editorLetterSpacingTitle: "文字間隔",
+ editorTextAlignOptions: { left: "左揃え", justify: "両端揃え" },
+ editorLetterSpacingDefault: "デフォルト",
editorBodyLineHeightTitle: "行間",
accountSyncDescription: "クラウドに同期します。",
editorBodyLineHeights: {
diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.ts
index 60be6018..4685cb47 100644
--- a/packages/shared/src/i18n/pl.ts
+++ b/packages/shared/src/i18n/pl.ts
@@ -1159,6 +1159,11 @@ export const pl = {
start: "Wyrównaj do lewej",
},
editorBodyFontSizeTitle: "Rozmiar tekstu",
+ editorParagraphSpacingTitle: "Odstęp między akapitami",
+ editorTextAlignTitle: "Wyrównanie tekstu",
+ editorLetterSpacingTitle: "Odstęp między znakami",
+ editorTextAlignOptions: { left: "Do lewej", justify: "Wyjustowany" },
+ editorLetterSpacingDefault: "Domyślny",
editorBodyLineHeightTitle: "Interlinia",
accountSyncDescription: "Synchronizowane z chmurą.",
editorBodyLineHeights: {
diff --git a/packages/shared/src/i18n/ru.ts b/packages/shared/src/i18n/ru.ts
index 5dab20e0..1df8b2f8 100644
--- a/packages/shared/src/i18n/ru.ts
+++ b/packages/shared/src/i18n/ru.ts
@@ -1170,6 +1170,11 @@ export const ru = {
start: "По левому краю",
},
editorBodyFontSizeTitle: "Размер текста",
+ editorParagraphSpacingTitle: "Интервал между абзацами",
+ editorTextAlignTitle: "Выравнивание текста",
+ editorLetterSpacingTitle: "Межбуквенный интервал",
+ editorTextAlignOptions: { left: "По левому краю", justify: "По ширине" },
+ editorLetterSpacingDefault: "По умолчанию",
editorBodyLineHeightTitle: "Межстрочный интервал",
accountSyncDescription: "Синхронизируется с облаком.",
editorBodyLineHeights: {
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index aa4c9cda..e5d94fc7 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -1170,6 +1170,11 @@ export const zhCN = {
start: "靠左显示",
},
editorBodyFontSizeTitle: "正文字号",
+ editorParagraphSpacingTitle: "段落间距",
+ editorTextAlignTitle: "正文对齐",
+ editorLetterSpacingTitle: "字间距",
+ editorTextAlignOptions: { left: "左对齐", justify: "两端对齐" },
+ editorLetterSpacingDefault: "默认",
editorBodyLineHeightTitle: "行高",
accountSyncDescription: "支持云端同步。",
editorBodyLineHeights: {
diff --git a/packages/shared/src/note-prose.ts b/packages/shared/src/note-prose.ts
index 6ec7c2b9..d79b40b1 100644
--- a/packages/shared/src/note-prose.ts
+++ b/packages/shared/src/note-prose.ts
@@ -45,7 +45,27 @@ export const NOTE_PROSE_EMPHASIS_STYLES = [
export type NoteProseEmphasisStyle = (typeof NOTE_PROSE_EMPHASIS_STYLES)[number];
export const DEFAULT_NOTE_PROSE_EMPHASIS_STYLE: NoteProseEmphasisStyle = "default";
+export const NOTE_PROSE_PARAGRAPH_SPACINGS = [8, 12, 16] as const;
+export type NoteProseParagraphSpacing = (typeof NOTE_PROSE_PARAGRAPH_SPACINGS)[number];
+export const NOTE_PROSE_TEXT_ALIGNS = ["left", "justify"] as const;
+export type NoteProseTextAlign = (typeof NOTE_PROSE_TEXT_ALIGNS)[number];
+export const NOTE_PROSE_LETTER_SPACINGS = ["default", "0.5px", "1px"] as const;
+export type NoteProseLetterSpacing = (typeof NOTE_PROSE_LETTER_SPACINGS)[number];
+
+export const parseNoteProseParagraphSpacing = (value: unknown): NoteProseParagraphSpacing | null =>
+ typeof value === "number" && (NOTE_PROSE_PARAGRAPH_SPACINGS as readonly number[]).includes(value)
+ ? value as NoteProseParagraphSpacing : null;
+export const parseNoteProseTextAlign = (value: unknown): NoteProseTextAlign | null =>
+ typeof value === "string" && (NOTE_PROSE_TEXT_ALIGNS as readonly string[]).includes(value)
+ ? value as NoteProseTextAlign : null;
+export const parseNoteProseLetterSpacing = (value: unknown): NoteProseLetterSpacing | null =>
+ typeof value === "string" && (NOTE_PROSE_LETTER_SPACINGS as readonly string[]).includes(value)
+ ? value as NoteProseLetterSpacing : null;
+
export type NoteProseStylePreferences = {
+ paragraphSpacing: NoteProseParagraphSpacing;
+ textAlign: NoteProseTextAlign;
+ letterSpacing: NoteProseLetterSpacing;
headingStyle: NoteProseHeadingStyle;
quoteStyle: NoteProseQuoteStyle;
emphasisStyle: NoteProseEmphasisStyle;
@@ -436,3 +456,11 @@ export const noteProseCssVariables = (prose: ResolvedNoteProse): Record<string,
variables["--note-palette-bg"] = colors.background;
return variables;
};
+
+/** Independent reading rhythm shared by editor, publishing preview, and print. */
+export const noteProseStyleCssVariables = (style: Partial<NoteProseStylePreferences>): Record<string, string> => ({
+ "--editor-paragraph-spacing": `${parseNoteProseParagraphSpacing(style.paragraphSpacing) ?? 8}px`,
+ "--editor-body-text-align": parseNoteProseTextAlign(style.textAlign) ?? "left",
+ "--editor-body-letter-spacing": parseNoteProseLetterSpacing(style.letterSpacing) === null || style.letterSpacing === "default"
+ ? "-0.005em" : style.letterSpacing!,
+});