File tree Expand file tree Collapse file tree 8 files changed +65
-9
lines changed
Expand file tree Collapse file tree 8 files changed +65
-9
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export const MenuDropdown = forwardRef<
4040
4141 return (
4242 < Ariakit . Menu
43+ unmountOnHide = { true }
4344 className = { mergeCSSClasses ( "bn-ak-menu" , className || "" ) }
4445 ref = { ref } >
4546 { children }
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ export const SideMenu = forwardRef<
1010> ( ( props , ref ) => {
1111 const { className, children, ...rest } = props ;
1212
13- assertEmpty ( rest ) ;
13+ assertEmpty ( rest , false ) ;
1414
1515 return (
16- < Ariakit . Group className = { className } ref = { ref } >
16+ < Ariakit . Group className = { className } ref = { ref } { ... rest } >
1717 { children }
1818 </ Ariakit . Group >
1919 ) ;
Original file line number Diff line number Diff line change @@ -10,10 +10,15 @@ export const SideMenu = forwardRef<
1010> ( ( props , ref ) => {
1111 const { className, children, ...rest } = props ;
1212
13- assertEmpty ( rest ) ;
13+ assertEmpty ( rest , false ) ;
1414
1515 return (
16- < Mantine . Group align = { "center" } gap = { 0 } className = { className } ref = { ref } >
16+ < Mantine . Group
17+ align = { "center" }
18+ gap = { 0 }
19+ className = { className }
20+ ref = { ref }
21+ { ...rest } >
1722 { children }
1823 </ Mantine . Group >
1924 ) ;
Original file line number Diff line number Diff line change 66 InlineContentSchema ,
77 StyleSchema ,
88} from "@blocknote/core" ;
9- import { ReactNode } from "react" ;
9+ import { ReactNode , useMemo } from "react" ;
1010
1111import { AddBlockButton } from "./DefaultButtons/AddBlockButton" ;
1212import { DragHandleButton } from "./DefaultButtons/DragHandleButton" ;
@@ -33,8 +33,28 @@ export const SideMenu = <
3333
3434 const { addBlock, ...rest } = props ;
3535
36+ const dataAttributes = useMemo ( ( ) => {
37+ const attrs : Record < string , string > = {
38+ "data-block-type" : props . block . type ,
39+ } ;
40+
41+ if ( props . block . type === "heading" ) {
42+ attrs [ "data-level" ] = props . block . props . level . toString ( ) ;
43+ }
44+
45+ if ( props . editor . schema . blockSchema [ props . block . type ] . isFileBlock ) {
46+ if ( props . block . props . url ) {
47+ attrs [ "data-url" ] = "true" ;
48+ } else {
49+ attrs [ "data-url" ] = "false" ;
50+ }
51+ }
52+
53+ return attrs ;
54+ } , [ props . block , props . editor . schema . blockSchema ] ) ;
55+
3656 return (
37- < Components . SideMenu . Root className = { "bn-side-menu" } >
57+ < Components . SideMenu . Root className = { "bn-side-menu" } { ... dataAttributes } >
3858 { props . children || (
3959 < >
4060 < AddBlockButton addBlock = { addBlock } />
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export const SideMenuController = <
3939 state ?. referencePos || null ,
4040 1000 ,
4141 {
42- placement : "left" ,
42+ placement : "left-start " ,
4343 }
4444 ) ;
4545
Original file line number Diff line number Diff line change 210210[data-background-color = "pink" ] {
211211 background-color : var (--bn-colors-highlights-pink-background );
212212}
213+
214+ /* Matching Side Menu height to block line height */
215+ .bn-side-menu {
216+ height : 30px ;
217+ }
218+
219+ .bn-side-menu [data-block-type = "heading" ][data-level = "1" ] {
220+ height : 78px ;
221+ }
222+
223+ .bn-side-menu [data-block-type = "heading" ][data-level = "2" ] {
224+ height : 54px ;
225+ }
226+
227+ .bn-side-menu [data-block-type = "heading" ][data-level = "3" ] {
228+ height : 37px ;
229+ }
230+
231+ .bn-side-menu [data-block-type = "file" ] {
232+ height : 38px ;
233+ }
234+
235+ .bn-side-menu [data-block-type = "audio" ] {
236+ height : 60px ;
237+ }
238+
239+ .bn-side-menu [data-url = "false" ] {
240+ height : 54px ;
241+ }
Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ export const SideMenu = forwardRef<
88> ( ( props , ref ) => {
99 const { className, children, ...rest } = props ;
1010
11- assertEmpty ( rest ) ;
11+ assertEmpty ( rest , false ) ;
1212
1313 return (
14- < div className = { className } ref = { ref } >
14+ < div className = { className } ref = { ref } { ... rest } >
1515 { children }
1616 </ div >
1717 ) ;
Original file line number Diff line number Diff line change 8282}
8383
8484.bn-side-menu {
85+ align-items : center;
8586 display : flex;
8687 justify-content : center;
8788}
You can’t perform that action at this time.
0 commit comments