@@ -26,7 +26,8 @@ import {
2626 topAreaChildren$ ,
2727 Translation ,
2828 useTranslation ,
29- viewMode$
29+ viewMode$ ,
30+ editorWrapperElementRef$
3031} from './plugins/core'
3132import { RealmPlugin , RealmWithPlugins } from './RealmWithPlugins'
3233
@@ -196,7 +197,9 @@ const EditorRootElement: React.FC<{
196197 overlayContainer ?: HTMLElement | null
197198} > = ( { children, className, overlayContainer } ) => {
198199 const editorRootElementRef = React . useRef < HTMLDivElement | null > ( null )
200+ const wrapperElementRef = React . useRef < HTMLDivElement | null > ( null )
199201 const setEditorRootElementRef = usePublisher ( editorRootElementRef$ )
202+ const setEditorWrapperElementRef = usePublisher ( editorWrapperElementRef$ )
200203
201204 React . useEffect ( ( ) => {
202205 const popupContainer = document . createElement ( 'div' )
@@ -210,11 +213,16 @@ const EditorRootElement: React.FC<{
210213 container . appendChild ( popupContainer )
211214 editorRootElementRef . current = popupContainer
212215 setEditorRootElementRef ( editorRootElementRef )
216+ setEditorWrapperElementRef ( wrapperElementRef )
213217 return ( ) => {
214218 popupContainer . remove ( )
215219 }
216- } , [ className , editorRootElementRef , overlayContainer , setEditorRootElementRef ] )
217- return < div className = { classNames ( 'mdxeditor' , styles . editorRoot , styles . editorWrapper , className ) } > { children } </ div >
220+ } , [ className , editorRootElementRef , overlayContainer , setEditorRootElementRef , setEditorWrapperElementRef ] )
221+ return (
222+ < div className = { classNames ( 'mdxeditor' , styles . editorRoot , styles . editorWrapper , className ) } ref = { wrapperElementRef } >
223+ { children }
224+ </ div >
225+ )
218226}
219227
220228const Methods : React . FC < { mdxRef : React . ForwardedRef < MDXEditorMethods > } > = ( { mdxRef } ) => {
0 commit comments