From 91c8519c7227fadd6ede61f0c780113a988ccc93 Mon Sep 17 00:00:00 2001 From: twolate0101 <170792018+twolate0101@users.noreply.github.com> Date: Wed, 10 Dec 2025 11:20:36 +0800 Subject: [PATCH] Feat: Auto-scroll editor on content changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增了编辑器自动滚动跟随功能。 1. 修改了 CodePage.vue,移除了父容器的 overflow-auto 样式。 2. 配置了 CodeMirror 的 updateListener,监听文档变化。 3. 当光标位置变化时,使用 scrollIntoView 将视图滚动到底部,优化输入体验。 --- web/src/pages/CodePage.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/web/src/pages/CodePage.vue b/web/src/pages/CodePage.vue index e4ffb31..c2004e3 100644 --- a/web/src/pages/CodePage.vue +++ b/web/src/pages/CodePage.vue @@ -125,13 +125,10 @@ onMounted(() => { cpp(), ls, indentUnit.of(" "), - // ✨✨✨ 1. 新增:强制编辑器高度 100%,让它自己管理滚动条 ✨✨✨ EditorView.theme({ "&": { height: "100%" }, ".cm-scroller": { overflow: "auto" } }), - - // ✨✨✨ 2. 修改:滚动逻辑 ✨✨✨ EditorView.updateListener.of((update) => { if (update.docChanged && update.selectionSet) { const cursorParams = update.state.selection.main.head;