mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Scroll directly to comment position (#28349)
* Scroll directly to comment position * Only use EditorView.scrollIntoView when the target position is outside the viewport * Always listen for editor:scroll-position-restored (#28352) GitOrigin-RevId: 2da23b05ddd4ddbd2631c1da5b27dbef4757c86d
This commit is contained in:
@@ -402,20 +402,31 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
})
|
||||
)
|
||||
if (hasGotoLine(options)) {
|
||||
window.setTimeout(() => jumpToLine(options))
|
||||
const jump = () => jumpToLine(options)
|
||||
|
||||
// Jump to the line again after a stored scroll position has been restored
|
||||
if (isNewDoc) {
|
||||
window.addEventListener(
|
||||
'editor:scroll-position-restored',
|
||||
() => jumpToLine(options),
|
||||
{ once: true }
|
||||
)
|
||||
// Jump to the line after a stored scroll position has been restored
|
||||
window.addEventListener('editor:scroll-position-restored', jump, {
|
||||
once: true,
|
||||
})
|
||||
} else {
|
||||
// Jump directly to the line
|
||||
jump()
|
||||
}
|
||||
} else if (hasGotoOffset(options)) {
|
||||
window.setTimeout(() => {
|
||||
const jump = () => {
|
||||
eventEmitter.emit('editor:gotoOffset', options)
|
||||
})
|
||||
}
|
||||
|
||||
if (isNewDoc) {
|
||||
// Jump to the offset after a stored scroll position has been restored
|
||||
window.addEventListener('editor:scroll-position-restored', jump, {
|
||||
once: true,
|
||||
})
|
||||
} else {
|
||||
// Jump directly to the offset
|
||||
jump()
|
||||
}
|
||||
}
|
||||
|
||||
resolve(doc)
|
||||
|
||||
Reference in New Issue
Block a user