mirror of
https://github.com/dreamstarsky/runbin.git
synced 2026-05-15 14:23:07 +00:00
Feat: Auto-scroll editor on content changes
新增了编辑器自动滚动跟随功能。 1. 修改了 CodePage.vue,移除了父容器的 overflow-auto 样式。 2. 配置了 CodeMirror 的 updateListener,监听文档变化。 3. 当光标位置变化时,使用 scrollIntoView 将视图滚动到底部,优化输入体验。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user