mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat(core): remember the scroll position of doc when routing forward and backward (#8631)
close AF-1011 https://github.com/user-attachments/assets/d2dfeee2-926f-4760-b3fb-8baf5ff90aa9
This commit is contained in:
@@ -32,7 +32,7 @@ import {
|
||||
WorkspaceService,
|
||||
} from '@toeverything/infra';
|
||||
import clsx from 'clsx';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import { PageHeader } from '../../../components';
|
||||
@@ -67,6 +67,8 @@ const DetailPageImpl = () => {
|
||||
|
||||
const isInTrash = useLiveData(doc.meta$.map(meta => meta.trash));
|
||||
const { openPage, jumpToPageBlock } = useNavigateHelper();
|
||||
const scrollViewportRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const editorContainer = useLiveData(editor.editorContainer$);
|
||||
|
||||
const enableKeyboardToolbar =
|
||||
@@ -157,7 +159,11 @@ const DetailPageImpl = () => {
|
||||
);
|
||||
}
|
||||
|
||||
editor.setEditorContainer(editorContainer);
|
||||
editor.bindEditorContainer(
|
||||
editorContainer,
|
||||
null,
|
||||
scrollViewportRef.current
|
||||
);
|
||||
|
||||
return () => {
|
||||
disposable.dispose();
|
||||
@@ -171,6 +177,7 @@ const DetailPageImpl = () => {
|
||||
<div className={styles.mainContainer}>
|
||||
<div
|
||||
data-mode={mode}
|
||||
ref={scrollViewportRef}
|
||||
className={clsx(
|
||||
'affine-page-viewport',
|
||||
styles.affineDocViewport,
|
||||
|
||||
Reference in New Issue
Block a user