Commit 7cf8b9f 1 parent a0e771a commit 7cf8b9f Copy full SHA for 7cf8b9f
File tree 1 file changed +4
-11
lines changed
packages/heading/src/react/hooks
1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import React from 'react';
3
3
import { getNode } from '@udecode/plate-common' ;
4
4
import {
5
5
toDOMNode ,
6
+ useEditorContainerRef ,
6
7
useEditorPlugin ,
7
8
useEditorSelector ,
8
9
} from '@udecode/plate-common/react' ;
@@ -20,17 +21,9 @@ export const useTocSideBarState = ({
20
21
rootMargin = '0px 0px 0px 0px' ,
21
22
topOffset = 0 ,
22
23
} : TocSideBarProps ) => {
23
- const { editor, getOptions } = useEditorPlugin ( TocPlugin ) ;
24
- const { scrollContainerSelector } = getOptions ( ) ;
24
+ const { editor } = useEditorPlugin ( TocPlugin ) ;
25
25
const headingList = useEditorSelector ( getHeadingList , [ ] ) ;
26
- const scrollContainerRef = React . useRef < HTMLDivElement | null > ( null ) ;
27
-
28
- React . useEffect ( ( ) => {
29
- scrollContainerRef . current = document . querySelector (
30
- scrollContainerSelector ?? `#${ editor . uid } `
31
- ) ! ;
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
- } , [ ] ) ;
26
+ const containerRef = useEditorContainerRef ( ) ;
34
27
35
28
const tocRef = React . useRef < HTMLElement > ( null ) ;
36
29
@@ -39,7 +32,7 @@ export const useTocSideBarState = ({
39
32
const [ isObserve , setIsObserve ] = React . useState ( open ) ;
40
33
41
34
const { activeContentId, onContentScroll } = useContentController ( {
42
- containerRef : scrollContainerRef ,
35
+ containerRef,
43
36
isObserve,
44
37
rootMargin,
45
38
topOffset,
You can’t perform that action at this time.
0 commit comments