From 52e9d0b2d73ab7b5c18e29fd1f49bf222b8a9ee8 Mon Sep 17 00:00:00 2001 From: qishaoxuan Date: Wed, 27 Jul 2022 11:00:56 +0800 Subject: [PATCH] feat: add onScroll hook in editor, resolved #561 --- libs/components/editor-core/src/RenderRoot.tsx | 6 ++++++ libs/components/editor-core/src/editor/plugin/hooks.ts | 4 ++++ libs/components/editor-core/src/editor/types.ts | 2 ++ 3 files changed, 12 insertions(+) diff --git a/libs/components/editor-core/src/RenderRoot.tsx b/libs/components/editor-core/src/RenderRoot.tsx index d6af706ebe..13c2bbbc82 100644 --- a/libs/components/editor-core/src/RenderRoot.tsx +++ b/libs/components/editor-core/src/RenderRoot.tsx @@ -11,6 +11,7 @@ import { type ReturnUnobserve, } from '@toeverything/datasource/db-service'; import { addNewGroup } from './recast-block'; +import { HookType } from './editor'; interface RenderRootProps { editor: BlockEditor; @@ -178,6 +179,10 @@ export const RenderRoot: FC> = ({ editor.getHooks().onRootNodeDrop(event); }; + const onScroll = (event: React.UIEvent) => { + editor.getHooks().onRootNodeScroll(event); + }; + return ( > = ({ onDragOverCapture={onDragOverCapture} onDragEnd={onDragEnd} onDrop={onDrop} + onScroll={onScroll} > void; beforeCopy: (e: ClipboardEvent) => void; beforeCut: (e: ClipboardEvent) => void; + onRootNodeScroll: (e: React.UIEvent) => void; } export type AnyFunction = (...args: any[]) => any;