Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Nov 11, 2024
1 parent a0e771a commit 7cf8b9f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/heading/src/react/hooks/useTocSideBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { getNode } from '@udecode/plate-common';
import {
toDOMNode,
useEditorContainerRef,
useEditorPlugin,
useEditorSelector,
} from '@udecode/plate-common/react';
Expand All @@ -20,17 +21,9 @@ export const useTocSideBarState = ({
rootMargin = '0px 0px 0px 0px',
topOffset = 0,
}: TocSideBarProps) => {
const { editor, getOptions } = useEditorPlugin(TocPlugin);
const { scrollContainerSelector } = getOptions();
const { editor } = useEditorPlugin(TocPlugin);
const headingList = useEditorSelector(getHeadingList, []);
const scrollContainerRef = React.useRef<HTMLDivElement | null>(null);

React.useEffect(() => {
scrollContainerRef.current = document.querySelector(
scrollContainerSelector ?? `#${editor.uid}`
)!;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const containerRef = useEditorContainerRef();

const tocRef = React.useRef<HTMLElement>(null);

Expand All @@ -39,7 +32,7 @@ export const useTocSideBarState = ({
const [isObserve, setIsObserve] = React.useState(open);

const { activeContentId, onContentScroll } = useContentController({
containerRef: scrollContainerRef,
containerRef,
isObserve,
rootMargin,
topOffset,
Expand Down

0 comments on commit 7cf8b9f

Please sign in to comment.