1
0
This commit is contained in:
Zef Hemel 2023-07-27 15:25:25 +02:00
parent bfce343e7b
commit a3ad239b09

View File

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