From f0fe8f2629d8f48cd6af9c2f62adf269a23c90ed Mon Sep 17 00:00:00 2001 From: KiriAky 107 Date: Sun, 6 Sep 2026 17:15:41 +0800 Subject: [PATCH] feat(editor): add scroll navigation and update theme Markdown behavior --- docs/development/主题组件覆盖检查.md | 23 +++++++ .../src/assets/themes/paper-moments.theme | 5 +- .../src/components/common/MarkdownContent.vue | 2 +- frontend/src/features/editor/EditorPane.vue | 6 ++ .../editor/EditorScrollButtons.spec.ts | 47 ++++++++++++++ .../features/editor/EditorScrollButtons.vue | 62 +++++++++++++++++++ .../themes/CommunityThemePreview.spec.ts | 4 ++ .../features/themes/CommunityThemePreview.vue | 2 + .../src/features/themes/ThemesView.spec.ts | 2 +- .../src/features/themes/themeSpecimen.html | 17 +++++ frontend/src/main.ts | 1 + frontend/src/services/themePackageService.ts | 7 ++- frontend/src/stores/theme.ts | 6 +- frontend/src/styles/markdown-behavior.css | 32 ++++++++++ frontend/src/styles/tokens.css | 3 + 15 files changed, 211 insertions(+), 8 deletions(-) create mode 100644 frontend/src/features/editor/EditorScrollButtons.spec.ts create mode 100644 frontend/src/features/editor/EditorScrollButtons.vue create mode 100644 frontend/src/styles/markdown-behavior.css diff --git a/docs/development/主题组件覆盖检查.md b/docs/development/主题组件覆盖检查.md index d4a04c1..47c9740 100644 --- a/docs/development/主题组件覆盖检查.md +++ b/docs/development/主题组件覆盖检查.md @@ -1,5 +1,28 @@ # 主题组件覆盖检查(2026-09-05) +## 2026-09-06:Markdown 行为与文档滚动适配 + +| 主题 | 当前版本 | +| --- | --- | +| Light / Dark / Sepia | 1.4.0 | +| 纸间时光 | 1.9.0 | +| Ocean Blue | 1.6.0 | +| Midnight Purple | 2.4.0 | + +新增共享 `frontend/src/styles/markdown-behavior.css`,由应用入口及隔离主题预览同时加载。六个主题通过语义变量提供链接悬停与键盘焦点、任务复选框、引用与分隔线、文字选区、表格选区、标题折叠状态、警告框折叠状态和文档滚动按钮配色。标题箭头沿用悬停或键盘聚焦时显示的规则;表格选区采用透明叠色,避免遮住单元格文字。纸间时光保留长文轻量背景实现。 + +只读 Markdown(包括 AI 对话)现在同步代码行号、自动换行和缩进宽度设置。语法是否启用仍由 Markdown 预设与解析器决定;ATX / Setext 等源码写法解析成同级标题后使用相同主题样式,不用 CSS 模拟语法。主题预览新增 H4–H6、嵌套列表、任务列表、链接、行内代码、折叠警告框、带行号长代码及滚动按钮样例。 + +工作区滚动按钮固定在编辑区域右下角,适用于写作和源码模式:顶部只显示到底部、底部只显示到顶部、中间同时显示;空文档或没有可滚动内容时隐藏。滚动状态通过被动监听与动画帧合并更新,尺寸、内容和折叠变化会重新计算,减少动画偏好开启时直接跳转。 + +验证方法: + +1. 运行 `cd frontend` 后执行 `npm test` 和 `npm run build`,检查主题变量覆盖、六主题预览矩阵、主题升级、Markdown 预设和滚动按钮回归。 +2. 本地启动前端,访问 `tests/visual/index.html?theme=light`,依次切换表中六个主题,检查新增样例的链接焦点、复选框、折叠态、代码换行及行号。社区主题已安装旧版本时,应在主题页更新后再检查。 +3. 工作区分别打开空笔记、短笔记、长笔记,切换写作与源码模式,在顶部、中间、底部验证按钮数量和跳转方向;调整窗口尺寸、折叠标题后再次检查。 + +本次自动检查覆盖仓库内六主题的结构和样式变量,不包含用户自行导入的任意第三方 CSS,也不等同于所有浏览器的逐页视觉验收。 + 本次检查仓库内 3 个内置主题和 3 个社区预设,共扫描 105 个前端源文件的组件与语义样式变量。用户自行导入的第三方 CSS 不在仓库中,不据此声称已验收。 ## 范围与结果 diff --git a/frontend/src/assets/themes/paper-moments.theme b/frontend/src/assets/themes/paper-moments.theme index 36869b0..289afc7 100644 --- a/frontend/src/assets/themes/paper-moments.theme +++ b/frontend/src/assets/themes/paper-moments.theme @@ -1,6 +1,6 @@ theme_id: paper-moments name: 纸间时光 · Paper Moments -version: 1.8.1 +version: 1.9.0 author: NotesAgent description: 奶油纸张、手帐虚线与粉蓝胶带,把每天的灵感好好收藏。 min_app_version: 0.2.0 @@ -9,6 +9,9 @@ css_entry: theme.css license: MIT --- [data-theme="paper-moments"] { + --color-markdown-selection: #ecd3c7; + --color-editor-scroll-background: #fff9e9; + --color-editor-scroll-text: #875343; --color-callout-info: #406b7b; --color-callout-success: #536f43; --color-callout-warning: #875f25; diff --git a/frontend/src/components/common/MarkdownContent.vue b/frontend/src/components/common/MarkdownContent.vue index 0fdf620..58fd755 100644 --- a/frontend/src/components/common/MarkdownContent.vue +++ b/frontend/src/components/common/MarkdownContent.vue @@ -24,7 +24,7 @@ watch([() => props.source, diagramTheme, () => themeStore.currentThemeId, () =>