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 Markdown and rich text reading gutters

tianma-ifeaf9c10b2383
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index f3b5368b..1051e833 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -39,6 +39,7 @@ import { MemoEditorFocusModeButton, MemoEditorTopRowLeading, MemoEditorUpdatedLa
import { MemoEditorToolbarDivider } from "@/components/MemoEditorToolbarChrome";
import {
MEMO_EDITOR_READING_GUTTER_CLASS_NAME,
+ MEMO_EDITOR_READING_GUTTER_PROPERTIES_CLASS_NAME,
MEMO_EDITOR_TOP_ROW_CLASS_NAME,
nextTitleStatusClearance,
} from "@/components/MemoEditorChromeDensity";
@@ -4096,6 +4097,7 @@ const RichEditorPane = ({
} as CSSProperties}
className={cn(
"edgeever-editor relative min-h-0 flex-1 bg-transparent",
+ MEMO_EDITOR_READING_GUTTER_PROPERTIES_CLASS_NAME,
useMobilePlainTextEditor
? "overflow-visible"
: useMarkdownSourceEditor
diff --git a/apps/web/src/components/MemoEditorChromeDensity.ts b/apps/web/src/components/MemoEditorChromeDensity.ts
index 18c4ce0b..4647a24e 100644
--- a/apps/web/src/components/MemoEditorChromeDensity.ts
+++ b/apps/web/src/components/MemoEditorChromeDensity.ts
@@ -1,4 +1,8 @@
-export const MEMO_EDITOR_READING_GUTTER_CLASS_NAME = "px-4 sm:px-7 lg:px-24";
+export const MEMO_EDITOR_READING_GUTTER_PROPERTIES_CLASS_NAME =
+ "[--editor-reading-gutter:1rem] sm:[--editor-reading-gutter:1.75rem] lg:[--editor-reading-gutter:6rem]";
+
+export const MEMO_EDITOR_READING_GUTTER_CLASS_NAME =
+ `${MEMO_EDITOR_READING_GUTTER_PROPERTIES_CLASS_NAME} px-[var(--editor-reading-gutter)]`;
export const MEMO_EDITOR_TOP_ROW_CLASS_NAME =
"relative flex min-h-12 items-center justify-between gap-2 border-b border-slate-100 py-2 sm:min-h-9 sm:py-0.5";
diff --git a/apps/web/src/components/MemoEditorHeaderActions.test.mjs b/apps/web/src/components/MemoEditorHeaderActions.test.mjs
index 85cb1868..904890bc 100644
--- a/apps/web/src/components/MemoEditorHeaderActions.test.mjs
+++ b/apps/web/src/components/MemoEditorHeaderActions.test.mjs
@@ -69,13 +69,13 @@ describe("shared memo editor header actions", () => {
expect(densitySource).toContain("max-h-12 overflow-hidden sm:max-h-9");
expect(densitySource.match(/MEMO_EDITOR_TOP_ROW_CLASS_NAME =\s*"([^"]+)"/)?.[1]).not.toContain("sm:px-7");
expect(densitySource.match(/MEMO_EDITOR_TOOLBAR_PADDING_CLASS_NAME =\s*"([^"]+)"/)?.[1]).not.toContain("sm:px-7");
- expect(densitySource).toContain("px-4 sm:px-7 lg:px-24");
+ expect(densitySource).toContain("[--editor-reading-gutter:1rem] sm:[--editor-reading-gutter:1.75rem] lg:[--editor-reading-gutter:6rem]");
expect(densitySource).not.toContain("min-[1600px]:flex");
});
test("aligns the note title, notebook row, and article on one reading gutter", () => {
expect(editorSource).toContain("MEMO_EDITOR_READING_GUTTER_CLASS_NAME");
- expect(densitySource).toContain('export const MEMO_EDITOR_READING_GUTTER_CLASS_NAME = "px-4 sm:px-7 lg:px-24"');
+ expect(densitySource).toContain('px-[var(--editor-reading-gutter)]');
expect(densitySource).toContain("MEMO_EDITOR_READING_GUTTER_CLASS_NAME");
expect(editorSource).toContain("overflow-y-auto lg:[scrollbar-gutter:stable_both-edges]");
});
diff --git a/apps/web/src/components/editor/MarkdownSourceEditor.tsx b/apps/web/src/components/editor/MarkdownSourceEditor.tsx
index 4d8cc20d..72cd53b1 100644
--- a/apps/web/src/components/editor/MarkdownSourceEditor.tsx
+++ b/apps/web/src/components/editor/MarkdownSourceEditor.tsx
@@ -88,9 +88,14 @@ const baseEditorTheme = EditorView.theme({
fontFamily: "inherit",
},
".cm-content": {
- padding: "16px 24px 64px",
+ padding: "16px var(--editor-reading-gutter, 24px) 64px",
minHeight: "100%",
},
+ "@media (min-width: 1024px)": {
+ ".cm-scroller": {
+ scrollbarGutter: "stable both-edges",
+ },
+ },
".cm-line": {
padding: "0",
},