pull/483/head
Zef Hemel 2023-07-27 15:25:25 +02:00
parent bfce343e7b
commit a3ad239b09
1 changed files with 7 additions and 4 deletions

View File

@ -17,11 +17,10 @@ export class OpenPages {
const editorView = this.editorView; const editorView = this.editorView;
if (pageState) { if (pageState) {
// Restore state // Restore state
editorView.scrollDOM.scrollTop = pageState!.scrollTop;
try { try {
editorView.dispatch({ editorView.dispatch({
selection: pageState.selection, selection: pageState.selection,
scrollIntoView: true, // scrollIntoView: true,
}); });
} catch { } catch {
// This is fine, just go to the top // This is fine, just go to the top
@ -30,6 +29,10 @@ export class OpenPages {
scrollIntoView: true, scrollIntoView: true,
}); });
} }
setTimeout(() => {
// Next tick, to allow the editor to process the render
editorView.scrollDOM.scrollTop = pageState.scrollTop;
});
} else { } else {
editorView.scrollDOM.scrollTop = 0; editorView.scrollDOM.scrollTop = 0;
editorView.dispatch({ editorView.dispatch({
@ -45,8 +48,8 @@ export class OpenPages {
this.openPages.set( this.openPages.set(
currentPage, currentPage,
new PageState( new PageState(
this.editorView!.scrollDOM.scrollTop, this.editorView.scrollDOM.scrollTop,
this.editorView!.state.selection, this.editorView.state.selection,
), ),
); );
} }