@@ -11,15 +11,13 @@ import React, {
1111 HTMLAttributes ,
1212 ReactNode ,
1313 Ref ,
14- useCallback ,
1514 useEffect ,
1615 useMemo ,
1716 useState ,
1817} from "react" ;
1918import usePrefersColorScheme from "use-prefers-color-scheme" ;
2019import { useEditorChange } from "../hooks/useEditorChange" ;
2120import { useEditorSelectionChange } from "../hooks/useEditorSelectionChange" ;
22- import { mergeRefs } from "../util/mergeRefs" ;
2321import { BlockNoteContext , useBlockNoteContext } from "./BlockNoteContext" ;
2422import {
2523 BlockNoteDefaultUI ,
@@ -93,22 +91,8 @@ function BlockNoteViewComponent<
9391 const defaultColorScheme =
9492 existingContext ?. colorSchemePreference || systemColorScheme ;
9593
96- const [ editorColorScheme , setEditorColorScheme ] = useState <
97- "light" | "dark" | undefined
98- > ( undefined ) ;
99-
100- const containerRef = useCallback (
101- ( node : HTMLDivElement | null ) => {
102- if ( ! node ) {
103- return ;
104- }
105-
106- setEditorColorScheme (
107- theme || defaultColorScheme === "dark" ? "dark" : "light"
108- ) ;
109- } ,
110- [ defaultColorScheme , theme ]
111- ) ;
94+ const editorColorScheme =
95+ theme || ( defaultColorScheme === "dark" ? "dark" : "light" ) ;
11296
11397 useEditorChange ( onChange || emptyFn , editor ) ;
11498 useEditorSelectionChange ( onSelectionChange || emptyFn , editor ) ;
@@ -149,10 +133,6 @@ function BlockNoteViewComponent<
149133 } ;
150134 } , [ existingContext , editor ] ) ;
151135
152- const refs = useMemo ( ( ) => {
153- return mergeRefs ( [ containerRef , ref ] ) ;
154- } , [ containerRef , ref ] ) ;
155-
156136 return (
157137 < BlockNoteContext . Provider value = { context as any } >
158138 < EditorContent editor = { editor } >
@@ -164,7 +144,7 @@ function BlockNoteViewComponent<
164144 ) }
165145 data-color-scheme = { editorColorScheme }
166146 { ...rest }
167- ref = { refs } >
147+ ref = { ref } >
168148 < div
169149 aria-autocomplete = "list"
170150 aria-haspopup = "listbox"
0 commit comments