@@ -11,15 +11,13 @@ import React, {
11
11
HTMLAttributes ,
12
12
ReactNode ,
13
13
Ref ,
14
- useCallback ,
15
14
useEffect ,
16
15
useMemo ,
17
16
useState ,
18
17
} from "react" ;
19
18
import usePrefersColorScheme from "use-prefers-color-scheme" ;
20
19
import { useEditorChange } from "../hooks/useEditorChange" ;
21
20
import { useEditorSelectionChange } from "../hooks/useEditorSelectionChange" ;
22
- import { mergeRefs } from "../util/mergeRefs" ;
23
21
import { BlockNoteContext , useBlockNoteContext } from "./BlockNoteContext" ;
24
22
import {
25
23
BlockNoteDefaultUI ,
@@ -93,22 +91,8 @@ function BlockNoteViewComponent<
93
91
const defaultColorScheme =
94
92
existingContext ?. colorSchemePreference || systemColorScheme ;
95
93
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" ) ;
112
96
113
97
useEditorChange ( onChange || emptyFn , editor ) ;
114
98
useEditorSelectionChange ( onSelectionChange || emptyFn , editor ) ;
@@ -149,10 +133,6 @@ function BlockNoteViewComponent<
149
133
} ;
150
134
} , [ existingContext , editor ] ) ;
151
135
152
- const refs = useMemo ( ( ) => {
153
- return mergeRefs ( [ containerRef , ref ] ) ;
154
- } , [ containerRef , ref ] ) ;
155
-
156
136
return (
157
137
< BlockNoteContext . Provider value = { context as any } >
158
138
< EditorContent editor = { editor } >
@@ -164,7 +144,7 @@ function BlockNoteViewComponent<
164
144
) }
165
145
data-color-scheme = { editorColorScheme }
166
146
{ ...rest }
167
- ref = { refs } >
147
+ ref = { ref } >
168
148
< div
169
149
aria-autocomplete = "list"
170
150
aria-haspopup = "listbox"
0 commit comments