File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ const createHeadlessEditor = ({ namespace }: { namespace?: string }) => {
99 namespace,
1010 nodes : [ ...nodes ] ,
1111 theme : theme ,
12- onError : ( ) => { } ,
12+ onError : e => {
13+ console . error ( e ) ;
14+ } ,
1315 html : htmlConfig ,
1416 } ) ;
1517} ;
Original file line number Diff line number Diff line change @@ -36,11 +36,25 @@ function setupDom() {
3636 } ;
3737}
3838
39+ function setupWindow ( ) {
40+ const _window = global . window ;
41+ // need to setup window for CodeNode since facebook#5828
42+ // https://github.com/facebook/lexical/pull/5828
43+ // @ts -expect-error
44+ global . window = global ;
45+
46+ return ( ) => {
47+ global . window = _window ;
48+ } ;
49+ }
50+
3951export async function getHtml ( serializedEditorState : string ) {
4052 const html : string = await new Promise ( resolve => {
53+ const cleanup = setupWindow ( ) ;
4154 const editor = createHeadlessEditor ( { namespace : 'html-renderer' } ) ;
4255
4356 editor . setEditorState ( editor . parseEditorState ( serializedEditorState ) ) ;
57+ cleanup ( ) ;
4458
4559 editor . update ( ( ) => {
4660 try {
You can’t perform that action at this time.
0 commit comments