Commit ea9823e9 by pangchong

feat: 解决 点击编辑区内容时编辑区自动滚动/定位 的问题

parent 9b585f84
......@@ -389,9 +389,26 @@ export function useEditorPanel() {
})
}
const isEditAreaClick = ref(false)
let clickTimer: ReturnType<typeof setTimeout> | null = null
const handleViewportMouseDown = () => {
isEditAreaClick.value = true
if (clickTimer) clearTimeout(clickTimer)
clickTimer = setTimeout(() => {
isEditAreaClick.value = false
}, 200)
}
watch(
() => editorStore.selectedNodeId,
(newId) => syncEditorScroll(newId, true)
(newId) => {
if (isEditAreaClick.value) {
isEditAreaClick.value = false
return
}
syncEditorScroll(newId, false)
}
)
watch(
() => editorStore.lastUndoRedoTime,
......@@ -409,6 +426,8 @@ export function useEditorPanel() {
handleScroll,
setBlockRef,
syncEditorScroll,
scrollTop
scrollTop,
handleViewportMouseDown
}
}
......@@ -46,6 +46,7 @@
class="flex-1 overflow-y-auto min-h-0 leading-relaxed relative"
@scroll="handleScroll"
@contextmenu="handleContextMenu"
@mousedown="handleViewportMouseDown"
>
<!-- 占位撑高,模拟全量内容总高度 -->
<div :style="{ height: totalHeight + 'px', position: 'relative' }">
......@@ -114,7 +115,8 @@ const {
handleScroll,
setBlockRef,
syncEditorScroll,
scrollTop
scrollTop,
handleViewportMouseDown
} = useEditorPanel()
const findReplaceVisible = ref(false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment