@udecode/plate-heading
Advanced tools
Comparing version 38.0.1 to 38.0.12
@@ -8,3 +8,6 @@ import { H as Heading } from './types-DBDYSKgi.js'; | ||
type TocConfig = PluginConfig<'toc', { | ||
isScroll: boolean; | ||
topOffset: number; | ||
queryHeading?: (editor: SlateEditor) => Heading[]; | ||
scrollContainerSelector?: string; | ||
}>; | ||
@@ -11,0 +14,0 @@ declare const BaseTocPlugin: _udecode_plate_core.SlatePlugin<TocConfig>; |
@@ -92,3 +92,8 @@ "use strict"; | ||
key: "toc", | ||
node: { isElement: true, isVoid: true } | ||
node: { isElement: true, isVoid: true }, | ||
options: { | ||
isScroll: true, | ||
scrollContainerSelector: "#scroll_container", | ||
topOffset: 80 | ||
} | ||
}); | ||
@@ -95,0 +100,0 @@ |
@@ -14,13 +14,11 @@ import * as _udecode_plate_core from '@udecode/plate-core'; | ||
declare const TocPlugin: _udecode_plate_core_react.PlatePlugin<_udecode_plate_core.PluginConfig<"toc", { | ||
isScroll: boolean; | ||
topOffset: number; | ||
queryHeading?: (editor: _udecode_plate_core.SlateEditor) => Heading[]; | ||
scrollContainerSelector?: string; | ||
}, {}, {}>>; | ||
interface TocSideBarProps { | ||
containerRef: React.RefObject<HTMLDivElement>; | ||
className?: string; | ||
onOpenChange?: (open: boolean) => void; | ||
open?: boolean; | ||
rootMargin?: string; | ||
showHeader?: boolean; | ||
style?: React.CSSProperties; | ||
topOffset?: number; | ||
@@ -58,13 +56,7 @@ } | ||
isObserve: boolean; | ||
showHeader: boolean; | ||
tocRef: React$1.RefObject<HTMLElement>; | ||
} | ||
declare const useTocController: ({ activeId, isObserve, showHeader, tocRef, }: UseTocController) => void; | ||
declare const useTocController: ({ activeId, isObserve, tocRef, }: UseTocController) => void; | ||
type useTocElementStateProps = { | ||
isScroll: boolean; | ||
topOffset: number; | ||
scrollContainerSelector?: string; | ||
}; | ||
declare const useTocElementState: ({ isScroll, scrollContainerSelector, topOffset, }: useTocElementStateProps) => { | ||
declare const useTocElementState: () => { | ||
editor: _udecode_plate_core_react.PlateEditor; | ||
@@ -83,3 +75,2 @@ headingList: Heading[]; | ||
isObserve: boolean; | ||
showHeader: boolean; | ||
tocRef: React$1.RefObject<HTMLElement>; | ||
@@ -92,3 +83,3 @@ } | ||
declare const useTocSideBarState: ({ containerRef, open, rootMargin, showHeader, style, topOffset, onOpenChange, }: TocSideBarProps) => { | ||
declare const useTocSideBarState: ({ open, rootMargin, topOffset, }: TocSideBarProps) => { | ||
activeContentId: string; | ||
@@ -101,4 +92,2 @@ editor: _udecode_plate_core_react.PlateEditor; | ||
setMouseInToc: React$1.Dispatch<React$1.SetStateAction<boolean>>; | ||
showHeader: boolean; | ||
style: React$1.CSSProperties | undefined; | ||
tocRef: React$1.RefObject<HTMLElement>; | ||
@@ -110,3 +99,2 @@ onContentScroll: ({ id, behavior, el, }: { | ||
}) => void; | ||
onOpenChange: ((open: boolean) => void) | undefined; | ||
}; | ||
@@ -126,2 +114,2 @@ declare const useTocSideBar: ({ editor, mouseInToc, open, setIsObserve, setMouseInToc, tocRef, onContentScroll, }: ReturnType<typeof useTocSideBarState>) => { | ||
export { HeadingPlugin, TocPlugin, type TocSideBarProps, type UseContentController, checkIn, heightToTop, useContentController, useContentObserver, useTocController, useTocElement, useTocElementState, type useTocElementStateProps, useTocObserver, useTocSideBar, useTocSideBarState }; | ||
export { HeadingPlugin, TocPlugin, type TocSideBarProps, type UseContentController, checkIn, heightToTop, useContentController, useContentObserver, useTocController, useTocElement, useTocElementState, useTocObserver, useTocSideBar, useTocSideBarState }; |
@@ -138,3 +138,8 @@ "use strict"; | ||
key: "toc", | ||
node: { isElement: true, isVoid: true } | ||
node: { isElement: true, isVoid: true }, | ||
options: { | ||
isScroll: true, | ||
scrollContainerSelector: "#scroll_container", | ||
topOffset: 80 | ||
} | ||
}); | ||
@@ -381,3 +386,2 @@ | ||
isObserve, | ||
showHeader, | ||
tocRef | ||
@@ -389,3 +393,2 @@ }) => { | ||
isObserve, | ||
showHeader, | ||
tocRef | ||
@@ -410,8 +413,5 @@ }); | ||
var import_react10 = require("@udecode/plate-common/react"); | ||
var useTocElementState = ({ | ||
isScroll, | ||
scrollContainerSelector, | ||
topOffset | ||
}) => { | ||
const editor = (0, import_react10.useEditorRef)(); | ||
var useTocElementState = () => { | ||
const { editor, getOptions } = (0, import_react10.useEditorPlugin)(TocPlugin); | ||
const { isScroll, scrollContainerSelector, topOffset } = getOptions(); | ||
const headingList = (0, import_react10.useEditorSelector)(getHeadingList, []); | ||
@@ -474,12 +474,15 @@ const containerRef = import_react9.default.useRef(null); | ||
var useTocSideBarState = ({ | ||
containerRef, | ||
open = true, | ||
rootMargin = "0px 0px 0px 0px", | ||
showHeader = true, | ||
style, | ||
topOffset = 0, | ||
onOpenChange | ||
topOffset = 0 | ||
}) => { | ||
const editor = (0, import_react12.useEditorRef)(); | ||
const { editor, getOptions } = (0, import_react12.useEditorPlugin)(TocPlugin); | ||
const { scrollContainerSelector } = getOptions(); | ||
const headingList = (0, import_react12.useEditorSelector)(getHeadingList, []); | ||
const scrollContainerRef = import_react11.default.useRef(null); | ||
import_react11.default.useEffect(() => { | ||
scrollContainerRef.current = document.querySelector( | ||
scrollContainerSelector != null ? scrollContainerSelector : "#scroll_container" | ||
); | ||
}, []); | ||
const tocRef = import_react11.default.useRef(null); | ||
@@ -489,3 +492,3 @@ const [mouseInToc, setMouseInToc] = import_react11.default.useState(false); | ||
const { activeContentId, onContentScroll } = useContentController({ | ||
containerRef, | ||
containerRef: scrollContainerRef, | ||
isObserve, | ||
@@ -498,3 +501,2 @@ rootMargin, | ||
isObserve, | ||
showHeader, | ||
tocRef | ||
@@ -510,7 +512,4 @@ }); | ||
setMouseInToc, | ||
showHeader, | ||
style, | ||
tocRef, | ||
onContentScroll, | ||
onOpenChange | ||
onContentScroll | ||
}; | ||
@@ -517,0 +516,0 @@ }; |
{ | ||
"name": "@udecode/plate-heading", | ||
"version": "38.0.1", | ||
"version": "38.0.12", | ||
"description": "Headings plugin for Plate", | ||
@@ -56,3 +56,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@udecode/plate-common": ">=38.0.1", | ||
"@udecode/plate-common": ">=38.0.6", | ||
"react": ">=16.8.0", | ||
@@ -59,0 +59,0 @@ "react-dom": ">=16.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
122328
1422