@@ -19,13 +19,18 @@ export const TableContent = () => {
1919 const { t } = useTranslation ( ) ;
2020 const [ isHover , setIsHover ] = useState ( false ) ;
2121
22+ // Filter headings to only show h1, h2, h3 (levels 1-3)
23+ const filteredHeadings = headings ?. filter (
24+ ( heading ) => heading . props . level >= 1 && heading . props . level <= 3 ,
25+ ) ;
26+
2227 useEffect ( ( ) => {
2328 const handleScroll = ( ) => {
24- if ( ! headings ) {
29+ if ( ! filteredHeadings ) {
2530 return ;
2631 }
2732
28- for ( const heading of headings ) {
33+ for ( const heading of filteredHeadings ) {
2934 const elHeading = document . body . querySelector (
3035 `.bn-block-outer[data-id="${ heading . id } "] [data-content-type="heading"]:first-child` ,
3136 ) ;
@@ -69,7 +74,7 @@ export const TableContent = () => {
6974 . getElementById ( MAIN_LAYOUT_ID )
7075 ?. removeEventListener ( 'scroll' , scrollFn ) ;
7176 } ;
72- } , [ headings , setHeadingIdHighlight ] ) ;
77+ } , [ filteredHeadings , setHeadingIdHighlight ] ) ;
7378
7479 const onOpen = ( ) => {
7580 setIsHover ( true ) ;
@@ -88,12 +93,13 @@ export const TableContent = () => {
8893 setIsHover ( false ) ;
8994 } ;
9095
91- if (
96+ const shouldHideTableContent =
9297 ! editor ||
93- ! headings ||
94- headings . length === 0 ||
95- ( headings . length === 1 && ! headings [ 0 ] . contentText )
96- ) {
98+ ! filteredHeadings ||
99+ filteredHeadings . length === 0 ||
100+ ( filteredHeadings . length === 1 && ! filteredHeadings [ 0 ] . contentText ) ;
101+
102+ if ( shouldHideTableContent ) {
97103 return null ;
98104 }
99105
@@ -162,7 +168,7 @@ export const TableContent = () => {
162168 overflow-y : auto;
163169 ` }
164170 >
165- { headings ?. map (
171+ { filteredHeadings ?. map (
166172 ( heading ) =>
167173 heading . contentText && (
168174 < Heading
0 commit comments