From 500a68df7a7de5a5e5b0626cd1998be1ba8080df Mon Sep 17 00:00:00 2001 From: qishaoxuan Date: Wed, 27 Jul 2022 15:53:20 +0800 Subject: [PATCH] fix: adaptation of editor changes and restoration of scrollManager functionality --- .../src/pages/workspace/docs/Page.tsx | 16 ++++++-- .../editor-core/src/editor/plugin/hooks.ts | 4 ++ .../editor-core/src/editor/scroll/scroll.ts | 39 ++++++++++++------- .../editor-core/src/editor/types.ts | 2 + 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx b/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx index 3d4abd6ce..8b0e17f1d 100644 --- a/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx +++ b/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx @@ -1,5 +1,5 @@ /* eslint-disable filename-rules/match */ -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, type UIEvent } from 'react'; import { useParams } from 'react-router'; import { MuiBox as Box, @@ -37,7 +37,8 @@ export function Page(props: PageProps) { const { user } = useUserAndSpaces(); const templatesPortalFlag = useFlag('BooleanTemplatesPortal', false); const dailyNotesFlag = useFlag('BooleanDailyNotes', false); - const editor = useRef(); + const editorRef = useRef(); + const scrollContainerRef = useRef(); useEffect(() => { if (!user?.id || !page_id) return; @@ -60,6 +61,13 @@ export function Page(props: PageProps) { updateRecentPages(); }, [user, props.workspace, page_id]); + const onScroll = (event: UIEvent) => { + editorRef.current.scrollManager.scrollContainer = + scrollContainerRef.current; + editorRef.current.getHooks().onRootNodeScroll(event); + editorRef.current.scrollManager.emitScrollEvent(event); + }; + return ( @@ -104,12 +112,12 @@ export function Page(props: PageProps) { - + {page_id ? ( ) : ( void; beforeCopy: (e: ClipboardEvent) => void; beforeCut: (e: ClipboardEvent) => void; + onRootNodeScroll: (e: React.UIEvent) => void; } export type PayloadType> = T extends []