Feat: Auto-scroll editor on content changes

新增了编辑器自动滚动跟随功能。
1. 修改了 CodePage.vue,移除了父容器的 overflow-auto 样式。
2. 配置了 CodeMirror 的 updateListener,监听文档变化。
3. 当光标位置变化时,使用 scrollIntoView 将视图滚动到底部,优化输入体验。
This commit is contained in:
twolate0101
2025-12-10 11:20:36 +08:00
parent 0b81d67882
commit 91c8519c72

View File

@@ -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;