11import { Fun , Optional } from '@ephox/katamari' ;
22import { SugarElement , SugarNode } from '@ephox/sugar' ;
33import * as React from 'react' ;
4+ import * as ReactDOMClient from 'react-dom/client' ;
45import { Editor , IAllProps , IProps , Version } from '../../../main/ts/components/Editor' ;
56import { Editor as TinyMCEEditor } from 'tinymce' ;
67import { before , context } from '@ephox/bedrock-client' ;
78import { VersionLoader } from '@tinymce/miniature' ;
8- import { createRoot } from 'react-dom/client' ;
99
1010// @ts -expect-error Remove when dispose polyfill is not needed
1111Symbol . dispose ??= Symbol ( 'Symbol.dispose' ) ;
@@ -33,7 +33,7 @@ export const render = async (props: Partial<IAllProps> = {}, container: HTMLElem
3333 const originalInit = props . init || { } ;
3434 const originalSetup = originalInit . setup || Fun . noop ;
3535 const ref = React . createRef < Editor > ( ) ;
36- const root = createRoot ( container ) ;
36+ const root = ReactDOMClient . createRoot ( container ) ;
3737
3838 const ctx = await new Promise < Context > ( ( resolve , reject ) => {
3939 const init : IProps [ 'init' ] = {
@@ -44,17 +44,18 @@ export const render = async (props: Partial<IAllProps> = {}, container: HTMLElem
4444 editor . on ( 'SkinLoaded' , ( ) => {
4545 setTimeout ( ( ) => {
4646 Optional . from ( ref . current )
47- . map ( ( editorInstance ) => editorInstance . editor ?. targetElm as HTMLElement )
47+ . bind ( ( editorInstance ) => Optional . from ( editorInstance . editor ?. targetElm ) )
48+ . filter ( ( elm ) => elm instanceof window . HTMLElement )
4849 . map ( SugarElement . fromDom )
4950 . filter ( SugarNode . isHTMLElement )
5051 . map ( ( val ) => val . dom )
51- . fold ( ( ) =>
52- reject ( 'Could not find editor element' ) ,
53- ( DOMNode ) => resolve ( {
54- ref : ref as React . RefObject < Editor > ,
55- editor ,
56- DOMNode
57- } )
52+ . fold ( ( ) => reject ( 'Could not find DOMNode' ) , ( DOMNode ) => {
53+ resolve ( {
54+ ref : ref as React . RefObject < Editor > ,
55+ editor ,
56+ DOMNode ,
57+ } ) ;
58+ }
5859 ) ;
5960 } , 0 ) ;
6061 } ) ;
0 commit comments