Skip to content

Commit f0f1f50

Browse files
committed
fix(app): 统一笔记三滚动面底部留白(约视区高 1/3)
1 parent 37874c6 commit f0f1f50

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎app/src/components/NoteEditView.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
} from "./markdownEdit";
1919
// v0.16.1:正文多色荧光笔——色板复用(选中色 → 包裹 ==[色]…==)
2020
import NoteColorPicker from "./NoteColorPicker";
21+
// 批 3(用户问题9):降级 textarea 底部留白与阅读/CM 同源(滚动行程一致)
22+
import { BOTTOM_BREATHER_CSS } from "../utils/contentBreather";
2123

2224
interface Props {
2325
note: Note;
@@ -397,7 +399,7 @@ const NoteEditView = forwardRef<NoteEditHandle, Props>(function NoteEditView({ n
397399
onPaste={(e) => { handleImagePaste(e); }}
398400
onBlur={() => { if (dirty) void saveDraft(false); }}
399401
autoFocus // v0.12.2:新建即编辑态聚焦首行(去摩擦——零对话框新建后直接可输入)
400-
style={{ flex: 1, padding: 16, fontSize: 14, lineHeight: 1.8, border: "none", outline: "none", resize: "none", fontFamily: "monospace", background: "#fcfcfc" }}
402+
style={{ flex: 1, padding: `16px 16px ${BOTTOM_BREATHER_CSS}`, fontSize: 14, lineHeight: 1.8, border: "none", outline: "none", resize: "none", fontFamily: "monospace", background: "#fcfcfc" }}
401403
placeholder="在此编辑笔记内容…"
402404
/>
403405

‎app/src/components/NoteReadingView.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type { Note } from "../types";
1515
import NoteMarkdown from "./NoteMarkdown";
1616
import ColumnBar from "./ColumnBar";
1717
import { fmtDate, parseTags } from "./NoteListView";
18+
// 批 3(用户问题9):阅读容器底部留白与编辑双面同源(末段不再贴底无法上移)
19+
import { BOTTOM_BREATHER_CSS } from "../utils/contentBreather";
1820

1921
interface Props {
2022
note: Note;
@@ -240,7 +242,7 @@ export default function NoteReadingView({
240242
{editing ? (
241243
editor
242244
) : (
243-
<div ref={contentRef} style={{ flex: 1, overflowY: "auto", padding: 16, fontSize: 14, lineHeight: 1.8 }}>
245+
<div ref={contentRef} style={{ flex: 1, overflowY: "auto", padding: `16px 16px ${BOTTOM_BREATHER_CSS}`, fontSize: 14, lineHeight: 1.8 }}>
244246
{auxPanels}
245247
<NoteMarkdown
246248
note={note}

‎app/src/components/RichEditorView.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { clearDraft, readDraft } from "../utils/draftStore";
2626
import NoteEditView, { type NoteEditHandle } from "./NoteEditView";
2727
// v0.16.1:正文多色荧光笔——色板复用(选中色 → 包裹 ==[色]…==)
2828
import NoteColorPicker from "./NoteColorPicker";
29+
// 批 3(用户问题9):CM 内容底部留白与阅读/textarea 同源(末行可滚离底边)
30+
import { BOTTOM_BREATHER_CSS } from "../utils/contentBreather";
2931

3032
interface Props {
3133
note: Note;
@@ -43,7 +45,8 @@ const TOOLBAR_BTN: React.CSSProperties = {
4345
const editorTheme = EditorView.theme({
4446
"&": { height: "100%", backgroundColor: "#fcfcfc" },
4547
".cm-scroller": { fontFamily: "monospace", fontSize: "14px", lineHeight: "1.8" },
46-
".cm-content": { padding: "16px 0" },
48+
// 底部留白 token 与阅读/textarea 同源(上 16 保留原观感;左右 0 不变)
49+
".cm-content": { padding: `16px 0 ${BOTTOM_BREATHER_CSS}` },
4750
"&.cm-focused": { outline: "none" },
4851
});
4952

‎app/src/utils/contentBreather.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* 笔记正文滚动面统一底部留白 token(批 3 / 用户问题9)。
3+
*
4+
* @ai-context: 三个滚动面——NoteReadingView 阅读容器、RichEditorView
5+
* CodeMirror 的 .cm-content、NoteEditView 降级 textarea——
6+
* 引用同一 padding-bottom 值。Why:滚动行程在内容末尾耗尽
7+
* (无底部留白),末行贴住容器底边、无法上移至视区中央留出
8+
* 呼吸空间;三面同源避免改一处漏一处。
9+
* Why vh + max():仓库 inline-style 为主(无共享 CSS 类基建);flex 布局
10+
* 下各滚动容器高 ≈ 窗口高 − 固定页头,用窗口相对单位 vh 近似
11+
* 「视区高 × 1/3」无需 ResizeObserver 测量(CM 主题在模块
12+
* 作用域构造,也无法注入测量值)。max() 提供矮窗下限,防留白
13+
* 随视口收缩塌没;高窗按 1/3 等比放大,观感一致。
14+
* 边界:非精确的容器比例——页头/工具栏高度使实际留白比例略小于 1/3,
15+
* 符合授权口径「约视区高 1/3」,不做 JS 测量(YAGNI)。
16+
*/
17+
18+
/** 留白下限(px)——滚动容器很矮(<288px)时 vh 项不足 1/3 也有呼吸空间 */
19+
export const BOTTOM_BREATHER_MIN_PX = 96;
20+
21+
/** 留白与视口高之比(约 1/3——超出则末段滚动行程过长、浪费屏高) */
22+
export const BOTTOM_BREATHER_VIEWPORT_RATIO = 1 / 3;
23+
24+
/** 统一底部留白 CSS 值(三滚动面 padding-bottom 唯一数据源) */
25+
export const BOTTOM_BREATHER_CSS = `max(${BOTTOM_BREATHER_MIN_PX}px, ${Math.round(BOTTOM_BREATHER_VIEWPORT_RATIO * 100)}vh)`;

0 commit comments

Comments
 (0)