tiptap: keep scroll top

fix/tiptap
fantasticit 2022-08-19 18:54:59 +08:00
parent dd9d4c6da3
commit 27599dca10
1 changed files with 7 additions and 0 deletions

View File

@ -53,7 +53,14 @@ export const ExcalidrawSettingModal: React.FC<IProps> = ({ editor }) => {
return;
}
/**
* FIXME: dom hack
*/
const currentScrollTop = document.querySelector('main#js-tocs-container')?.scrollTop;
editor.chain().focus().setExcalidraw({ data }).run();
setTimeout(() => {
document.querySelector('main#js-tocs-container').scrollTop = currentScrollTop;
});
toggleVisible(false);
}, [Excalidraw, editor, data, toggleVisible]);